1.

What Is The Output Of This Program? 1. Class Output { 2. Public Static Void Main(string Args[]) { 3. Integer I = New Integer(257); 4. Byte X = I.bytevalue(); 5. System.out.print(x); 6. } 7. }

Answer»

i.byteValue() METHOD returns the value of wrapper i as a byte value. i is 257, RANGE of byte is 256 therefore i value exceeds byte range by 1 hence 1 is returned and stored in x.

Output:

$ JAVAC Output.JAVA
$ java Output
1

i.byteValue() method returns the value of wrapper i as a byte value. i is 257, range of byte is 256 therefore i value exceeds byte range by 1 hence 1 is returned and stored in x.

Output:

$ javac Output.java
$ java Output
1



Discussion

No Comment Found

Related InterviewSolutions