Java Overriding
Method Overriding
Method overriding achieved by the same method and the same parameter in base class as well as in derived class. Method overriding used only in different classes.
Syntax:
class A {
public:
void show(){
//body of the function.
}
}
class B {
public:
void show(){
//body of the function.
}
}

Example:
class A // base class
{
void showdata()
{
System.out.println("Base class");
}
}
class B extends A // derived class
{
void showdata()
{
System.out.println("Derived class");
}
}
public class Methodoverriding{
public static void main(String args[])
{
B b=new B();
b.showdata();
}
}
Quickly Find What You Are Looking For
OnlineTpoint is a website that is meant to offer basic knowledge, practice and learning materials. Though all the examples have been tested and verified, we cannot ensure the correctness or completeness of all the information on our website. All contents published on this website are subject to copyright and are owned by OnlineTpoint. By using this website, you agree that you have read and understood our Terms of Use, Cookie Policy and Privacy Policy.
point.com