Java exam Flashcards
How many primitive data types are there?
8
byte
char
short
int
long
float
double
boolean
What format are
byte
char
short
int
long
represented in?
two’s complement format
(left most bit represents the sign for all except char)
Will float or double overflow?
No
Does Java support a wrapper object for each primitive data type?
Yes ie., Character wrapper object for char primitive data type
Can you declare multiple variables of the same data type in the same line in Java?
Yes
ie., double firstDouble, secondDouble;
Can you declare multiple variables of different data type in the same line in Java?
No
ie., int myInt, short myShort will give an “identifier expected” error
What is an unmodified integer value assumed to be?
A 32 bit int primitive
What is a value containing a decimal point assumed to be?
A 64 bit double
What is considered a valid char literal?
A single character value in single quotes
When does a while statement satisfy compiler’s full initialisation check?
when the if condition is statically known ie.,
while(true) { do something }
it isn’t statically known in scenarios like:
while(v < 1) { do something }