Consider the classes shown below: public class Parent
{
Private int value = 100;
Public int getValue()
{
Return value;
}
}
Public class Child extends Parent
{
Private int value;
Public Child(int number)
{
Value = number;
}
}
What is the output of the following lines of code?
Child kid = new Child(-14) ;
Parent kid2 = new Child(21) ;
System.out.println(kid.getValue() + " "
+ kid2.getValue() ) ;
A) 100 100
B) -14 21
C) 21 21
D) -14 100
Correct Answer:
Verified
Q6: Which of the following statements about inheritance
Q7: Consider the following inheritance hierarchy diagram:
Q8: Consider the classes shown below: public class
Q9: Suppose the class Value is partially defined
Q12: Insert the missing code in the following
Q13: Consider the hierarchy of classes shown below.
Q14: All rodents are mammals and all canines
Q14: Consider the classes shown below: public class
Q15: Consider the hierarchy of classes shown below.
Q16: Consider the classes shown below: public class
Unlock this Answer For Free Now!
View this answer and more for free by performing one of the following actions
Scan the QR code to install the App and get 2 free unlocks
Unlock quizzes for free by uploading documents