Declarations and Access Control Logic
© examsiri.com
Question : 6 of 29
Marks:
+1,
-0
Given:
What is the output?
1. class Cup { }
2. class PoisonCup extends Cup { }
...
3. public void takeCup(Cup c) {
4.   if (c instanceof PoisonCup) {
5.   System.out.println("Inconceivable!");
6.   } else if (c instanceof Cup) {
7.     System.out.println("Dizzying intellect!");
8.    } else {
9.      System.exit(0);
10.     }
11. }
And the execution of the statements:
Cup cup = new PoisonCup();
takeCup(cup);What is the output?
Go to Question: