PASS - TAKER : Anonymos

Java SE 8 - OCA Assignments

Correct : 13

100% Complete (success)

100 %

False : 0

0% Complete (success)

0 %



Anonymos 2018-10-24T13:48:20

Correct

1. Given: {code}
When // do Stuff is reached, how many objects are eligible for garbage collection?

Only one CardBoard object (c1) is eligible, but it has an associated Short wrapper object that is also eligible.

Correct

2. Given: {code}
Which lines WILL NOT compile? (Choose all that apply.)

compilation of line E fails. When a mathematical operation is performed on any primitives smaller than ints, the result is automatically cast to an integer.

Correct

3. Given: {code}
Which lines WILL NOT compile? (Choose all that apply.)

Line C will NOT compile. As of Java 7, underscores can be included in numeric literals, but not at the beginning or the end. A, B, D, E, and F are incorrect. A and B are legal numeric literals. D and E are examples of valid binary literals, which were new to Java 7, and F is a valid hexadecimal literal that uses an underscore.

Correct

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

The m2 object’s m1 instance variable is never initialized, so when m5 tries to use it, a NullPointerException is thrown.

Correct

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

The references f1, z, and f3 all refer to the same instance of Fizz. The final modifier assures that a reference variable cannot be referred to a different object, but final doesn’t keep the object’s state from changing.

Correct

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

In the go() method, m refers to the single Mirror instance, but the int i is a new int variable, a detached copy of i2.

Correct

7. Given: {code}
When execution reaches the commented line, which are true? (Choose all that apply.)

The constructor sets the value of id for w1 and w2. When the commented line is reached, none of the three Wind objects can be accessed, so they are eligible to be garbage collected.

Correct

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

The parameter declared on line 9 is valid (although ugly), but the variable name ouch cannot be declared again on line 11 in the same scope as the declaration on line 9.

Correct

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

Inside the go() method, h1 is out of scope.

Correct

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

Three Network objects are created. The n2 object has a reference to the n1 object, and the n3 object has a reference to the n2 object. The S.O.P. can be read as, “Use the n3 object’s Network reference (the first p), to find that object’s reference (n2), and use that object’s reference (the second p) to find that object’s (n1’s) id, and print that id.”

Correct

11. Given: {code}
When line 16 is reached, how many objects will be eligible for garbage collection?

It should be clear that there is still a reference to the object referred to by a2, and that there is still a reference to the object referred to by a2.b2. What might be less clear is that you can still access the other Beta object through the static variable a2.b1—because it’s static.

Correct

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

In the Telescope class, there are three different variables named magnify. The go() method’s version and the zoomMore() method’s version are not used in the zoomIn() method. The zoomIn() method multiplies the class variable * 5. The result (10) is sent to zoomMore(), but what happens in zoomMore() stays in zoomMore(). The S.O.P. prints the value of zoomIn()’s magnify.

Correct

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

In go1() the local variable x is not initialized.