/*code snippet from Vehicle.java*/
public abstract class Vehicle{
public abstract
String getName();
public Class dataClass = Axle.class;
public void printClassName(){
System.out.println("Class Name: " + dataClass);
}
}
/*code snippet from Car.java*/
public class Car extends Vehicle{
public Class dataClass = LicensePlate.class;
public String getName(){
return "Mustang";
}
public static void main(String a[]){
Car car = new Car();
System.out.println(car.getName());
car.printClassName();
}
}
Provided the classes Axle and LicensePlate are present, why is it that the output is Axle.class and not LicensePlate.class which i thought would override the super class' Class attribute dataClass since it has public access.
thanks in advance
- Kalyan