Wednesday, September 28, 2011

Quiz of the day | OCPJP (23)

Given:

3. class A {
4. public void a() { System.out.print("A "); }
5. }
6. class B extends A {
7. public void b() { System.out.print("B "); }
8. public void a() { System.out.print("a "); }
9. }
10. public class C {
11. public static void main(String[] args) { new C().c(); }
12. void c() {
13. new B().a();
14. ((A) new B()).a();
15. ((A) new B()).b();
16. }
17. }

What is the result? (Choose all that apply.)

A. a a B
B. a A B
C. a a followed by an exception
D. a A followed by an exception
E. Compilation fails with an error at line 14
F. Compilation fails with an error at line 15

DOWNLOAD the answer

0 comments: