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();
		a.doAThings();
	}
}
and

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?
Explanation
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.

Следи за CodeGalaxy

Мобильное приложение Beta

Get it on Google Play
Обратная Связь
Продолжайте изучать
тесты по Java
Cosmo
Зарегистрируйся сейчас
или Подпишись на будущие тесты