Menu
Topics Index
...
`

Reader


If you need explanation Read this topic

If you need Answer Take test on this topic

Reader
What will be the output of the following program?
import java.io.*;
public class Reader {
    public static void main(String args[]) {
        StringReader r = new StringReader("All is well");
        for (int i = 0; i < 6; i++) {
            char ch = (char) r.read();
            System.out.print(ch + "");
        }
        r.close();
    }
}

A. (EMPTY)
B. All is
C. Compilation Error
D. Runtime Error 
Topic: Reader Class In Java

If you need explanation Read this topic

If you need Answer Take test on this topic

User comments below. All of them might not be correct.

answer c is correct. it thrws compilatn error. because read() method throws io exception

Posted by Vijay Kumar    2014-06-04 04:00:24


ans c as string reader returns byte the conversion of char to byte is not compatible therefore thows compilation error

Posted by Manasa Jyothi Sree    2014-06-04 06:14:55


Congratulations  Vijay Kumar. You are this dose winner. We will send you the link using which you can claim your recharge.

Posted by Merit Campus    2014-06-05 04:11:16


© meritcampus 2019

All Rights Reserved.

Open In App