• Skip to main content
  • Skip to secondary menu
  • Skip to primary sidebar

JavaTutorOnline

1-on-1 Online Java Training by a Senior Software Engineer

  • Home
  • AP CSA
    • FRQ Practice
      • Arrays
      • ArrayList
      • Strings
      • 2D Arrays
    • MCQ Practice
      • Booleans
      • Iteration
      • Arrays
      • View all Units
  • Courses
  • Tutorials
    • Java
    • Servlets
    • Struts
    • Spring
    • Webservice
  • FAQ
  • Testimonials
  • Blog
  • CONTACT US

AP CSA Unit 1.12–1.14 MCQ Practice: Object References

Home » AP CSA MCQ Practice » Unit 1: Using Objects and Methods

AP CSA Unit 1.12–1.14 MCQ Practice: Object References & Instance Methods

Topics 1.12–1.14 ⏱️ 10 Min Practice ✅ Current AP CSA Framework

Understanding object references is an important part of AP Computer Science A. In this interactive practice set, you will work with Topics 1.12–1.14: object creation, object references, using object references, and calling instance methods.

Key Concepts to Remember Before You Start:


  • References vs. Primitive Values:
    Primitive variables store values such as integers and doubles. An object
    variable stores a reference to an object. The reference can
    be used to access the object’s instance variables and call its instance methods.

  • Aliasing:
    When two reference variables refer to the same object, they are aliases.
    A change to that object’s state through one reference can be observed through
    the other reference.

  • null References:
    A reference variable containing null does not currently refer
    to an object. Calling an instance method using a null reference
    causes a NullPointerException at runtime.

  • Object Creation:
    The new keyword creates an object by invoking a constructor.
    The resulting reference can be assigned to an object variable.

  • Reference Equality:
    For object references, the == operator determines whether two
    references refer to the same object. It does not compare the objects’
    instance-variable values.

Test your object-reference and memory-tracing skills with these 10 practice questions. Select an answer to see the explanation and understand the reasoning behind each result.

Topics 1.12–1.14 Practice

Question 1 of 10 | Score: 0
1. Which of the following best describes what is stored in an object reference variable in Java?
Correct Answer: B An object variable stores a reference to an object. The reference allows the program to access the object’s state and call its instance methods.
2. Consider the following code segment:
String s1 = “Java”;
String s2 = s1;
s2 = “Python”;
System.out.println(s1);
What is printed?
Correct Answer: B Initially, s2 receives the same reference value as s1. Both variables refer to the String containing "Java".When s2 = "Python"; executes, only s2 is reassigned. The value of s1 remains unchanged, so s1 still refers to "Java".
3. Consider the following code segment:
Car c1 = new Car(“Red”);
Car c2 = c1;
c1.setColor(“Blue”);
System.out.println(c2.getColor());
Assuming setColor changes the car’s color instance variable, what is printed?
Correct Answer: B c1 and c2 refer to the same Car object. This is called aliasing.When c1.setColor("Blue") changes the object’s state, that same changed state is visible when the object is accessed through c2.
4. Which exception occurs when a program attempts to call an instance method using a reference variable whose value is null?
Correct Answer: C A NullPointerException occurs at runtime when code attempts to use a reference whose value is null in a context that requires an object.
5. What is the default value of an instance variable whose type is an object reference when no explicit value is assigned?
Correct Answer: C An instance variable whose type is a reference type has a default value of null when no other value is assigned.This is different from local variables, which must be explicitly initialized before they are used.
6. Consider the following code segment:
String str = null;
System.out.println(str.length());
What happens when this code is executed?
Correct Answer: C str contains null, so it does not refer to a String object. Calling length() requires a String object, resulting in a NullPointerException at runtime.
7. Which of the following correctly creates a new Person object and assigns its reference to a variable named p?
Correct Answer: B The new keyword creates an object and invokes the appropriate constructor.The general form is:

ClassName variableName = new ClassName(arguments);
8. Consider the following code segment:
Rectangle r1 = new Rectangle(10, 5);
Rectangle r2 = new Rectangle(10, 5);
Rectangle r3 = r1;
System.out.println((r1 == r2) + ” ” + (r1 == r3));
What is printed?
Correct Answer: C The two new expressions create two separate Rectangle objects.Therefore, r1 == r2 is false.Then:

Rectangle r3 = r1;

copies the reference value from r1 into r3. Both variables therefore refer to the same object, making r1 == r3 true.
9. What happens to an object when there are no longer any references that allow the program to access it?
Correct Answer: C When an object is no longer reachable through any active reference, it becomes eligible for garbage collection.Java’s garbage collector can later reclaim the memory associated with such an object. The exact time at which garbage collection occurs is not specified by the Java language.
10. Consider the following method header: public void modifyPoint(Point p). If this method changes the coordinates of p internally, what happens to the original Point object passed to the method?
Correct Answer: A Java is strictly pass-by-value.When an object reference is passed to a method, the parameter receives a copy of the reference value. The parameter and the original variable therefore refer to the same object.If the method changes the object’s instance state, that change is visible through the original reference as well.

Topics 1.12–1.14 Practice Complete!

0 / 10

Understanding Object References and Aliasing

Aliasing is an important concept in AP CSA. When two reference variables refer to the same object, modifying that object’s state through one reference can affect what is observed through the other reference.

When tracing Java code, pay close attention to whether a statement creates a new object with new or simply copies an existing reference value.

Continue Your AP CSA Practice

You can continue reviewing the remaining Unit 1 object concepts with Topic 1.15: String Methods .

For the complete current AP CSA framework, visit the AP CSA Unit 1: Using Objects and Methods practice hub.

← Back to Unit 1: Using Objects & Methods AP CSA MCQ Practice Hub
Next: String Methods →

Primary Sidebar

Mr Chinmay

Chinmay Patel
Book a Demo Class

Phone & Whatsapp +919853166385
javatution@gmail.com

Recent Posts

  • Learn Java in One Day: 10-Hour 1-on-1 Crash Course | JavaTutorOnline
  • Constructor in Java: Examples, Types & Constructor Overloading
  • Important Interview Questions on Java Multithreading
  • React Spring Boot Web Services React Integration
  • Spring Boot RESTful Web Services Example
  • Top Spring MVC Interview Questions and Answers for Developers
  • Top Spring Core Interview Questions and Answers for Developers
  • Host Java Web Apps for Free on Mobile with Tomcat and Termux
  • How to Deploy Java Web Application on Aws EC2 with Elastic IP
  • Simple Jsp Servlet Jdbc User Registration using Tomcat Mysql and Eclipse

Additional Resources

  • AP Computer Science A Summer Prep
Copyright © 2026 JavaTutorOnline