Question 1 of 25
Hints left: 3
Q1
What will be the output of the following Java code? 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.getProtocol()); } }
Q2
Serializaed object can be transferred via network.
Q3
Which of these is a process of extracting/removing the state of an object from a stream?
Q4
Which of these class is used to encapsulate IP address and DNS?
Q5
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); } } }
Q6
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.
Q7
Which of these data member of HttpResponse class is used to store the response from an http server?
Q8
Which of these is a method of ObjectInput interface used to deserialize an object from a stream?
Q9
Which of these method of httpd class is used to get report on each hit to HTTP server?
Q10
Which of these class is used to create servers that listen for either local or remote client programs?
Q11
Which of these is a protocol for breaking and sending packets to an address across a network?
Q12
Which of the following methods is not used while Serialization and DeSerialization?
Q13
Which of these class extend InputStream class?
Q14
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.
Q15
What will be the output of the following Java program? import java.io.*; class serialization { public static void main(String[] args) { try { Myclass object1 = new Myclass("Hello", -7, 2.1e10); FileOutputStream fos = new FileOutputStream("serial"); ObjectOutputStream oos = new ObjectOutputStream(fos); oos.writeObject(object1); oos.flush(); oos.close(); } catch(Exception e) { System.out.println("Serialization" + e); System.exit(0); } try { Myclass object2; FileInputStream fis = new FileInputStream("serial"); ObjectInputStream ois = new ObjectInputStream(fis); object2 = (Myclass)ois.readObject(); ois.close(); System.out.println(object2); } catch (Exception e) { System.out.print("deserialization" + e); System.exit(0); } } } class Myclass implements Serializable { String s; int i; double d; Myclass (String s, int i, double d) { this.d = d; this.i = i; this.s = s; } }
Q16
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()); } }
Q17
Which of these process occur automatically by java run time system?
Q18
Which of these package contains classes and interfaces for networking?
Q19
What does URL stands for?
Q20
How many methods Serializable has?
Q21
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()); } }
Q22
If member does not implement serialization, which exception would be thrown?
Q23
What will be the output of the following Java program? import java.io.FileOutputStream; public class FileOutputStreamExample { public static void main(String args[]) { try { FileOutputStream fout=new FileOutputStream("D:\\example.txt"); String s="Welcome to India."; byte b[]=s.getBytes();//converting string into byte array fout.write(b); fout.close(); System.out.println("Success"); } catch(Exception e){System.out.println(e);} } }
Q24
How many bits are in a single IP address?
Q25
Which of these transfer protocol must be used so that URL can be accessed by URLConnection class object?