Question: Need assistance for a hw assignment Question 1 (1 point) If A is the base class, B is the derived class, and the constructors for
Need assistance for a hw assignment
Question 1 (1 point)
If A is the base class, B is the derived class, and the constructors for both classes are no-arg, which statement generates a compiler error?
Question 1 options:
| A | B x = new A( ); |
| B | B x = new B( ); |
| C | A x = new A( ); |
| D | A x = new B( ); |
Question 2 (1 point)
Which choice defines the interface I that has required method f?
Question 2 options:
| A | public interface I implements f; |
| B | public interface I { public void f( ); } |
| C | public interface I requires f; |
| D | public interface I {f}; |
Question 3 (1 point)
Which choice is the first line of a class A that implements the interface I?
Question 3 options:
| A | public class A interface I { |
| B | public class A implements I { |
| C | public interface I for class A { |
| D | public class A extends I { |
Question 4 (1 point)
What is the required method of the Comparable interface?
Question 4 options:
| A | ltGt |
| B | compareTo |
| C | comparator |
| D | compare |
Question 5 (1 point)
For this problem, use the Speaker interface, from the Interfaces Example. Recall that the Speaker interface requires any class implementing it to supply a speak method. Suppose that a HashMap collection is defined as:
HashMap
Question 5 options:
| A | for(Speaker s : col) { col.speak( )); } |
| B | for(Speaker s : col) { s.speak( ); } |
| C | for(Speaker s : col.values( )) { s.speak( ); } |
| D | for(Speaker s : col.values( )) { col.speak( ); } |
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
