Java program to demonstrate the Usage of Super and This Keyword.

Below code is used to demonstrate the usage of Super and This keyword:

import java.util.Scanner;

class Vehicle
{
      int speed=50;
}
class Bike extends Vehicle
{
      int speed=100;
      void display()
      {
            System.out.println(super.speed);
            System.out.println(this.speed);
      }
      public static void main(String[] args)
      {
            Bike b=new Bike();
            b.display();
                     
      }
}  
Thank You.

© Copyright - 2018 - 2022 | All rights reserved at Funda of Web IT