Examveda

What will be the output of the following Java program?
import java.io.*;  
import java.net.*;  
public class URLDemo 
{  
    public static void main(String[] args) 
    {  
        try 
        {  
            URL url=new URL("https://www.example.com/java-mcq");  
            System.out.println("Protocol: "+url.getProtocol());  
            System.out.println("Host Name: "+url.getHost());  
            System.out.println("Port Number: "+url.getPort());   
        } catch(Exception e){System.out.println(e);}  
    }  
}

A. Protocol: http

B. Host Name: www.example.com

C. Port Number: -1

D. All of the mentioned

Answer: Option D


This Question Belongs to Java Program >> Java Serialization And Networking

Join The Discussion

Related Questions on Java Serialization and Networking

What is Java Serialization?

A. The process of converting an object into a byte stream

B. The process of converting a byte stream into an object

C. The process of converting an object into a text file

D. The process of converting a text file into an object