What is the result? 10/29/2018 – by Mod_GuideK 3 Given: What is the result? A. true:true B. true:false C. false:true D. false:false SHOW ANSWERSCorrect Answer: C Explanation/Reference: Explanation/Reference: Download Printable PDF. VALID exam to help you PASS.
public class Q77 { int id; String name; Q77(int id,String name){ this.id=id; this.name=name; } public static void main(String[] args) { Q77 p1 = new Q77(101,”Pen”); Q77 p2 = new Q77(101,”Pen”); Q77 p3 = p1; boolean ans1 = p1 == p2; boolean ans2 = p1.name.equals(p2.name); System.out.println(ans1+” : “+ ans2); } } result : false : true 2 Reply
false : True
C
public class Q77 {
int id;
String name;
Q77(int id,String name){
this.id=id;
this.name=name;
}
public static void main(String[] args) {
Q77 p1 = new Q77(101,”Pen”);
Q77 p2 = new Q77(101,”Pen”);
Q77 p3 = p1;
boolean ans1 = p1 == p2;
boolean ans2 = p1.name.equals(p2.name);
System.out.println(ans1+” : “+ ans2);
}
}
result : false : true
Answer is C