What is inheritance? Explain it with an example

What is inheritance?

Through inheritance, classes can inherit commonly used state and behavior from their parent class. One class can have a single parent class and a class can have unlimited number of subclasses.

Syntax:
class B extends class A
{
   // new fields and methods
}

class C extends class A
{
   // new fields and methods
}

class D extends class A
{
   // new fields and methods
}
What is an overloaded method? Provide an example to explain it
What is an overloaded method? - Overloaded methods are the methods which have the same name but different signatures...
Define overriding. Explain it with an example
Define overriding - Overriding is done in a child class for a method that is written in the parent class...
Difference between overloading and overriding
Difference between overloading and overriding - Overloading and overriding are different aspects of polymorphism...
Post your comment