Questions and CORRECT Answers
Java developers don't need to know an object's location in memory - CORRECT
ANSWER - true
Java automatically clears the memory once occupied by an object using garbage collection -
CORRECT ANSWER - true
Variables created within a method maintain scope outside that method - CORRECT
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? - CORRECT ANSWER - static variable
The purpose of a setter method is to allow private data to be modified safely - CORRECT
ANSWER - true
The purpose of a getter method is to return the value of a private field - CORRECT
ANSWER - true
Setters are void return type methods - CORRECT ANSWER - true
Encapsulation - CORRECT ANSWER - A technique for limiting one class's visibility to
another
When you write your own constructor, the default constructor is no longer available - CORRECT
ANSWER - true
, Which keyword is used to allocate memory for a newly created object? - CORRECT
ANSWER - new
A constructor is a special method which is commonly used to set the initial values of an object's
fields. - CORRECT ANSWER - true
Class name should follow Camel casing rules. - CORRECT ANSWER - true
What will happen when you try to access an object reference with a null value? - CORRECT
ANSWER - null pointer exception
If fields aren't initialized, they take on a default value - CORRECT ANSWER - true
Objects are accessed using reference variables. - CORRECT ANSWER - true
What is stored within the stack memory? - CORRECT ANSWER - local variables
what is stored in heap memory? - CORRECT ANSWER - objects
An object reference with a null value points to an empty location in memory - CORRECT
ANSWER - true
In Java, the this keyword can be used to reference the current object's fields and methods. -
CORRECT ANSWER - true
To make fields directly accessible to other classes, the class fields must be marked public -
CORRECT ANSWER - true
You can write more than one constructor in a class - CORRECT ANSWER - true