Given: Which two code fragments are valid?
A.
Option E
B.
Option D
C.
Option C
D.
Option A
E.
Option B
Given: Which two code fragments are valid?
Given: Which two code fragments are valid?
A.
Option E
B.
Option D
C.
Option C
D.
Option A
E.
Option B
B and D would be the valid class declarations
Code question:
//This code is not given in the question
public class App {
public static void main(String[] args) {
System.out.println(“Answer: B, D”);
}
}
abstract class X {
public abstract void methodX();
}
public interface Y {
public void methodY();
}
// A:
class Z1 extends X implements Y {
public void methodZ() { }
}
/* Message in IDE (NetBeans):
Z1 is not abstract and does not override abstract methodY() in Y
*/
//B:
abstract class Z2 extends X implements Y {
public void methodZ() { }
}
//C:
class Z3 extends X implements Y {
public void methodX() { }
}
/* Message in IDE (NetBeans):
Z3 is not abstract and does not override abstract methodY() in Y
*/
//D:
abstract class Z4 extends X implements Y {
public void methodY() { }
}
//E:
public class Z5 extends X implements Y{
public void methodY() {}
}
/* Message in IDE (NetBeans):
Z5 is not abstract and does not override abstract methodY() in Y
*/