| preferred AP College board partner for AP classes
AP Computer Science A/Unit 5: Writing Classes
Start Practice TestPractice Test
About Exam
easy Solved by 5 students
Class Constructor and Getter Method
< Prev
Next >

What is the output when the above program is executed?

public class Person {
    private String name;
    public Person(String name) {
        this.name = name;
    }
    public String getName() {
        return this.name;
    }
}

public class TestPerson {
   public static void main(String[] args) {
       Person p = new Person("Alice");
       System.out.println(p.getName());
   }
}
A

The object’s memory reference

B

Compilation Error

C

null

D

Alice

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

Question Leaderboard

Rank
User
Correct Count
Attempt Count
Time
Score
#1kaisuki22 0m 00s 200
#2bommasam00023 0m 41s 149
#3songqiuhui201201 0m 02s -12
#4y.seong202711 5m 09s -209
Items per page:
10
1 – 4 of 4
No comments yet. Be the first to comment!

AI Tutor

How can I help?

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