My Report

Java Networking Test – 1


Correct Answer: 2 points | Wrong: -1 point
Grades: A* (100% score) | A (80%-99%) | B (60%-80%) | C (40%-60%) | D (0%-40%)
advertisement

1. What will be the output of the following Java program?

 
    import java.net.*;
    class networking 
    {
        public static void main(String[] args) throws UnknownHostException 
        {
            InetAddress obj1 = InetAddress.getByName("cisco.com");
            System.out.print(obj1.getHostName());
        }
    }

2. Which of these class is used to encapsulate IP address and DNS?

3. Which of these is a full form of DNS?

4. How many bits are in a single IP address?

5. What will be the output of the following Java program?

 
    import java.net.*;
    class networking 
    {
        public static void main(String[] args) throws UnknownHostException 
        {
            InetAddress obj1 = InetAddress.getByName("sanfoundry.com");
            InetAddress obj2 = InetAddress.getByName("sanfoundry.com");
            boolean x = obj1.equals(obj2); 
            System.out.print(x);
        }
    }

6. How many ports of TCP/IP are reserved for specific protocols?

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

8. Which of these is a protocol for breaking and sending packets to an address across a network?

9. What will be the output of the following Java program?

 
    import java.net.*;
    public class networking 
    {
        public static void main(String[] args) throws UnknownHostException 
        {
            InetAddress obj1 = InetAddress.getByName("cisco.com");
            InetAddress obj2 = InetAddress.getByName("sanfoundry.com");
            boolean x = obj1.equals(obj2); 
            System.out.print(x);
        }
    }

10. Which of these package contains classes and interfaces for networking?


 

Start practicing “1000 MCQs on Java”, and once you are ready, you can take tests on all topics by attempting our “Java Test Series”.

Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.