class Person{
private String name;
public Person(String name) {
this.name = name;
}
public String toString() {
return name;
}
}
class Test {
public static void main(String[] args) throws IOException {
Person p = new Person("Joe");
checkPerson(p);
System.out.println(p);
p=null;
checkPerson(p);
System.out.println(p);
}
public static Person checkPerson(Person p) {
if (p == null) {
p = new Person("Mary");
} else {
p = null;
}
return p;
}
}
-> A
1th checkperson transforms joe to null , so system.out.print print null
2th checkperson recieve null and transforms this null to mary , so system.out.print print in the console "mary"
A is correct because Changes in references of Person p are in the Person class so that object has different scope So There will be no effect on the Tester class object.
This section is not available anymore. Please use the main Exam Page.1z0-819 Exam Questions
Log in to ExamTopics
Sign in:
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.
Upvoting a comment with a selected answer will also increase the vote count towards that answer by one.
So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.
JGR_77
Highly Voted 1 year, 9 months agod7bb0b2
Most Recent 12 months agoduydn
1 year, 1 month agogreat_chainick
1 year, 3 months agoJavi_sc
1 year, 4 months agoStavok
1 year, 5 months agoaruni_mishra
1 year, 6 months agoMukes877
1 year, 7 months agoAlanRM
1 year, 8 months agoAnkit1010
1 year, 11 months ago