IT IS EXAM

Java using Super and This Keyword.

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.

PREV NEXT

Advertise Area

Your Advertise