Are you taking CLEP classes? Try clep.ai
| preferred AP College board partner for AP classes
medium Solved by 6 students

Object Reference Assignment

< Prev
Next >

Consider the following Student class definition and the code segment that uses it. What is printed as a result of executing the code segment?

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 */
}
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());
A

4.0

B

3.9

C

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

D

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

Hint
Did You Know?
Explain Why
Explain All Answers
Check Answer
Show Correct Answer
Report Question
Mark for review

Question Leaderboard

Rank
User
Correct Count
Attempt Count
Total Time
Score
#1kaisuki12 0m 00s 90
#2winstonhou110711 0m 43s 57
#3zgj0731041711 0m 44s 56
#4ravi.palepu01 1m 01s -71
#5y.seong202712 2m 52s -82
#6bommasam00036 11m 56s -446
Items per page:
10
1 – 6 of 6
No comments yet. Be the first to comment!

AI Tutor

How can I help?

APFIVE © 2020.
Email: apfive@apfive.org|Privacy Policy|FAQ