/* An example from Java: A beginners's guide by Herbert Schildt that illustrates the the strongly typed nature of Java. A reference for one type of object cannot normally refer to another type of object except whne a reference of a superclass is referred to an object that's a subclass. v1 - won't compile. v2 - uses inheritance and will compile */ public class Driverv2 { public static void main (String [] args) { Xv2 x = new Xv2(10); Xv2 x2; Yv2 y = new Yv2(5,6); x2 = x; // OK, both of the same type System.out.println("x2.a: " + x2.getA()); x2 = y; // Still okay because y is derived from x x2.setA(19); // x2.setB(27); // Not okay because X doesn't have this method. } }