Which of the next lines compile without an error?
Line float f = 7.0; will not compile because the type of a floating-point constant in java is double. This will compile:
float f = (float) 7.0; or float f = 7.0f;
Line char c = "z"; will not compile because char constant is defined with single quotes. This will compile char c = 'z';
Line byte b = 255; will not compile because the byte type can only hold integers between –128 and +127;
boolean type value can only be true or false.
int j = 'z'; will compile because chars can be automatically casted to an int.

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback
Keep exploring
Java quizzes
Sign Up Now
or Subscribe for future quizzes