Create a class with a method that prints "This is parent class" and its subclass with another method that prints "This is child class". Now, create an object for each of the class and call
class Pclass{
public void pmethod(){
System.out.println("This is parent class");
}
}
class Cclass extends Pclass{
public void cmethod(){
System.out.println("This is child class");
}
}
class Ans{
public static void main(String[] args){
Pclass m = new Pclass();
Cclass n = new Cclass();
m.pmethod();
n.cmethod();
n.pmethod();
}
}