Java, .NET, PHP, PYTHON, ANGULAR, .NET, ML, Data Scince, Testing, CI Tutorials in Easy Languages.

"Best Software Training, Internship, Project Development center of Indore India, Helpline 780506-3968"

Function Overriding:-



We will create same name method from base class to derived class only functionality will be different.

Overriding is used to extend the particular functionality of class ,without interfere to actual class.


For example ExamSystem ,Old system is based on Number and now based on Grade

 class Exam
{
      public void examInfo()
     {
        System.out.println("Main Exam");
     }
       public void examPattern()
      {
         System.out.println("Number System");
     }

}

class Examnew extends Exam
{
  public void examPattern()
      {
         System.out.println("Grade System");
     }

public static void main(String[] args) {
        Examnew obj = new Examnew();
        obj.examInfo();
        obj.examPattern();
        Exam obj1 = new Examnew();
        obj1.examPattern();
         Exam obj2 = new Exam();
        obj2.examPattern();
    }
}

Post a Comment

If you have any doubt in programming or join online classes then you can contact us by comment .

Previous Post Next Post