There are two classes:

package pak1;
import pak2.B;
public class A {
	void doAThings() {
		System.out.print("A ");
	public static void main(String[] args) {
		A a = new B();

package pak2;
import pak1.A;
public class B extends A {
	public void doAThings() {
		System.out.println("I'm B ;)");
What will happen when you try to compile both classes and run the main-method?
doAThings method is not inherited by class B, because B is in other package, and the access modifier in doAThings is absent (package-private). Therefore, polymorphic call of doAThings will not happen. Method doAThings will be called from class A.

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback