Answers for "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"

0

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();
  }
}
Posted by: Guest on May-11-2021

Code answers related to "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"

Code answers related to "TypeScript"

Browse Popular Code Answers by Language