Programming in Java
Object Oriented in Java
Advanced topics in Java
Modal Box
Tutorials
C is a very powerful and widely used language. It is used in many scientific programming situations. It forms (or is the basis for) the core of the modern languages Java and C++. It allows you access to the bare bones of your computer.C++ is used for operating systems, games, embedded software, autonomous cars and medical technology, as well as many other applications. Don't forget to visit this section...
Method Overriding in java
In java if subclass has the same name function as its super class, then it is known as function overriding.
So in method overloading, there are multiple functions with the same name within a single class, while overriding is the same function name in super class and its sub class.
Method over riding is the example of run time polymorphism.
class A { public void display() { System.out.println("Super class display function"); } }
class B extends A { public void display() { System.out.println("Sub class display function"); } }
class CheckMain { public static void main(String args[]) { A obj= new A (); obj.display();
B obj1= new B(); obj1.display();
}
}
As b class object can also call the super class display function,
but here, the sub class function overrides the super class function.
To avoid the effect of overriding, super keyword is used which is discussed in the next chapter.
Video/ C Introduction
Watch video in full size