Skip to main content

Java Serialization And Networking — Part 2 MCQs with Explanations

Practice high-yield Programming & Software Development MCQs on Java Serialization And Networking — Part 2 with worked academic solutions for FPSC, PPSC, NTS, NITB, PTS.

Questions
40
Difficulty Level
Exam-Level
Target Exams
FPSC, PPSC, NTS...
Estimated Time
48 mins
Exam-Level FPSC PPSC NTS NITB PTS
Verified for Commission Syllabus • Oct 14, 2026
40

Verified Practice Questions

Interactive test mode with detailed academic worked solutions

Live Progress | 0/40 answered
✓ 0 correct ✗ 0 wrong 0% score
Question 1 of 40
★ FPSC ★ PPSC

What is serialization?

Question 2 of 40
★ FPSC ★ PPSC

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

Question 3 of 40
★ FPSC ★ PPSC

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

Question 4 of 40
★ FPSC ★ PPSC

Which of these methods is used to know host of an URL?

Question 5 of 40
★ FPSC ★ PPSC

Which of these interface extends DataOutput interface?

Question 6 of 40
★ FPSC ★ PPSC

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

Question 7 of 40
★ FPSC ★ PPSC

What type of members are not serialized?

Question 8 of 40
★ FPSC ★ PPSC

Which of these interface extends DataInput interface?

Question 9 of 40
★ FPSC ★ PPSC

Which of these class is used to access actual bits or content information of a URL?

Question 10 of 40
★ FPSC ★ PPSC

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

Question 11 of 40
★ FPSC ★ PPSC

Which of these method of DatagramPacket class is used to find the destination address?

Question 12 of 40
★ FPSC ★ PPSC

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

Question 13 of 40
★ FPSC ★ PPSC

Which of these method of DatagramPacket is used to find the port number?

Question 14 of 40
★ FPSC ★ PPSC

Which of these variables stores the number of hits that are successfully served out of cache?

Question 15 of 40
★ FPSC ★ PPSC

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

Question 16 of 40
★ FPSC ★ PPSC

What is deserialization?

Question 17 of 40
★ FPSC ★ PPSC

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.

Question 18 of 40
★ FPSC ★ PPSC

Which of these method is called when http daemon is acting like a normal web server?

Question 19 of 40
★ FPSC ★ PPSC

Which of these method of MimeHeader is used to return the string equivalent of the values stores on MimeHeader?

Question 20 of 40
★ FPSC ★ PPSC

Which of these is an instance variable of class httpd?

Question 21 of 40
★ FPSC ★ PPSC

Which of these exceptions is thrown by URL class's constructors?

Question 22 of 40
★ FPSC ★ PPSC

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

Question 23 of 40
★ FPSC ★ PPSC

Which of these class must be used to send a datagram packets over a connection?

Question 24 of 40
★ FPSC ★ PPSC

Which of these process occur automatically by the java runtime system?

Question 25 of 40
★ FPSC ★ PPSC

Which of these methods of DatagramPacket is used to find the length of byte array?

Question 26 of 40
★ FPSC ★ PPSC

Which of these is a bundle of information passed between machines?

Question 27 of 40
★ FPSC ★ PPSC

Which of these is method of ObjectOutput interface used to write the object to input or output stream as required?

Question 28 of 40
★ FPSC ★ PPSC

Which of these methods of httpd class is used to read data from the stream?

Question 29 of 40
★ FPSC ★ PPSC

Which of these package contains classes and interfaces for networking?

Question 30 of 40
★ FPSC ★ PPSC

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

Question 31 of 40
★ FPSC ★ PPSC

If member does not implement serialization, which exception would be thrown?

Question 32 of 40
★ FPSC ★ PPSC

How many bits are in a single IP address?

Question 33 of 40
★ FPSC ★ PPSC

Which of these transfer protocol must be used so that URL can be accessed by URLConnection class object?

Question 34 of 40
★ FPSC ★ PPSC

Which of these class extend InputStream class?

Question 35 of 40
★ FPSC ★ PPSC

Serializaed object can be transferred via network.

Question 36 of 40
★ FPSC ★ PPSC

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

Question 37 of 40
★ FPSC ★ PPSC

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

Question 38 of 40
★ FPSC ★ PPSC

What does URL stands for?

Question 39 of 40
★ FPSC ★ PPSC

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

Question 40 of 40
★ FPSC ★ PPSC

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

✓ Link copied to clipboard
Continue Your Practice

Advance Html — Part 1

Master the next curriculum module with 40 exam-standard MCQs.

Next Practice Set →

💡 Examiner's Advisory for Programming & Software Development

In competitive commission exams (FPSC, PPSC, KPPSC, SPSC, CSS, PMS), questions are frequently phrased with distractor options designed to catch rote learners. Whenever you answer an MCQ, read the Detailed Academic Explanation and Conceptual Anchor to understand why the remaining options are incorrect.

More Modules in Programming & Software Development

View All →
📚

Study Guides

Topic summaries and syllabus breakdown

Explore Guides →
🎯

Complete Library

Search through 78,000+ verified MCQs

Browse Library →
📱

Mobile App

Offline mock tests and instant bookmarks

Get Mobile App →