logo

Crowdly

What is the output of the following program? class   Parent{       void  P...

✅ The verified answer to this question is available below. Our community-reviewed solutions help you understand the material better.

What is the output of the following program?

  1. class  Parent{  
  2.    void PrintData() {  
  3.       System.out.println("method of parent class");  
  4.    }  
  5. }  
  6.   
  7. class Child extends Parent {  
  8.    void PrintData() {  
  9.       System.out.println("method of child class");  
  10.    }  
  11. }  
  12. class UpcastingExample{  
  13.    public static void main(String args[]) {  
  14.         
  15.       Parent obj1 = (Parent) new Child();  
  16.       Parent obj2 = (Parent) new Child();   
  17.       obj1.PrintData();  
  18.       obj2.PrintData();  
  19.    }  
  20. }  
0%
0%
0%
More questions like this

Want instant access to all verified answers on moodle.medtech.tn?

Get Unlimited Answers To Exam Questions - Install Crowdly Extension Now!