Java exam Flashcards

1
Q

How many primitive data types are there?

A

8

byte
char
short
int
long
float
double
boolean

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What format are

byte
char
short
int
long

represented in?

A

two’s complement format
(left most bit represents the sign for all except char)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Will float or double overflow?

A

No

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Does Java support a wrapper object for each primitive data type?

A

Yes ie., Character wrapper object for char primitive data type

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Can you declare multiple variables of the same data type in the same line in Java?

A

Yes

ie., double firstDouble, secondDouble;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Can you declare multiple variables of different data type in the same line in Java?

A

No

ie., int myInt, short myShort will give an “identifier expected” error

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is an unmodified integer value assumed to be?

A

A 32 bit int primitive

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is a value containing a decimal point assumed to be?

A

A 64 bit double

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is considered a valid char literal?

A

A single character value in single quotes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

When does a while statement satisfy compiler’s full initialisation check?

A

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 }

How well did you know this?
1
Not at all
2
3
4
5
Perfectly