Which one is a valid declaration of a boolean?
A boolean can only be assigned the literal true or false.
Which three are valid declarations of a float?
(1) and (3) are integer literals (32 bits), and integers can be legally assigned to floats (also 32 bits). (6) is correct because (F) is appended to the literal, declaring it as a float rather than a double (the default for floating point literals).
(2), (4),and (5) are all doubles.
Which is a valid declarations of a String?
Option A sets the String reference to null.
Option B is wrong because null cannot be in single quotes.
Option C is wrong because there are multiple characters between the single quotes ('abc').
Option D is wrong because you can't cast a char (primitive) to a String (object).
What is the numerical range of a char?
A char is really a 16-bit integer behind the scenes, so it supports 216 (from 0 to 65535) values.
« Prev 123
Contact us: firstname.lastname@example.org
Follow us on twitter!