Java Super Keyword.

 Super Keyword in java

Super Keyword is used to prefer parent class during inheritance. 
Super is used in two scenario::::::::
1. Use with variables.

class Animal {
public int weigth = 130;
}
class Height extends Animal {
public int weight = 200;
public void display(){
System.out.println("Weight = "+super.weight);
}
}

class Driver {
public static void main(String args[])
{
  Height obj = new Height();
   obj.display();
}
}


Comments

Popular posts from this blog

About RAM

Class and object in c++