super in java
class Parent{
int amount=5000;
Parent(){}
Parent(int receive){
amount+=receive;
}
void home(){
System.out.println("Location:Delhi");
}
void balance(){
System.out.println("balance="+amount);
}
}
class Child extends Parent{
/*int amount=1000;
Child(int transfer){
amount-=transfer;
super(transfer);
}
*/
Child(){}
Child(int transfer){
super(transfer);
}
void home(){
System.out.println("Location:Chennai");
}
void homeParent(){
super.home();
}
void homeBalance(){
System.out.println(super.amount);
}
}
class Test{
public static void main(String ar[]){
//=new Child().homeBalance();
Child objChild new Child(500);
objChild.homeBalance();
}
}
0 comments:
Post a Comment