| 6.15 | Which statement is true about the following code? // Filename: MyClass.java abstract class MyClass implements Interface1, Interface2 { public void f() { } public void g() { } } interface Interface1 { int VAL_A = 1; int VAL_B = 2; void f(); void g(); } interface Interface2 { int VAL_B = 3; int VAL_C = 4; void g(); void h(); } Select the one correct answer. -
Interface1 and Interface2 do not match, therefore, MyClass cannot implement them both. -
MyClass only implements Interface1 . Implementation for void h() from Interface2 is missing. -
The declarations of void g() in the two interfaces conflict, therefore, the code will not compile. -
The declarations of int VAL_B in the two interfaces conflict, therefore, the code will not compile. -
Nothing is wrong with the code, it will compile without errors. |
| 6.16 | Given the following code, which declaration can be inserted at the indicated line without causing a compilation error? interface MyConstants { int r = 42; int s = 69; // INSERT CODE HERE } Select the two correct answers. -
final double circumference = 2*Math.PI*r; -
int total = total + r + s; -
int AREA = r*s; -
public static MAIN = 15; -
protected int CODE = 31337; |