package extends_base_java;
class Car {
private String name;
private double price;
public Car(String name, double price) {
super();
this.name = name;
this.price = price;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public double getPrice() {
return price;
}
public void setPrice(double price) {
this.price = price;
}
public void printlnName() {
System.err.println("name:"+getName());
}
}
package extends_base_java;
class BMW extends Car{
private String color;
public BMW(String name, double price, String color) {
super(name, price);
this.color = color;
}
public String getColor() {
return color;
}
public void setColor(String color) {
this.color = color;
}
}
package extends_base_java;
class Test {
public static void main(String[] args) {
// TODO Auto-generated method stub
Car car = new BMW("bmw320",300000.0,"white");
System.out.println(car.getClass());
}
}
//输出结果
class extends_base_java.BMW