Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

6. To prohibit any instance (object) of type Foo from being created: a. Declare

ID: 3661345 • Letter: 6

Question

6. To prohibit any instance (object) of type Foo from being created:

a. Declare class Foo as final.

b. Declare Foo as an interface.

c. Declare class Foo to be static.

d. Declare all class Foo constructors to be private.

7. Every object within a running Java application:

a. Can access any of its class's static variables, even if they are declared private.

b. Must have its class explicitly declare the method public String toString().

c. Is stored within the same memory that is used by local method variables.

d. Has a lifetime that ends when exiting the method that created it.

9.A Javaimportstatement:

a. Is always required within a class in order to use another class belonging to another package.

b. Always names a specific class/interface/enum.

c. Can always be avoided by using other Java language syntax.

11.Supposed we have the following Javado-whileloop, controlled by thebooleanexpression<expr>, andhaving<stmt>as a single logical statement in the loop's body:

do {<stmt>; } while (<expr>);

Then:

a. The semicolon immediately following<stmt>may always be omitted.

b. Acontinuestatement within<stmt>may not terminate the loop.

c. The loop body<stmt>may not be executed at all.

d. The braces indo{...}while (...)are optional for certain kinds of<stmt>.

14.A Java interfaceIFoo:

a. Mustnotdeclare any constructor, such aspublic IFoo().

b. May declareprivatemethods.

c. Cannot be the type of a declared variable, as in:IFoo ifoo;

d. Can only be implemented bypublicclasses.

15.The Java keywordthis:

a. Is illegal as an actual parameter (argument) in a method call.

b. Can only be used as an object reference to the object associated withthis.

c. May not be referenced within astaticmethod.

d. Allows any methods to be invoked against it via the dot (.) operator.

Explanation / Answer

6 A 7 C 9 A 11 B 14 C 15 D