8.1. Mock exam

ME-Q1)

Given the following definition of the classes Animal, Lion, and Jumpable, select the correct combinations of assignments of a variable that don’t result in compilation errors or runtime exceptions (select 2 options).

interface Jumpable {}
class Animal {}
class Lion extends Animal implements Jumpable {}
  1. Jumpable var1 = new Jumpable();
  2. Animal var2 = new Animal();
  3. Lion var3 = new Animal();
  4. Jumpable var4 = new Animal();
  5. Jumpable var5 = new Lion();
  6. Jumpable var6 = (Jumpable)(new Animal());

ME-Q2)

Given the following code, which option, if used to replace /* INSERT CODE HERE */, will make the code print 1? (Select 1 option.)

try { String[][] names = {{"Andre", "Mike"}, null, {"Pedro"}}; System.out.println (names[2][1].substring(0, ...

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.