Question 1 of 25
Hints left: 3
Q1
What is the primary use of the `java.io` package in Java?
Q2
Which of these method is used to start a server thread?
Q3
What will be the output of the following Java code? import java.io.*; class streams { public static void main(String[] args) { try { FileOutputStream fos = new FileOutputStream("serial"); ObjectOutputStream oos = new ObjectOutputStream(fos); oos.writeInt(5); oos.flush(); oos.close(); } catch(Exception e) { System.out.println("Serialization" + e); System.exit(0); } try { int z; FileInputStream fis = new FileInputStream("serial"); ObjectInputStream ois = new ObjectInputStream(fis); z = ois.readInt(); ois.close(); System.out.println(x); } catch (Exception e) { System.out.print("deserialization"); System.exit(0); } } }
Q4
What will be the output of the following Java code? 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 { int 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); } } } 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; } }
Q5
Which of these is a wrapper around everything associated with a reply from an http server?
Q6
Which of these interface extends DataOutput interface?
Q7
Which of these class is used for operating on request from the client to the server?
Q8
Which of these method of httpd class is used to write UrlCacheEntry object into local disk?
Q9
What is serialization?
Q10
Which of these is a process of writing the state of an object to a byte stream?
Q11
In Java Networking, which class is used for creating a UDP socket?
Q12
In Java Serialization, what is the purpose of the `serialVersionUID` field?
Q13
Which Java class is used to represent a URL (Uniform Resource Locator)?
Q14
Which of these methods is used to know the full URL of an URL object?
Q15
Default Serialization process cannot be overridden.
Q16
Which of these methods is used to make raw MIME formatted string?
Q17
Which protocol is commonly used for web communication in Java Networking?
Q18
Which of these methods is used to know host of an URL?
Q19
Which of these is a standard for communicating multimedia content over email?
Q20
What is the purpose of the `java.net` package in Java?
Q21
What will be the output of the following Java program? import java.io.*; class Chararrayinput { public static void main(String[] args) { String obj = "abcdefgh"; int length = obj.length(); char c[] = new char[length]; obj.getChars(0, length, c, 0); CharArrayReader input1 = new CharArrayReader(c); CharArrayReader input2 = new CharArrayReader(c, 1, 4); int i; int j; try { while ((i = input1.read()) == (j = input2.read())) { System.out.print((char)i); } } catch (IOException e) { e.printStackTrace(); } } }
Q22
In Java Networking, what is the purpose of the `ServerSocket` class?
Q23
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 { int 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); } } } 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; } }
Q24
How many ports of TCP/IP are reserved for specific protocols?
Q25
Which of the following methods is used to avoid serialization of new class whose super class already implements Serialization?