Java 7 - OCA 1 Declarations and Access Control

Correct : 5

45% Complete (success)

45 %

False : 6

54% Complete (success)

54 %



jfc 2019-06-21T14:24:47

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.

Not Correct

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

Since Rocket.blastOff() is private, it can't be overridden, and it is invisible to class Shuttle.

Not Correct

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.

Not Correct

Given: {code}
What is the result?

enums can have constructors and variables. these lines all use correct syntax.

Not Correct

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

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

all of these are legal declarations.

Not Correct

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.

Correct

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.

Correct

Given: {code}
What is the result?

The countGold() method cannot be invoked from a static context.

Correct

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

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.