Java Reference
In-Depth Information
3.
4. public static void main(String [] args) {
5. Fruit apple = new Fruit();
6. apple.color = “Red”;
7. System.out.println(apple.color);
8. }
9. }
A. Red
B. Green
C. Compiler error on line 5
D. Compiler error on lines 6 and 7
E. Line 6 throws an exception at runtime.
9. Given the following MyWindowCloser class definition:
1. public abstract class MyWindowCloser {
2. protected abstract void closeWindow(String id);
3. }
which of the following methods could appear in a child class of MyWindowCloser ?
(Select three answers.)
A. protected void closeWindow(String id)
B. private void closeWindow()
C. protected int closeWindow(String id)
D. void closeWindow(String id)
E. public void closeWindow(String x)
10. What is the result of the following code?
1. public abstract class Catchable {
2. protected abstract void catchAnObject(Object x);
3.
4. public static void main(String [] args) {
5. java.util.Date now = new java.util.Date();
6. Catchable target = new MyStringCatcher();
7. target.catchAnObject(now);
8. }
9. }
10.
11. class MyStringCatcher extends Catchable {
12. public void catchAnObject(Object x) {
13. System.out.println(“Caught object”);
14. }
Search WWH ::




Custom Search