Java Reference
In-Depth Information
15.
16. public void catchAnObject(String s) {
17. System.out.println(“Caught string”);
18. }
19. }
A.
Caught object
B.
Caught string
C.
Compiler error on line 2
D.
Compiler error on line 12
E.
Compiler error on line 16
11.
What is the result of the following code?
1. public abstract class A {
2. private void doSomething() {
3. System.out.println(“A”);
4. }
5.
6. public static void main(String [] args) {
7. A a = new B();
8. a.doSomething();
9. }
10. }
11.
12. class B extends A {
13. protected void doSomething() {
14. System.out.println(“B”);
15. }
16. }
A.
A
B.
B
C.
Compiler error on line 7
D.
Compiler error on line 8
E.
Compiler error on line 13
12.
What is the result of the following code?
1. public class X {
2. protected final void doSomething() {
3. System.out.println(“X”);
4. }
Search WWH ::
Custom Search