Menu
Topics Index
...
`

ErrorOrNot


If you need explanation Read this topic

If you need Answer Take test on this topic

ErrorOrNot
What will be the output of the following program?
import java.io.*;
public class ErrorOrNot {
    public static void main(String[] args) {
        byte b = (byte) -256;
        PrintStream ps = new PrintStream(System.out);
        ps.println(b);
        ps.print(ps.checkError());
    }
}

A. 0
false
B. 0
true
C. -256
true
D. -256
false
E. Compilation Error or Runtime Error
Topic: Java PrintStream Class

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.

option a is correct. as byte value range is 0 to 256. if it goes beyond that it takes the cycle from 0 to 256 again. so the value is 0.checkerror method flushes the stream nd checks its error state

Posted by Vijay Kumar    2014-06-05 04:04:13


ans :e
can't use class name for arithmetic operations...

Posted by Ananda Kumar    2014-06-05 04:04:50


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-06 04:23:52


© meritcampus 2019

All Rights Reserved.

Open In App