51. Which of these class is used to access actual bits or content information of a URL?
52. 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("example.com");
boolean x = obj1.equals(obj2);
System.out.print(x);
}
}
import java.net.*;
public class networking
{
public static void main(String[] args) throws UnknownHostException
{
InetAddress obj1 = InetAddress.getByName("cisco.com");
InetAddress obj2 = InetAddress.getByName("example.com");
boolean x = obj1.equals(obj2);
System.out.print(x);
}
}
53. Which of these method of DatagramPacket class is used to find the destination address?
54. 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("example.com");
InetAddress obj2 = InetAddress.getByName("example.com");
boolean x = obj1.equals(obj2);
System.out.print(x);
}
}
import java.net.*;
class networking
{
public static void main(String[] args) throws UnknownHostException
{
InetAddress obj1 = InetAddress.getByName("example.com");
InetAddress obj2 = InetAddress.getByName("example.com");
boolean x = obj1.equals(obj2);
System.out.print(x);
}
}
55. Which of these method of DatagramPacket is used to find the port number?
56. Which of these variables stores the number of hits that are successfully served out of cache?
57. 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
{
FileInputStream fis = new FileInputStream("serial");
ObjectInputStream ois = new ObjectInputStream(fis);
System.out.println(ois.available());
}
catch (Exception e)
{
System.out.print("deserialization");
System.exit(0);
}
}
}
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
{
FileInputStream fis = new FileInputStream("serial");
ObjectInputStream ois = new ObjectInputStream(fis);
System.out.println(ois.available());
}
catch (Exception e)
{
System.out.print("deserialization");
System.exit(0);
}
}
}
58. What is deserialization?
59. 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();
int len = obj1.getContentLength();
System.out.print(len);
}
}
Note: Host URL is having length of content 127.
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();
int len = obj1.getContentLength();
System.out.print(len);
}
}
Note: Host URL is having length of content 127.
60. Which of these method is called when http daemon is acting like a normal web server?
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.