Reference Variables QuizS2C Home « Reference Variables Quiz

The questions in this Java quiz are on the topics covered in the java - Objects & Classes section of the site. The table below lists the lesson used for each quiz, a description of the lesson content and the quiz number and questions associated with that lesson.

Lesson Summary

Click on a lesson in the table to go to that lesson for a refresher on the topics for that quiz.

Click on a quiz in the table to go straight to the quiz for a particular lesson.

Objects & Classes Lessons Description Quiz Info.
Lesson 1 - ArraysIn this lesson we look at arrays and how to use them in java.Quiz1
8 questions
Lesson 2 - Class Structure & SyntaxFor this lesson we looked at class structure and syntax within our Java programs.Quiz2
8 questions
Lesson 3 - Reference VariablesThis lesson is about reference variables and how to use them within our Java programs.This quiz.
7 questions
Lesson 4 - MethodsWe have used methods throughout the lessons so far so its time for a thorough investigation of what we can do with these members.Quiz4
10 questions
Lesson 5 - Instance Variables & ScopeThis lesson is about instance variables, how to use them and their scope.Quiz5
6 questions
Lesson 6 - ConstructorsIn this lesson we learn about constructors, which we can use to instantiate objects of our classes.Quiz6
7 questions
Lesson 7 - Static MembersFor this lesson we investigate what static means and how to apply it to our class members.Quiz7
6 questions
Lesson 8 - EnumerationsIn our final lesson of this section we go through enumerations which were introduced in java.Quiz8
8 questions

Java Objects & Classes Quiz 3

The quiz below tests your knowledge of the material learnt in Objects & Classes - Lesson 3 - Reference Variables.

Question 1 : Where are objects stored?
- Objects are stored on the heap.
Question 2 : Where are reference variables stored?
- Reference variables are stored on the stack.
Question 3 : How does the JVM reclaim memory?
- The JVM reclaims memory through garbage collection.
Question 4 : Two ways an object becomes eligible for garbage collection are when it goes out of scope and no live references exist and when all pointers to it are set to null. What is the third?
- An object becomes eligible for garbage collection when the object is unreachable.
Question 5 : How can we check the reference type of an object?
- We can check the reference type using the <code>instanceof</code> operator.
Question 6 : What is output from the following code snippet?

public class Testinstanceof {
public static void main (String[] args) {
String moggy = new String();
Cat string = new Cat();
if (string instanceof String) {; // Check for Cat instance
System.out.println("string is a String.");
- You will get a compiler error for <em>inconvertible types</em>.
Question 7 : A reference variable holds an objects state?
- false - A reference variable holds a pointer to an object on the heap.
Quiz Progress Bar Please select an answer

What's Next?

The next quiz on Java Objects & Classes is all about class structure and syntax.