Practice high-yield Programming & Software Development MCQs on Input Output — Part 1 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
🎉 Set complete! All 40 questions answered.
Question 1 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
When comparing java.io.BufferedWriter and java.io.FileWriter, which capability exist as a method in only one of two ?
Correct Answer: Option D — writting a line separator to the stream
Detailed Academic Explanation:
A newLine() method is provided in BufferedWriter which is not in FileWriter.
💡Key Conceptual Anchor:Input Output
Question 2 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of these class contains the methods used to write in a file?
Correct Answer: Option C — BUfferedOutputStream
Detailed Academic Explanation:
The class BufferedOutputStream in Java contains methods that are used to write data into a file. It provides buffering for output streams, which helps to improve efficiency by reducing the number of write operations to the underlying file.
💡Key Conceptual Anchor:Input Output
Question 3 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the length of the application box made by the following Java program? import java.awt.*; import java.applet.*; public class myapplet extends Applet { public void paint(Graphics g) { g.drawString("A Simple Applet", 20, 20); } }
Correct Answer: Option D — System dependent
Detailed Academic Explanation:
The Java program provided uses the AWT and Applet classes to draw a string on the screen using the paint() method. However, it does not explicitly specify the size (length or width) of the application box (applet window). When an applet does not set its size using methods like setSize() , the actual size of the applet is determined by the HTML page that embeds the applet or by the applet viewer or browser displaying it. Because different systems and viewers may allocate different default sizes, the length of the application box is therefore system dependent .
💡Key Conceptual Anchor:Input Output
Question 4 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which class is used to read data from the keyboard in Java?
Correct Answer: Option A — Scanner
Detailed Academic Explanation:
Scanner is the correct answer to “Which class is used to read data from the keyboard in Java”. This question is standard in competitive examination syllabi for Input Output.
💡Key Conceptual Anchor:Input Output
Question 5 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the purpose of the `System.out.println()` method in Java?
Correct Answer: Option D — It prints data to the standard output stream followed by a newline
Detailed Academic Explanation:
It prints data to the standard output stream followed by a newline is the correct answer to “What is the purpose of the `System.out.println()` method in Java”. This question is standard in competitive examination syllabi for Input Output.
💡Key Conceptual Anchor:Input Output
Question 6 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which method is used to write data to a file in Java?
Correct Answer: Option C — write()
Detailed Academic Explanation:
write() is the correct answer to “Which method is used to write data to a file in Java”. This question is standard in competitive examination syllabi for Input Output.
💡Key Conceptual Anchor:Input Output
Question 7 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
How can you close a file after reading or writing in Java?
Correct Answer: Option B — By using the `close()` method of the file stream
Detailed Academic Explanation:
By using the `close()` method of the file stream is the correct answer to “How can you close a file after reading or writing in Java”. This question is standard in competitive examination syllabi for Input Output.
💡Key Conceptual Anchor:Input Output
Question 8 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the purpose of the `FileInputStream` class in Java?
Correct Answer: Option C — It is used to read data from a file
Detailed Academic Explanation:
It is used to read data from a file is the correct answer to “What is the purpose of the `FileInputStream` class in Java”. This question is standard in competitive examination syllabi for Input Output.
💡Key Conceptual Anchor:Input Output
Question 9 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which class is used to read data from a file in Java?
Correct Answer: Option D — FileReader
Detailed Academic Explanation:
FileReader is the correct answer to “Which class is used to read data from a file in Java”. This question is standard in competitive examination syllabi for Input Output.
💡Key Conceptual Anchor:Input Output
Question 10 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the purpose of the `BufferedReader` class in Java?
Correct Answer: Option A — It is used to read data from a file efficiently
Detailed Academic Explanation:
It is used to read data from a file efficiently is the correct answer to “What is the purpose of the `BufferedReader` class in Java”. This question is standard in competitive examination syllabi for Input Output.
💡Key Conceptual Anchor:Input Output
Question 11 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which method is used to read a line of text from the keyboard in Java?
Correct Answer: Option D — `readLine()`
Detailed Academic Explanation:
`readLine()` is the correct answer to “Which method is used to read a line of text from the keyboard in Java”. This question is standard in competitive examination syllabi for Input Output.
💡Key Conceptual Anchor:Input Output
Question 12 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
In Java, what does the `FileOutputStream` class do?
Correct Answer: Option C — It is used to write data to a file
Detailed Academic Explanation:
It is used to write data to a file is the correct answer to “In Java, what does the `FileOutputStream` class do”. This question is standard in competitive examination syllabi for Input Output.
💡Key Conceptual Anchor:Input Output
Question 13 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the purpose of the `PrintWriter` class in Java?
Correct Answer: Option B — It is used to write formatted text to a file
Detailed Academic Explanation:
It is used to write formatted text to a file is the correct answer to “What is the purpose of the `PrintWriter` class in Java”. This question is standard in competitive examination syllabi for Input Output.
💡Key Conceptual Anchor:Input Output
Question 14 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which class is used to write binary data to a file in Java?
Correct Answer: Option C — `FileOutputStream`
Detailed Academic Explanation:
`FileOutputStream` is the correct answer to “Which class is used to write binary data to a file in Java”. This question is standard in competitive examination syllabi for Input Output.
💡Key Conceptual Anchor:Input Output
Question 15 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
In Java, which method is used to write binary data to a file?
Correct Answer: Option D — `write()`
Detailed Academic Explanation:
`write()` is the correct answer to “In Java, which method is used to write binary data to a file”. This question is standard in competitive examination syllabi for Input Output.
💡Key Conceptual Anchor:Input Output
Question 16 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the purpose of the `FileWriter` class in Java?
Correct Answer: Option A — It is used to write character data to a file
Detailed Academic Explanation:
It is used to write character data to a file is the correct answer to “What is the purpose of the `FileWriter` class in Java”. This question is standard in competitive examination syllabi for Input Output.
💡Key Conceptual Anchor:Input Output
Question 17 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which class is used to write formatted text to a file in Java?
Correct Answer: Option D — `PrintWriter`
Detailed Academic Explanation:
`PrintWriter` is the correct answer to “Which class is used to write formatted text to a file in Java”. This question is standard in competitive examination syllabi for Input Output.
💡Key Conceptual Anchor:Input Output
Question 18 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
In Java, what is the primary purpose of the `DataInputStream` class?
Correct Answer: Option C — It is used to read primitive data types from an input stream
Detailed Academic Explanation:
It is used to read primitive data types from an input stream is the correct answer to “In Java, what is the primary purpose of the `DataInputStream` class”. This question is standard in competitive examination syllabi for Input Output.
💡Key Conceptual Anchor:Input Output
Question 19 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
In Java, what does the `DataOutputStream` class do?
Correct Answer: Option B — It is used to write primitive data types to an output stream
Detailed Academic Explanation:
It is used to write primitive data types to an output stream is the correct answer to “In Java, what does the `DataOutputStream` class do”. This question is standard in competitive examination syllabi for Input Output.
💡Key Conceptual Anchor:Input Output
Question 20 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which class is used to write primitive data types to an output stream in Java?
Correct Answer: Option C — `DataOutputStream`
Detailed Academic Explanation:
`DataOutputStream` is the correct answer to “Which class is used to write primitive data types to an output stream in Java”. This question is standard in competitive examination syllabi for Input Output.
💡Key Conceptual Anchor:Input Output
Question 21 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the purpose of the `RandomAccessFile` class in Java?
Correct Answer: Option D — It allows reading and writing at random positions in a file
Detailed Academic Explanation:
It allows reading and writing at random positions in a file is the correct answer to “What is the purpose of the `RandomAccessFile` class in Java”. This question is standard in competitive examination syllabi for Input Output.
💡Key Conceptual Anchor:Input Output
Question 22 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
In Java, which class is used to read and write character streams?
Correct Answer: Option A — `Reader` and `Writer` classes
Detailed Academic Explanation:
`Reader` and `Writer` classes is the correct answer to “In Java, which class is used to read and write character streams”. This question is standard in competitive examination syllabi for Input Output.
💡Key Conceptual Anchor:Input Output
Question 23 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the primary purpose of the `File` class in Java?
Correct Answer: Option D — It represents a file or directory pathname
Detailed Academic Explanation:
It represents a file or directory pathname is the correct answer to “What is the primary purpose of the `File` class in Java”. This question is standard in competitive examination syllabi for Input Output.
💡Key Conceptual Anchor:Input Output
Question 24 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
In Java, how can you check if a file or directory exists using the `File` class?
Correct Answer: Option C — By using the `exists()` method
Detailed Academic Explanation:
By using the `exists()` method is the correct answer to “In Java, how can you check if a file or directory exists using the `File` class”. This question is standard in competitive examination syllabi for Input Output.
💡Key Conceptual Anchor:Input Output
Question 25 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which method is used to delete a file or directory in Java?
Correct Answer: Option B — `delete()`
Detailed Academic Explanation:
`delete()` is the correct answer to “Which method is used to delete a file or directory in Java”. This question is standard in competitive examination syllabi for Input Output.
💡Key Conceptual Anchor:Input Output
Question 26 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
In Java, what is the purpose of the `File.separator` constant?
Correct Answer: Option C — It represents the platform-specific file separator (e.g., `/` or ``)
Detailed Academic Explanation:
It represents the platform-specific file separator (e.g., `/` or ``) is the correct answer to “In Java, what is the purpose of the `File.separator` constant”. This question is standard in competitive examination syllabi for Input Output.
💡Key Conceptual Anchor:Input Output
Question 27 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the difference between character streams and byte streams in Java?
Correct Answer: Option D — Character streams are used for reading and writing text data, while byte streams are used for reading and writing binary data
Detailed Academic Explanation:
Character streams are used for reading and writing text data, while byte streams are used for reading and writing binary data is the correct answer to “What is the difference between character streams and byte streams in Java”. This question is standard in competitive examination syllabi for Input Output.
💡Key Conceptual Anchor:Input Output
Question 28 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
In Java, what is the purpose of the `BufferedWriter` class?
Correct Answer: Option A — It is used to write character data to a file efficiently
Detailed Academic Explanation:
It is used to write character data to a file efficiently is the correct answer to “In Java, what is the purpose of the `BufferedWriter` class”. This question is standard in competitive examination syllabi for Input Output.
💡Key Conceptual Anchor:Input Output
Question 29 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which class is used for reading character streams in a platform-independent way in Java?
Correct Answer: Option D — `InputStreamReader`
Detailed Academic Explanation:
`InputStreamReader` is the correct answer to “Which class is used for reading character streams in a platform-independent way in Java”. This question is standard in competitive examination syllabi for Input Output.
💡Key Conceptual Anchor:Input Output
Question 30 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
In Java, what is the primary purpose of the `PrintStream` class?
Correct Answer: Option C — It is used to write formatted text to an output stream
Detailed Academic Explanation:
It is used to write formatted text to an output stream is the correct answer to “In Java, what is the primary purpose of the `PrintStream` class”. This question is standard in competitive examination syllabi for Input Output.
💡Key Conceptual Anchor:Input Output
Question 31 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the difference between reading and writing character streams in Java?
Correct Answer: Option B — Reading character streams use `Reader` classes, while writing character streams use `Writer` classes
Detailed Academic Explanation:
Reading character streams use `Reader` classes, while writing character streams use `Writer` classes is the correct answer to “What is the difference between reading and writing character streams in Java”. This question is standard in competitive examination syllabi for Input Output.
💡Key Conceptual Anchor:Input Output
Question 32 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
In Java, which class is used to read binary data from an input stream?
Correct Answer: Option C — `DataInputStream`
Detailed Academic Explanation:
`DataInputStream` is the correct answer to “In Java, which class is used to read binary data from an input stream”. This question is standard in competitive examination syllabi for Input Output.
💡Key Conceptual Anchor:Input Output
Question 33 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the purpose of the `Console` class in Java?
Correct Answer: Option D — It provides methods for reading and writing character-based console input and output
Detailed Academic Explanation:
It provides methods for reading and writing character-based console input and output is the correct answer to “What is the purpose of the `Console` class in Java”. This question is standard in competitive examination syllabi for Input Output.
💡Key Conceptual Anchor:Input Output
Question 34 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
System class is defined in .................
Correct Answer: Option B — java.lang package
Detailed Academic Explanation:
java.lang package is the correct answer to “System class is defined in .................”. This question is standard in competitive examination syllabi for Input Output.
💡Key Conceptual Anchor:Input Output
Question 35 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of these classes defined in java.io and used for file-handling are abstract? A. InputStream B. PrintStream C. Reader D. FileInputStream E. FileWriter
Correct Answer: Option C — A and C
Detailed Academic Explanation:
A and C is the correct answer to “Which of these classes defined in java.io and used for file-handling are abstract? A. InputStream B. PrintStream C. Reader D. FileInputStream E. FileWriter”. This question is standard in competitive examination syllabi for Input Output.
💡Key Conceptual Anchor:Input Output
Question 36 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What does AWT stands for?
Correct Answer: Option C — Abstract Window Toolkit
Detailed Academic Explanation:
Abstract Window Toolkit is the correct answer to “What does AWT stands for”. This question is standard in competitive examination syllabi for Input Output.
💡Key Conceptual Anchor:Input Output
Question 37 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of these is used to perform all input & output operations in Java?
Correct Answer: Option A — streams
Detailed Academic Explanation:
streams is the correct answer to “Which of these is used to perform all input & output operations in Java”. This question is standard in competitive examination syllabi for Input Output.
💡Key Conceptual Anchor:Input Output
Question 38 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of these is a type of stream in Java?
Correct Answer: Option C — Byte stream
Detailed Academic Explanation:
Byte stream is the correct answer to “Which of these is a type of stream in Java”. This question is standard in competitive examination syllabi for Input Output.
💡Key Conceptual Anchor:Input Output
Question 39 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of these classes are used by character streams for input and output operations?
Correct Answer: Option B — Writer
Detailed Academic Explanation:
Writer is the correct answer to “Which of these classes are used by character streams for input and output operations”. This question is standard in competitive examination syllabi for Input Output.
💡Key Conceptual Anchor:Input Output
Question 40 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of these class is used to read from byte array?
Correct Answer: Option D — ByteArrayInputStream
Detailed Academic Explanation:
ByteArrayInputStream is the correct answer to “Which of these class is used to read from byte array”. This question is standard in competitive examination syllabi for Input Output.
💡Key Conceptual Anchor:Input Output
✓Link copied to clipboard
Continue Your Practice
Advance Html — Part 1
Master the next curriculum module with 40 exam-standard MCQs.
💡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.