Computer Science, asked by souravo7530, 1 year ago

Making a run-time decision about which instance method to call is known as:

Answers

Answered by sahilloeip5u6ag
1
ob.methB(); // Compile Time Error
}
}
This will produce a Compile Time Error that method methB() not found in class A, although Object Reference "ob" contains an object of class B which consists of method methB(). Reason for this is that Java Compiler checks for the method in Class A (the reference type) not in Class B (the actual object type). So, I want to know whats the reason behind this. Why does Java Compiler looks for the method in Class A why not in Class B(the actual object type)?
Similar questions