Vidyalelo
Java Programming · all questions

Java Serialization and Networking
practice.

Practice every MCQ with options. Use Show answers when you want the correct option and solution.

113

Questions

5/6

Page

Pick an option on a question to see the right answer and solution.

Which of these class extend InputStream class?

Select an option to see the answer and solution.

Serializaed object can be transferred via network.

Select an option to see the answer and solution.

Which of these is a process of extracting/removing the state of an object from a stream?

Select an option to see the answer and solution.

What will be the output of the following Java program?
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());
    }
}

Note: Host URL is written in html and simple text.

Select an option to see the answer and solution.

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

Select an option to see the answer and solution.

What does URL stands for?

Select an option to see the answer and solution.

Which of these data member of HttpResponse class is used to store the response from an http server?

Select an option to see the answer and solution.

Which of these method of httpd class is used to get report on each hit to HTTP server?

Select an option to see the answer and solution.

What will be the output of the following Java program?
import java.net.*;
class networking
{
    public static void main(String[] args) throws MalformedURLException
    {
        URL obj = new URL("https://www.example.com/javamcq");
        System.out.print(obj.toExternalForm());
    }
}

Select an option to see the answer and solution.

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

Select an option to see the answer and solution.

Which of these class is used to create servers that listen for either local or remote client programs?

Select an option to see the answer and solution.

How many methods Serializable has?

Select an option to see the answer and solution.

Which API gets the SocketAddress (usually IP address + port number) of the remote host that this packet is being sent to or is coming from.

Select an option to see the answer and solution.

Which of the following methods is not used while Serialization and DeSerialization?

Select an option to see the answer and solution.

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

Select an option to see the answer and solution.

Which of these process occur automatically by java run time system?

Select an option to see the answer and solution.

What will be the output of the following Java program?
import java.io.*;
class streams
{
    public static void main(String[] args) 
    {
        try
        {
      FileOutputStream fos = new FileOutputStream("serial");
      ObjectOutputStream oos = new ObjectOutputStream(fos);
            oos.writeFloat(3.5);
            oos.flush();
            oos.close();
  }
  catch(Exception e)
        {
      System.out.println("Serialization" + e);
            System.exit(0);
        }
  try 
        {
      float x;
      FileInputStream fis = new FileInputStream("serial");
      ObjectInputStream ois = new ObjectInputStream(fis);
            x = ois.readInt();
            ois.close();
      System.out.println(x);		    	
  }
  catch (Exception e)
        {
            System.out.print("deserialization");
      System.exit(0);
  }
    }
}

Select an option to see the answer and solution.

Which of these is a method of ObjectInput interface used to deserialize an object from a stream?

Select an option to see the answer and solution.

Which of these method of DatagramPacket is used to obtain the byte array of data contained in a datagram?

Select an option to see the answer and solution.

What will be the output of the following Java program?
import java.net.*;
class networking 
{
    public static void main(String[] args) throws MalformedURLException 
    {
        URL obj = new URL("https://www.example.com/javamcq");
        System.out.print(obj.getPort());
    }
}

Select an option to see the answer and solution.