Question: Consider the following two classes. What is printed as a result of executing the following code segment? * Consider the following two classes: public class

Consider the following two classes. What is printed as a result of executing the following code segment?
*
Consider the following two classes:
public class Parent
public String myType()
return "Parent";
public class Child extends Parent
public String myType )
return "Child":
What is printed as a result of executing the following code segment?
Child obj - new Parent():
System.out-println(obj.myType)):
A. ParentChild
B. Parent
C. Child
D. error: incompatible types: Parent cannot be converted to Child
E. ChildParent

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!