Java Foundations 3 Flashcards
What are the two main categories of data types in Java?
Primitives and reference types.
True or False: Java primitives are stored in the heap memory.
False, they are stored in the stack memory.
Fill in the blank: In Java, the primitive data type ‘int’ is used to represent _____ numbers.
integer
Which of the following is NOT a primitive data type in Java: int, String, char, boolean?
String
What type of memory is used for reference types in Java?
Heap memory.
True or False: Reference types can hold a reference to an object.
True.
What happens to primitives when passed as arguments to methods in Java?
They are passed by value.
Multiple choice: Which of the following is a reference type in Java? A) double B) boolean C) ArrayList D) char
C) ArrayList
What is the default value of a boolean primitive in Java?
false
Fill in the blank: The _____ memory area is used for storing method call information and local variables.
stack
True or False: Objects in Java are created in stack memory.
False, they are created in heap memory.
What will happen if you try to access a primitive variable that has not been initialized?
A compilation error will occur.
In Java, which keyword is used to declare a reference type?
new
Multiple choice: When a primitive is passed to a method, what is actually passed? A) Reference B) Object C) Value D) Address
C) Value
What is the size of a ‘long’ primitive in Java?
8 bytes.