Class Constructor and Getter Method
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
Question Leaderboard
| Rank | |||||
|---|---|---|---|---|---|
| #1 | kaisuki | 2 | 2 | 0m 00s | 200 |
| #2 | bommasam000 | 2 | 3 | 0m 41s | 149 |
| #3 | songqiuhui2012 | 0 | 1 | 0m 02s | -12 |
| #4 | y.seong2027 | 1 | 1 | 5m 09s | -209 |
Items per page:
10
1 – 4 of 4
APFIVE