12.
What will be the output of the following Java program?
Note: Host URL is written in html and simple text.
import java.net.*;
class networking 
{
    public static void main(String[] args) throws Exception
    {
        URL obj = new URL("https://www.example.com/javamcq");
        URLConnection obj1 = obj.openConnection();
        System.out.print(obj1.getContentType());
    }
}

13.
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);}  
    }  
}

Read More Section(Java Serialization and Networking)

Each Section contains maximum 100 MCQs question on Java Serialization and Networking. To get more questions visit other sections.