System.out.println("Calling an A's version of xyz"); new AAA().xyz(); System.out.println("Calling a B's version of xyz"); new BBB().xyz();