Practice high-yield Programming & Software Development MCQs on Input Output — Part 2 with worked academic solutions for FPSC, PPSC, NTS, NITB, PTS.
Questions
33
Difficulty Level
Exam-Level
Target Exams
FPSC, PPSC, NTS...
Estimated Time
40 mins
Exam-Level FPSC PPSC NTS NITB PTS
Verified for Commission Syllabus • Oct 14, 2026
33
Verified Practice Questions
Interactive test mode with detailed academic worked solutions
Live Progress|0/33 answered
✓0 correct
✗0 wrong
0% score
🎉 Set complete! All 33 questions answered.
Question 1 of 33
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following Java program if input given is 'abcqfghqbcd'? class Input_Output { public static void main(String args[]) throws IOException { char c; BufferedReader obj = new BufferedReader(new InputStreamReader(System.in)); do { c = (char) obj.read(); System.out.print(c); } while(c != 'q'); } }
Correct Answer: Option C — abcq
Detailed Academic Explanation:
abcq is the correct answer to “What will be the output of the following Java program if input given is 'abcqfghqbcd'? class Input_Output { public static void main(String args[]) throws IOException { char c; BufferedReader obj = new BufferedReader(new InputStreamReader(System.in)); do { c = (char) obj.read(); System.out.print(c); } while(c != 'q'); } }”. This question is standard in competitive examination syllabi for Input Output.
💡Key Conceptual Anchor:Input Output
Question 2 of 33
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following Java program if input given is "abc'def/'egh"? class Input_Output { public static void main(String args[]) throws IOException { char c; BufferedReader obj = new BufferedReader(new InputStreamReader(System.in)); do { c = (char) obj.read(); System.out.print(c); } while(c!='\''); } }
Correct Answer: Option A — abc'
Detailed Academic Explanation:
abc' is the correct answer to “What will be the output of the following Java program if input given is "abc'def/'egh"? class Input_Output { public static void main(String args[]) throws IOException { char c; BufferedReader obj = new BufferedReader(new InputStreamReader(System.in)); do { c = (char) obj.read(); System.out.print(c); } while(c!='\''); } }”. This question is standard in competitive examination syllabi for Input Output.
💡Key Conceptual Anchor:Input Output
Question 3 of 33
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following Java program? class output { public static void main(String args[]) { StringBuffer c = new StringBuffer("Hello"); System.out.println(c.length()); } }
Correct Answer: Option B — 5
Detailed Academic Explanation:
5 is the correct answer to “What will be the output of the following Java program? class output { public static void main(String args[]) { StringBuffer c = new StringBuffer("Hello"); System.out.println(c.length()); } }”. This question is standard in competitive examination syllabi for Input Output.
💡Key Conceptual Anchor:Input Output
Question 4 of 33
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which exception is thrown by read() method?
Correct Answer: Option A — IOException
Detailed Academic Explanation:
IOException is the correct answer to “Which exception is thrown by read() method”. This question is standard in competitive examination syllabi for Input Output.
💡Key Conceptual Anchor:Input Output
Question 5 of 33
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of these is used to read a string from the input stream?
Correct Answer: Option C — read()
Detailed Academic Explanation:
read() is the correct answer to “Which of these is used to read a string from the input stream”. This question is standard in competitive examination syllabi for Input Output.
💡Key Conceptual Anchor:Input Output
Question 6 of 33
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of these class is used to read characters and strings in Java from console?
Correct Answer: Option A — BufferedReader
Detailed Academic Explanation:
BufferedReader is the correct answer to “Which of these class is used to read characters and strings in Java from console”. This question is standard in competitive examination syllabi for Input Output.
💡Key Conceptual Anchor:Input Output
Question 7 of 33
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of these class is implemented by FilterInputStream class?
Correct Answer: Option A — InputStream
Detailed Academic Explanation:
InputStream is the correct answer to “Which of these class is implemented by FilterInputStream class”. This question is standard in competitive examination syllabi for Input Output.
💡Key Conceptual Anchor:Input Output
Question 8 of 33
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following Java program if input given is "Hello stop World"? class Input_Output { public static void main(String args[]) throws IOException { string str; BufferedReader obj = new BufferedReader(new InputStreamReader(System.in)); do { str = (char) obj.readLine(); System.out.print(str); } while(!str.equals("strong")); } }
Correct Answer: Option D — Hello stop World
Detailed Academic Explanation:
Hello stop World is the correct answer to “What will be the output of the following Java program if input given is "Hello stop World"? class Input_Output { public static void main(String args[]) throws IOException { string str; BufferedReader obj = new BufferedReader(new InputStreamReader(System.in)); do { str = (char) obj.readLine(); System.out.print(str); } while(!str.equals("strong")); } }”. This question is standard in competitive examination syllabi for Input Output.
💡Key Conceptual Anchor:Input Output
Question 9 of 33
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following Java program? class output { public static void main(String args[]) { StringBuffer c = new StringBuffer("Hello"); StringBuffer c1 = new StringBuffer(" World"); c.append(c1); System.out.println(c); } }
Correct Answer: Option D — Hello World
Detailed Academic Explanation:
Hello World is the correct answer to “What will be the output of the following Java program? class output { public static void main(String args[]) { StringBuffer c = new StringBuffer("Hello"); StringBuffer c1 = new StringBuffer(" World"); c.append(c1); System.out.println(c); } }”. This question is standard in competitive examination syllabi for Input Output.
💡Key Conceptual Anchor:Input Output
Question 10 of 33
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following Java program? class output { public static void main(String args[]) { StringBuffer s1 = new StringBuffer("Hello"); s1.setCharAt(1,x); System.out.println(s1); } }
Correct Answer: Option C — Hxllo
Detailed Academic Explanation:
Hxllo is the correct answer to “What will be the output of the following Java program? class output { public static void main(String args[]) { StringBuffer s1 = new StringBuffer("Hello"); s1.setCharAt(1,x); System.out.println(s1); } }”. This question is standard in competitive examination syllabi for Input Output.
💡Key Conceptual Anchor:Input Output
Question 11 of 33
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of these class contains the methods print() & println()?
Correct Answer: Option D — PrintStream
Detailed Academic Explanation:
PrintStream is the correct answer to “Which of these class contains the methods print() & println()”. This question is standard in competitive examination syllabi for Input Output.
💡Key Conceptual Anchor:Input Output
Question 12 of 33
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of these methods can be used to writing console output?
Correct Answer: Option D — all of the mentioned
Detailed Academic Explanation:
all of the mentioned is the correct answer to “Which of these methods can be used to writing console output”. This question is standard in competitive examination syllabi for Input Output.
💡Key Conceptual Anchor:Input Output
Question 13 of 33
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of these classes are used by character streams 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 output operations”. This question is standard in competitive examination syllabi for Input Output.
💡Key Conceptual Anchor:Input Output
Question 14 of 33
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of these class is used to read from a file?
Correct Answer: Option C — FileInputStream
Detailed Academic Explanation:
FileInputStream is the correct answer to “Which of these class is used to read from a file”. This question is standard in competitive examination syllabi for Input Output.
💡Key Conceptual Anchor:Input Output
Question 15 of 33
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following Java program? class output { public static void main(String args[]) { String a="hello i love java"; System.out.println(indexof('i')+" "+indexof('o')+" "+lastIndexof('i')+" "+lastIndexof('o') )); } }
Correct Answer: Option A — 6 4 6 9
Detailed Academic Explanation:
6 4 6 9 is the correct answer to “What will be the output of the following Java program? class output { public static void main(String args[]) { String a="hello i love java"; System.out.println(indexof('i')+" "+indexof('o')+" "+lastIndexof('i')+" "+lastIndexof('o') )); } }”. This question is standard in competitive examination syllabi for Input Output.
💡Key Conceptual Anchor:Input Output
Question 16 of 33
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following Java program? class output { public static void main(String args[]) { char c[]={'a','1','b',' ','A','0']; for (int i = 0; i < 5; ++i) { if(Character.isDigit(c[i])) System.out.println(c[i]" is a digit"); if(Character.isWhitespace(c[i])) System.out.println(c[i]" is a Whitespace character"); if(Character.isUpperCase(c[i])) System.out.println(c[i]" is an Upper case Letter"); if(Character.isUpperCase(c[i])) System.out.println(c[i]" is a lower case Letter"); i = i + 3; } } }
Correct Answer: Option A — a is a lower case Letter is White space character
Detailed Academic Explanation:
a is a lower case Letter is White space character is the correct answer to “What will be the output of the following Java program? class output { public static void main(String args[]) { char c[]={'a','1','b',' ','A','0']; for (int i = 0; i < 5; ++i) { if(Character.isDigit(c[i])) System.out.println(c[i]" is a digit"); if(Character.isWhitespace(c[i])) System.out.println(c[i]" is a Whitespace character"); if(Character.isUpperCase(c[i])) System.out.println(c[i]" is an Upper case Letter"); if(Character.isUpperCase(c[i])) System.out.println(c[i]" is a lower case Letter"); i = i + 3; } } }”. This question is standard in competitive examination syllabi for Input Output.
💡Key Conceptual Anchor:Input Output
Question 17 of 33
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following Java program? class output { public static void main(String args[]) { StringBuffer s1 = new StringBuffer("Hello"); StringBuffer s2 = s1.reverse(); System.out.println(s2); } }
Correct Answer: Option B — olleH
Detailed Academic Explanation:
olleH is the correct answer to “What will be the output of the following Java program? class output { public static void main(String args[]) { StringBuffer s1 = new StringBuffer("Hello"); StringBuffer s2 = s1.reverse(); System.out.println(s2); } }”. This question is standard in competitive examination syllabi for Input Output.
💡Key Conceptual Anchor:Input Output
Question 18 of 33
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of these exception is thrown in cases when the file specified for writing is not found?
Correct Answer: Option C — FileNotFoundException
Detailed Academic Explanation:
FileNotFoundException is the correct answer to “Which of these exception is thrown in cases when the file specified for writing is not found”. This question is standard in competitive examination syllabi for Input Output.
💡Key Conceptual Anchor:Input Output
Question 19 of 33
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of these methods are used to read in from file?
Correct Answer: Option B — read()
Detailed Academic Explanation:
read() is the correct answer to “Which of these methods are used to read in from file”. This question is standard in competitive examination syllabi for Input Output.
💡Key Conceptual Anchor:Input Output
Question 20 of 33
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of these values is returned by read() method is end of file (EOF) is encountered?
Correct Answer: Option C — -1
Detailed Academic Explanation:
-1 is the correct answer to “Which of these values is returned by read() method is end of file (EOF) is encountered”. This question is standard in competitive examination syllabi for Input Output.
💡Key Conceptual Anchor:Input Output
Question 21 of 33
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of these exception is thrown by close() and read() methods?
Correct Answer: Option A — IOException
Detailed Academic Explanation:
IOException is the correct answer to “Which of these exception is thrown by close() and read() methods”. This question is standard in competitive examination syllabi for Input Output.
💡Key Conceptual Anchor:Input Output
Question 22 of 33
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of these methods is used to write() into a file?
Correct Answer: Option C — write()
Detailed Academic Explanation:
write() is the correct answer to “Which of these methods is used to write() into a file”. This question is standard in competitive examination syllabi for Input Output.
💡Key Conceptual Anchor:Input Output
Question 23 of 33
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following Java program? import java.io.*; class filesinputoutput { public static void main(String args[]) { InputStream obj = new FileInputStream("inputoutput.java"); System.out.print(obj.available()); } } Note: inputoutput.java is stored in the disk.
Correct Answer: Option C — prints number of bytes in file
Detailed Academic Explanation:
prints number of bytes in file is the correct answer to “What will be the output of the following Java program? import java.io.*; class filesinputoutput { public static void main(String args[]) { InputStream obj = new FileInputStream("inputoutput.java"); System.out.print(obj.available()); } } Note: inputoutput.java is stored in the disk.”. This question is standard in competitive examination syllabi for Input Output.
💡Key Conceptual Anchor:Input Output
Question 24 of 33
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following Java program? import java.io.*; public class filesinputoutput { public static void main(String[] args) { String obj = "abc"; byte b[] = obj.getBytes(); ByteArrayInputStream obj1 = new ByteArrayInputStream(b); for (int i = 0; i < 2; ++ i) { int c; while((c = obj1.read()) != -1) { if(i == 0) { System.out.print(Character.toUpperCase((char)c)); obj2.write(1); } } System.out.print(obj2); } } }
Correct Answer: Option D — AaBaaCaaa
Detailed Academic Explanation:
AaBaaCaaa is the correct answer to “What will be the output of the following Java program? import java.io.*; public class filesinputoutput { public static void main(String[] args) { String obj = "abc"; byte b[] = obj.getBytes(); ByteArrayInputStream obj1 = new ByteArrayInputStream(b); for (int i = 0; i < 2; ++ i) { int c; while((c = obj1.read()) != -1) { if(i == 0) { System.out.print(Character.toUpperCase((char)c)); obj2.write(1); } } System.out.print(obj2); } } }”. This question is standard in competitive examination syllabi for Input Output.
💡Key Conceptual Anchor:Input Output
Question 25 of 33
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following Java program? import java.io.*; class Chararrayinput { public static void main(String[] args) { String obj = "abcdef"; 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, 0, 3); int i; try { while((i = input2.read()) != -1) { System.out.print((char)i); } } catch (IOException e) { e.printStackTrace(); } } }
Correct Answer: Option A — abc
Detailed Academic Explanation:
abc is the correct answer to “What will be the output of the following Java program? import java.io.*; class Chararrayinput { public static void main(String[] args) { String obj = "abcdef"; 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, 0, 3); int i; try { while((i = input2.read()) != -1) { System.out.print((char)i); } } catch (IOException e) { e.printStackTrace(); } } }”. This question is standard in competitive examination syllabi for Input Output.
💡Key Conceptual Anchor:Input Output
Question 26 of 33
★ FPSC
★ PPSC
★ FPSC
★ PPSC
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(); } } }
Correct Answer: Option D — none of the mentioned
Detailed Academic Explanation:
none of the mentioned is the correct answer to “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(); } } }”. This question is standard in competitive examination syllabi for Input Output.
💡Key Conceptual Anchor:Input Output
Question 27 of 33
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of these functions is called to display the output of an applet?
Correct Answer: Option B — paint()
Detailed Academic Explanation:
paint() is the correct answer to “Which of these functions is called to display the output of an applet”. This question is standard in competitive examination syllabi for Input Output.
💡Key Conceptual Anchor:Input Output
Question 28 of 33
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of these methods can be used to output a string in an applet?
Correct Answer: Option C — drawString()
Detailed Academic Explanation:
drawString() is the correct answer to “Which of these methods can be used to output a string in an applet”. This question is standard in competitive examination syllabi for Input Output.
💡Key Conceptual Anchor:Input Output
Question 29 of 33
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of these methods is a part of Abstract Window Toolkit (AWT) ?
Correct Answer: Option B — paint()
Detailed Academic Explanation:
paint() is the correct answer to “Which of these methods is a part of Abstract Window Toolkit (AWT)”. This question is standard in competitive examination syllabi for Input Output.
💡Key Conceptual Anchor:Input Output
Question 30 of 33
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of these modifiers can be used for a variable so that it can be accessed from any thread or parts of a program?
Correct Answer: Option B — volatile
Detailed Academic Explanation:
volatile is the correct answer to “Which of these modifiers can be used for a variable so that it can be accessed from any thread or parts of a program”. This question is standard in competitive examination syllabi for Input Output.
💡Key Conceptual Anchor:Input Output
Question 31 of 33
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of these operators can be used to get run time information about an object?
Correct Answer: Option C — instanceof
Detailed Academic Explanation:
instanceof is the correct answer to “Which of these operators can be used to get run time information about an object”. This question is standard in competitive examination syllabi for Input Output.
💡Key Conceptual Anchor:Input Output
Question 32 of 33
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the Message is displayed in the applet 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 A — A Simple Applet
Detailed Academic Explanation:
A Simple Applet is the correct answer to “What is the Message is displayed in the applet 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); } }”. This question is standard in competitive examination syllabi for Input Output.
💡Key Conceptual Anchor:Input Output
Question 33 of 33
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the length of the application box made the following Java program? import java.awt.*; import java.applet.*; public class myapplet extends Applet { Graphic g; g.drawString("A Simple Applet", 20, 20); }
Correct Answer: Option C — Compilation Error
Detailed Academic Explanation:
Compilation Error is the correct answer to “What is the length of the application box made the following Java program? import java.awt.*; import java.applet.*; public class myapplet extends Applet { Graphic g; g.drawString("A Simple Applet", 20, 20); }”. 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.