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](https://dsd5zvtm8ll6.cloudfront.net/images/question_images/1706/9/3/7/71465bdcd726de9e1706937711917.jpg)
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
c Variables of the type byte can store values in the range 128 to 127 The exp... View full answer
Get step-by-step solutions from verified subject matter experts
