Java Reference
In-Depth Information
12.
13. class Firefox extends Browser {
14. public void go() {
15. System.out.println(“Inside Firefox”);
16. }
17. }
18.
19. class IE extends Browser {
20. public void go() {
21. System.out.println(“Inside IE”);
22. }
23. }
A. Inside Browser
B. Inside Firefox
C. Inside IE
D. Compiler error on line 4
E. Line 4 generates an exception at runtime.
16. Using the class definitions from Question 15, what is the result of the following statements?
4. Browser ref = new IE();
5. if(ref instanceof Firefox) {
6. System.out.println(“Firefox”);
7. } else if(ref instanceof Browser) {
8. System.out.println(“Browser”);
9. } else if(ref instanceof IE) {
10. System.out.println(“IE”);
11. } else {
12. System.out.println(“None of the above”);
13. }
A. Firefox
B. Browser
C. IE
D. None of the above
E. The code does not compile.
17. Using the class definitions from Question 15 along with the following OperatingSystem
class:
1. public class OperatingSystem {
2. private Browser browser;
Search WWH ::




Custom Search