PASS - TAKER : Anonymos

Java SE 8 - OCA Declarations and Access Control

Correct : 4

30% Complete (success)

30 %

False : 9

69% Complete (success)

69 %



Anonymos 2018-11-06T20:40:06

Correct

1. Which are true? (Choose all that apply.)

A is incorrect because classes implement interfaces, they don’t extend them. B is incorrect because interfaces only “inherit from” other interfaces. D is incorrect based on the preceding rules.

Correct

2. Given: {code}
Which are true? (Choose all that apply.)

B and F are correct. Since Rocket.blastOff() is private, it can’t be overridden, and it is invisible to class Shuttle.

Not Correct

3. Given that the for loop’s syntax is correct, and given: {code}
And the command line:
java _ - A .
What is the result?

This question is using valid (but inappropriate and weird) identifiers, static imports, main(), and pre-incrementing logic. (Note: You might get a compiler warning when compiling this code.)

Not Correct

4. Given: {code}
What is the result?

enums can have constructors and variables.

Not Correct

5. Given two files: {code}
What is the result? (Choose all that apply.)

Variable a has default access, so it cannot be accessed from outside the package. Variable b has protected access in pkgA.

Not Correct

6. Given: {code}
What is the result? (Choose all that apply.)

all of these are legal declarations.

Not Correct

7. Given: {code}
What is the result? (Choose all that apply.)

Variable names cannot begin with a #, and an array declaration can’t include a size without an instantiation. The rest of the code is valid.

Not Correct

8. Given: {code}
What is the result? (Choose all that apply.)

Every enum comes with a static values() method that returns an array of the enum’s values in the order in which they are declared in the enum.

Not Correct

9. Given: {code}
What is the result?

E. Compilation fails due to an error on line 11 The countGold() method cannot be invoked from a static context.

Not Correct

10. Given: {code}
Which are true? (Choose all that apply.)

By default, an interface’s methods are public so the Tablet.doStuff method must be public, too. The rest of the code is valid.

Correct

11. Given that the Integer class is in the java.lang package and given: {code}
Which, inserted independently at line 1, compiles? (Choose all that apply.)

C and E are correct syntax for static imports. Line 4 isn’t making use of static imports, so the code will also compile with none of the imports.

Correct

12. Given: {code}
Which lines of code—inserted independently at insert code here— will compile? (Choose all that apply.)

As of Java 8, interfaces can have default and static methods. A, D, and E are incorrect. A has no return type; D cannot have a method body; and E needs a method body.

Not Correct

13. Which are true? (Choose all that apply.)

A is incorrect because Java is a statically typed language. B is incorrect because it does not provide pointers. E is incorrect because JavaScript is an implementation of the ECMA standard, not Java. F is incorrect because the use of bytecode and the JVM provide Java’s primary security mechanisms.