Question: What is the result of compiling and running the following program? Select the one correct answer. (a) The program will not compile, because a byte

What is the result of compiling and running the following program?

public class Cast ( public static void main(String [] args) { byte

Select the one correct answer.

(a) The program will not compile, because a byte value cannot be assigned to an int variable without using a cast.

(b) The program will compile, and print 128 at runtime.

(c) The program will not compile, because the value 128 is not in the range of values for the byte type.

(d) The program will compile, but will throw a ClassCastException at runtime.

(e) The program will compile, and print 255 at runtime.

public class Cast ( public static void main(String [] args) { byte b = 128; int i = b; System.out.println (i); }

Step by Step Solution

3.46 Rating (153 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

c Variables of the type byte can store values in the range 128 to 127 The exp... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Java Programming 8th Questions!