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? Justify your choice. Child kid = new Child(-14); Parent adult = new Parent(); System.out.println(kid.getValue() + " " + adult.getValue() + " " + kid.getValue() + adult.getValue()); Output: -14 100 -14 100
Added by Krista B.
Step 1
We have a `Parent` class with a private `int` variable `value` set to 100 and a `getValue()` method that returns the value of this variable. Show more…
Show all steps
Your feedback will help us improve your experience
Patina Herring and 64 other AP CS educators are ready to help you.
Ask a new question
Labs
Want to see this concept in action?
Explore this concept interactively to see how it behaves as you change inputs.
Key Concepts
Recommended Videos
what will be the result of the expression 9/9.0 in JAVA
Rashmi P.
What will be the output of the following code? int i = 20; if (i > 10) { System.out.println("The value of i is " + i); i++; if (i % 2 != 0) break; }
Shelayah R.
Consider the following python code. What is the output? def f(x = 50, y = 50): return(x+y, x-y) x, y = f(y = 100, x = 50) print(x, y)
Urvashi A.
Recommended Textbooks
Computer Science and Information Technology
Introduction to Programming Using Python
Computer Science - An Overview
18,000,000+
Students on Numerade
Trusted by students at 8,000+ universities
Watch the video solution with this free unlock.
EMAIL
PASSWORD