java class inheritance example
Example 1: Inheritance in java
interface M
{
public void helloWorld();
}
interface N
{
public void helloWorld();
}
public class MultipleInheritanceExample implements M, N
{
public void helloWorld()
{
System.out.println("helloWorld() method");
}
public static void main(String[] args)
{
MultipleInheritanceExample obj = new MultipleInheritanceExample();
obj.helloWorld();
}
}
Example 2: inheritance in java
it is used to define relationship between two class,
which a child class occurs all the properties and
behaviours of a parent class.
Provides code reusability.
Ex: in my framework I have a TestBase
class which I store
all my reusable code and methods.
My test execution classes and
elements classes will extend the
TestBase in order to reuse the code.