Leave a Reply 3

Your email address will not be published. Required fields are marked *


renko

renko

Answer: C
package q043;

public class Product {
int id;
String name;

public Product(int id, String name) {
this.id = id;
this.name = name;
}
}

package q043;

public class ProductApp {

public static void main(String[] args) {
Product p1 = new Product(101, “Pen”);
Product p2 = new Product(101, “Pen”);
Product p3 = p1;
boolean ans1 = p1 == p2; //false
boolean ans2 = p1.name.equals(p2.name); //true
System.out.print(ans1 +” : “+ ans2);
}

}
Output:
false : true

jeronimo

jeronimo

C FALSE TRUE