What will be the output of the following Java code? [code] import java.net.*; class networking { public static void

What will be the output of the following Java code?
Code:
    import java.net.*;
    class networking 
    {
        public static void main(String[] args) throws MalformedURLException 
        {
            URL obj = new URL("https://ehoidap.com/javamcq");
            System.out.print(obj.getProtocol());
        }
    }
A. http
B. https
C. www
D. com
 
Answer: a
Explanation: obj.getProtocol() is used to know the protocol used by the host. http stands for hypertext transfer protocol, usually 2 types of protocols are used http and https, where s in https stands for secured.
Output:
Code:
$ javac networking.java
$ java networking 
http
 

Tìm kiếm

Back
Top