Which of the following lines will compile without warning or error.
-
float f=2.3;
-
char c="z";
-
boolean b=null;
-
int i=21;
-
byte b=257;
D
Correct answer
Explanation
int i=21; is a valid declaration and compiles successfully. float f=2.3; fails because 2.3 is a double literal. char c="z"; fails because double quotes are for Strings, not chars. boolean b=null; is invalid because boolean is a primitive, and byte b=257; exceeds byte's range.