JAVA TEST 3 2025 QUESTIONS
AND ANSWERS
Java developers don't need to know an object's location in memory - ANSWER✔✔-true
Java automatically clears the memory once occupied by an object using garbage
collection - ANSWER✔✔-true
Variables created within a method maintain scope outside that method - ANSWER✔✔-
false
If you need to make a particular variable belong to a class rather than any individual
instance, what type of variable should you use? - ANSWER✔✔-static variable
The purpose of a setter method is to allow private data to be modified safely -
ANSWER✔✔-true
The purpose of a getter method is to return the value of a private field - ANSWER✔✔-
true
Setters are void return type methods - ANSWER✔✔-true
, Encapsulation - ANSWER✔✔-A technique for limiting one class's visibility to another
When you write your own constructor, the default constructor is no longer available -
ANSWER✔✔-true
Which keyword is used to allocate memory for a newly created object? - ANSWER✔✔-
new
A constructor is a special method which is commonly used to set the initial values of an
object's fields. - ANSWER✔✔-true
Class name should follow Camel casing rules. - ANSWER✔✔-true
What will happen when you try to access an object reference with a null value? -
ANSWER✔✔-null pointer exception
If fields aren't initialized, they take on a default value - ANSWER✔✔-true
Objects are accessed using reference variables. - ANSWER✔✔-true
What is stored within the stack memory? - ANSWER✔✔-local variables
what is stored in heap memory? - ANSWER✔✔-objects
An object reference with a null value points to an empty location in memory -
ANSWER✔✔-true
AND ANSWERS
Java developers don't need to know an object's location in memory - ANSWER✔✔-true
Java automatically clears the memory once occupied by an object using garbage
collection - ANSWER✔✔-true
Variables created within a method maintain scope outside that method - ANSWER✔✔-
false
If you need to make a particular variable belong to a class rather than any individual
instance, what type of variable should you use? - ANSWER✔✔-static variable
The purpose of a setter method is to allow private data to be modified safely -
ANSWER✔✔-true
The purpose of a getter method is to return the value of a private field - ANSWER✔✔-
true
Setters are void return type methods - ANSWER✔✔-true
, Encapsulation - ANSWER✔✔-A technique for limiting one class's visibility to another
When you write your own constructor, the default constructor is no longer available -
ANSWER✔✔-true
Which keyword is used to allocate memory for a newly created object? - ANSWER✔✔-
new
A constructor is a special method which is commonly used to set the initial values of an
object's fields. - ANSWER✔✔-true
Class name should follow Camel casing rules. - ANSWER✔✔-true
What will happen when you try to access an object reference with a null value? -
ANSWER✔✔-null pointer exception
If fields aren't initialized, they take on a default value - ANSWER✔✔-true
Objects are accessed using reference variables. - ANSWER✔✔-true
What is stored within the stack memory? - ANSWER✔✔-local variables
what is stored in heap memory? - ANSWER✔✔-objects
An object reference with a null value points to an empty location in memory -
ANSWER✔✔-true