Tuesday, August 18, 2015

Vegetable Class

abstract class Vegetable{
String color;
}
class Potato extends Vegetable{
Potato(String color){
this.color = color;
}
/*public String toString(){
return "Name: Potato, Color:"+this.color;
}
*/

}
class Brinjal extends Vegetable{

}
class Tomato extends Vegetable{

}
class TestVegetable{
public static void main(String[] args){
Potato p1 = new Potato("Blue");
Potato p2 = new Potato("Red");

System.out.println(p1);
System.out.println(p2);


}
}


No comments:

Post a Comment