8.1. Mock exam
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 {}
- Jumpable var1 = new Jumpable();
- Animal var2 = new Animal();
- Lion var3 = new Animal();
- Jumpable var4 = new Animal();
- Jumpable var5 = new Lion();
- Jumpable var6 = (Jumpable)(new Animal());
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.