What will be the output of the following Java program if input given is “abc’def/’egh”? [code] class Input_Output { public

What will be the output of the following Java program if input given is “abc’def/’egh”?
Code:
    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 != '\'');
        }
    }
A. abc’
B. abcdef/’
C. abc’def/’egh
D. abcqfghq
 
Answer: a
Explanation: \’ is used for single quotes that is for representing ‘ .
Output:
Code:
$ javac Input_Output.java
$ java Input_Output
abc'
This section of our 1000+ Java MCQs focuses on reading & writing files in Java Programming Language.
 

Tìm kiếm

Back
Top