6.10. Sample exam questions
What is the output of the following code?
class Animal { void jump() { System.out.println("Animal"); } } class Cat extends Animal { void jump(int a) { System.out.println("Cat"); } } class Rabbit extends Animal { void jump() { System.out.println("Rabbit"); } } class Circus { public static void main(String args[]) { Animal cat = new Cat(); Rabbit rabbit = new Rabbit(); cat.jump(); rabbit.jump(); } }
Animal Rabbit Cat Rabbit Animal Animal- None of the above
Given the following code, select the correct statements:
class Flower { public void fragrance() {System.out.println("Flower"); } } class Rose { public void fragrance() {System.out.println("Rose"); } } class Lily { public void fragrance() ...
Get OCA Java SE 8 Programmer I Certification Guide now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.