Thursday, 12 February 2015

super

  1. class Vehicle{  
  2.   int speed=50;  
  3. }  
  4.   
  5. class Bike4 extends Vehicle{  
  6.   int speed=100;  
  7.       
  8.   void display(){  
  9.    System.out.println(super.speed);//will print speed of Vehicle now   System.out.println(speed);  //try with super keyword
  10.  
  11.   }  
  12.   public static void main(String args[]){  
  13.    Bike4 b=new Bike4();  
  14.    b.display();  
  15.      
  16. }  

No comments:

Post a Comment