Java Foundations 3 Flashcards

1
Q

What are the two main categories of data types in Java?

A

Primitives and reference types.

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

True or False: Java primitives are stored in the heap memory.

A

False, they are stored in the stack memory.

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

Fill in the blank: In Java, the primitive data type ‘int’ is used to represent _____ numbers.

A

integer

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

Which of the following is NOT a primitive data type in Java: int, String, char, boolean?

A

String

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

What type of memory is used for reference types in Java?

A

Heap memory.

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

True or False: Reference types can hold a reference to an object.

A

True.

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

What happens to primitives when passed as arguments to methods in Java?

A

They are passed by value.

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

Multiple choice: Which of the following is a reference type in Java? A) double B) boolean C) ArrayList D) char

A

C) ArrayList

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

What is the default value of a boolean primitive in Java?

A

false

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

Fill in the blank: The _____ memory area is used for storing method call information and local variables.

A

stack

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

True or False: Objects in Java are created in stack memory.

A

False, they are created in heap memory.

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

What will happen if you try to access a primitive variable that has not been initialized?

A

A compilation error will occur.

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

In Java, which keyword is used to declare a reference type?

A

new

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

Multiple choice: When a primitive is passed to a method, what is actually passed? A) Reference B) Object C) Value D) Address

A

C) Value

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

What is the size of a ‘long’ primitive in Java?

A

8 bytes.

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