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

[A]TCP/IP
[B]DNS
[C]Socket
[D] Proxy Server

Show Answer

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

[A]DatagramPacket
[B]URL
[C]InetAddress
[D]ContentHandler

Show Answer

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

[A]0
[B]1
[C]true
[D]false

Show Answer

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

[A]0
[B]1
[C]true
[D]false

Show Answer

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

[A]Protocol: http
[B]Host Name: www.sanfoundry.com
[C]Port Number: -1
[D]All of the mentioned

Show Answer

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

[A]cisco
[B]cisco.com
[C]www.cisco.com
[D]none of the mentioned

Show Answer