Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Question 2 1 pts Note: Questions 2-4 refer to the following class headers. public class G {1* class code */ } public class ] extends
Question 2 1 pts Note: Questions 2-4 refer to the following class headers. public class G {1* class code */ } public class ] extends G { /* class code */ } public class P extends G { /* class code */ } public class Q extends ] { /* class code */ } public class I extends 3 {1* class code */ } True or false: a T is-a G? True O False Question 3 1 pts A Q is a p? O True O False Question 4 1 pts A Jis-a T? O True O False Question 5 1 pts Which of the following should be true of a superclass? O A superclass can contain methods that will be used by all subclasses O Superclass data should be made public so the subclasses can access it. O A superclass should contain methods that will be used only by the superclass. Question 6 1 pts Consider the following class definitions. public class MyClass + private int myNumber: public MyClass() 1 myNumber = 0; + public MyClass(int x) { myNumber = x; } } class MyOtherClass extends MyClass { public MyotherClass() { super(); } } Which of the following will not compile? MyOtherClass d = new MyotherClass(); O MyClass b = new MyClass(); O MyOtherClass e = new MyOtherClass(5); O MyClass a = new MyClass(5); Question 7 1 pts Consider the following class declaration. public class Adder private int value; public Adder(int n) { value = n; public void increase(int more) { value = value + more; 1 public int getValue() { return value; } } The following code appears in another class: Adder a = new Adder (200); Adder b = new Adder (200); Adder C = a; a. increase (200); System.out.println(a.getValue() + "." + b.getValue() + " + c.getValue); What is printed? O 400 400 200 0 400 200 400 0 200 200 400 0 400 400 400 0 200 400 200
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started