Skip to main content

Input Output — Part 2 MCQs with Explanations

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
Question 1 of 33
★ 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'); } }

Question 2 of 33
★ 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!='\''); } }

Question 3 of 33
★ 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()); } }

Question 4 of 33
★ FPSC ★ PPSC

Which exception is thrown by read() method?

Question 5 of 33
★ FPSC ★ PPSC

Which of these is used to read a string from the input stream?

Question 6 of 33
★ FPSC ★ PPSC

Which of these class is used to read characters and strings in Java from console?

Question 7 of 33
★ FPSC ★ PPSC

Which of these class is implemented by FilterInputStream class?

Question 8 of 33
★ 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")); } }

Question 9 of 33
★ 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); } }

Question 10 of 33
★ 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); } }

Question 11 of 33
★ FPSC ★ PPSC

Which of these class contains the methods print() & println()?

Question 12 of 33
★ FPSC ★ PPSC

Which of these methods can be used to writing console output?

Question 13 of 33
★ FPSC ★ PPSC

Which of these classes are used by character streams output operations?

Question 14 of 33
★ FPSC ★ PPSC

Which of these class is used to read from a file?

Question 15 of 33
★ 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') )); } }

Question 16 of 33
★ 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; } } }

Question 17 of 33
★ 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); } }

Question 18 of 33
★ FPSC ★ PPSC

Which of these exception is thrown in cases when the file specified for writing is not found?

Question 19 of 33
★ FPSC ★ PPSC

Which of these methods are used to read in from file?

Question 20 of 33
★ FPSC ★ PPSC

Which of these values is returned by read() method is end of file (EOF) is encountered?

Question 21 of 33
★ FPSC ★ PPSC

Which of these exception is thrown by close() and read() methods?

Question 22 of 33
★ FPSC ★ PPSC

Which of these methods is used to write() into a file?

Question 23 of 33
★ 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.

Question 24 of 33
★ 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); } } }

Question 25 of 33
★ 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(); } } }

Question 26 of 33
★ 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(); } } }

Question 27 of 33
★ FPSC ★ PPSC

Which of these functions is called to display the output of an applet?

Question 28 of 33
★ FPSC ★ PPSC

Which of these methods can be used to output a string in an applet?

Question 29 of 33
★ FPSC ★ PPSC

Which of these methods is a part of Abstract Window Toolkit (AWT) ?

Question 30 of 33
★ 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?

Question 31 of 33
★ FPSC ★ PPSC

Which of these operators can be used to get run time information about an object?

Question 32 of 33
★ 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); } }

Question 33 of 33
★ 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); }

✓ 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 →