Java, .NET, PHP, PYTHON, ANGULAR, ML, Data Science, 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

POST Answer of Questions and ASK to Doubt

Previous Post Next Post