What will happen as a result of the following code?
class A {}
class B extends A {}
public class Test {
static public void main(String args[]) {
B b = new B();
A a = b;
if (a.hashCode() == b.hashCode())
System.out.print("Passed");
}
}
References a and b indicate the same object, so the console displays the message "Passed". A class specimen can be assigned to the specimen of a class B due to polymorphism.
Login in to like
Login in to comment