Given:
Which three values will appear in the output?
Correct Answer:
Explanation
🗳️
Static method of base class is invoked >>
A myA = new B();
System.out.print(myA.doA() + myA.doA2() + myA.a);
class B String doA() { return "b1 "; }
class A protected static String doA2 () { return "a2 "; }
class B int a = 7;
Given:
What is the result?
Correct Answer:
A
🗳️
(this == obj) is the object implementation of equals() and therefore FALSE, if the reference points to various objects and then the super.equals() is invoked, the object method equals() what still result in FALSE better override of equals() is to compare the attributes like: public boolean equals (Object obj) { if (obj != null){
Product p = (Product)obj;
return this.id == p.id;
}
return false;
}
Given:
What is the result?
Correct Answer:
C
🗳️
Compiler says: Cannot reduce the visibility of the inherited method from Rideable. mssen PUBLIC sein public String ride() { return "cantering "; } public String ride() { return "tolting "; } if this is given then the result would be:
A : tolting cantering tolting
Which four are syntactically correct?
Correct Answer:
BEGH
🗳️