0
0
Javaprogramming~5 mins

Reference data types in Java - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What are reference data types in Java?
Reference data types store the address (reference) of objects in memory, not the actual data value itself. Examples include classes, arrays, and interfaces.
Click to reveal answer
beginner
How do reference types differ from primitive types in Java?
Primitive types store actual values (like int, double), while reference types store memory addresses pointing to objects. Reference types can be null; primitives cannot.
Click to reveal answer
intermediate
What happens when you assign one reference variable to another?
Both variables point to the same object in memory. Changes through one reference affect the same object seen by the other.
Click to reveal answer
beginner
Can reference variables be null? What does that mean?
Yes, reference variables can be null, meaning they do not point to any object in memory. Accessing methods or fields on a null reference causes a NullPointerException.
Click to reveal answer
beginner
Give an example of a reference data type in Java.
Example:
String name = "Alice";
Here, name is a reference variable pointing to a String object containing "Alice".
Click to reveal answer
Which of the following is a reference data type in Java?
Aint
Bdouble
CString
Dboolean
What does a reference variable store?
AThe actual data value
BThe size of the object
CThe data type of the object
DThe memory address of an object
What happens if you try to use a method on a null reference variable?
AThe program crashes with NullPointerException
BThe method returns null
CThe variable automatically gets initialized
DThe method runs normally
If you assign one reference variable to another, what happens?
ABoth variables point to the same object
BA new object is created
CThe original object is deleted
DThe variables become primitive types
Which of these is NOT a reference data type?
AInterface
Bchar
CArray
DClass
Explain what reference data types are in Java and how they differ from primitive types.
Think about how variables hold data versus how they hold addresses.
You got /4 concepts.
    Describe what happens when you assign one reference variable to another in Java.
    Consider what happens to the memory address stored.
    You got /3 concepts.