Java Reference
In-Depth Information
5.
6. public static void main(String [] args) {
7. X x = new Y();
8. x.doSomething();
9. }
10. }
11.
12. class Y extends X {
13. protected void doSomething() {
14. System.out.println(“Y”);
15. }
16. }
A. X
B. Y
C. Compiler error on line 2
D. Compiler error on line 8
E. Compiler error on line 13
13. Given the following class definitions:
1. public class Pet implements Runnable {
2. public void run() {}
3.
4. public static void main(String [] args) {
5. _____ x = new Cat();
6. }
7. }
8.
9. class Cat extends Pet {
10. }
11.
12. class Dog extends Pet {
13. }
which of the following answers can fi ll in the blank on line 5 and have the code com-
pile successfully? (Select three.)
A. Pet
B. Runnable
C. Cat
D. Dog
E. Thread
Search WWH ::




Custom Search