Review Flashcards Preview

OCA Java 8 Exam > Review > Flashcards

Flashcards in Review Deck (50)
Loading flashcards...
1

What type does the Integer.parseInt method return?

Primitive integer (int)

2

What type does the Integer.valueOf method return?

Integer object

3

What does the ArrayList set( ) method do?

Sets an element at the index provided to the value provided

4

In Java, forward references to local variables are not allowed.

True

5

If a variable is declared in a switch statement case, it is available to all cases after it, but not before it.

True

6

Only a String, byte, short, int or char can be used as types of a switch variable.

False, the wrapper classes of these primitives can also be used.

7

You can start a literal value with an underscore.

False

8

A literal is a fixed value that doesn't need further calculations in order for it to be assigned to any variable.

True

9

The char data type can be assigned a positive or a negative integer.

False, char is unsigned, it can only be assigned a positive integer value.

10

A top level class cannot be defined with the private or protected access modifier.

True

11

A concrete class cannot define an abstract method.

True

12

Local variables can be defined with access modifiers.

False

13

The append( ) method adds a String to the end of a String object.

False, the append( ) method belongs to StringBuilder.

14

Variables local to an if block are accessible to any else if or else blocks that follow it as well.

False

15

static public final void jump( ) { } is a valid method.

True

16

String static public jump( ) is a valid method

False, the return type is out of place.

17

public static void 2test ( ) { } is a valid method

False, you cannot start an identifier with a number.

18

Method arguments are the variables that appear in the definition of a method.

False, method arguments are the actual values that are passed to a method.

19

Static methods can access the nonstatic variables and methods of a class.

False.

20

To import the static method sort( ) from the Collections class, you would use the statement import static java.util.Collections;

False, static imports are only able to import static members, so import static java.util.Collections.*; or import static java.util.Collections.sort would be valid.

21

When a constructor is given the private access modifier, the class cannot be instantiated except for within itself.

True

22

When calling this( ) in a constructor, it can be placed anywhere in the constructor.

False, this( ) must be the first statement in any constructor that is calling it.

23

Java supports multiple inheritance of type, but not multiple inheritance of state.

True

24

The Java compiler will not ignore extra semicolons.

False, it does ignore extra semicolons.

25

In Java, autoboxing/unboxing is preferred over widening a variable.

False, widening is preferred over autoboxing/unboxing.

26

The order of initialization in a Java class is static variables/initializers, superclass, constructor, then instance variables/initializers.

False, the order of initialization is superclass, static variables/initializers, instance variables/initializers, and constructors.

27

Abstract methods cannot be declared private or final.

True.

28

Abstract methods can be defined in concrete classes.

False, abstract methods can only be defined in abstract classes.

29

An abstract method can be defined as static.

False, abstract methods cannot be defined as static.

30

Variables in an interface are implicitly public, static and final.

True.