| preferred AP College board partner for AP classes
AP Computer Science A/Unit 5: Writing Classes
Start Practice TestPractice Test
Share
About Exam
medium Solved by 6 students
Object Reference Assignment
< Prev
Next >

Refer to the following class:

public class Student 
{
    private String name;
    private double gpa;

    public Student(String newName, double newGPA) 
    {
        name = newName;
        gpa = newGpa;
    }

    public String getName() 
    {
        return name;
    }
    /* Additional methods not shown */
}
Consider the following code segment.
Student s1 = new Student("Brody Kai", 3.9);
Student s2 = new Student("Charlie Cole", 3.2);
s2 = s1;
s2.setGpa(4.0);
System.out.println(s1.getGpa());

What is printed as a result of executing the code segment?

A

4.0

B

Nothing will be printed. There will be a run-time error.

C

Nothing will be printed. There will be a compile-time error.

D

3.9

Hint
Did You Know?
Explain Why
Explain All Answers
Check Answer
Show Correct Answer

Question Leaderboard

Rank
User
Correct Count
Attempt Count
Time
Score
#1kaisuki12 0m 00s 90
#2winstonhou110711 0m 43s 57
#3ravi.palepu01 1m 01s -71
#4y.seong202712 2m 52s -82
#5bommasam00036 11m 56s -446
Items per page:
10
1 – 5 of 5

AI Tutor

How can I help?

APFIVE © 2020.
Email: [email protected]|Privacy Policy