Review Flashcards

1
Q

What type does the Integer.parseInt method return?

A

Primitive integer (int)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What type does the Integer.valueOf method return?

A

Integer object

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What does the ArrayList set( ) method do?

A

Sets an element at the index provided to the value provided

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

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

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

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

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

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

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

You can start a literal value with an underscore.

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

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

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

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

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

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

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

A concrete class cannot define an abstract method.

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Local variables can be defined with access modifiers.

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

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

A

False, the append( ) method belongs to StringBuilder.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

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

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

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

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

String static public jump( ) is a valid method

A

False, the return type is out of place.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

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

A

False, you cannot start an identifier with a number.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

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

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

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

A

False.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

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

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

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

A

True

22
Q

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

A

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

23
Q

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

A

True

24
Q

The Java compiler will not ignore extra semicolons.

A

False, it does ignore extra semicolons.

25
Q

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

A

False, widening is preferred over autoboxing/unboxing.

26
Q

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

A

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

27
Q

Abstract methods cannot be declared private or final.

A

True.

28
Q

Abstract methods can be defined in concrete classes.

A

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

29
Q

An abstract method can be defined as static.

A

False, abstract methods cannot be defined as static.

30
Q

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

A

True.

31
Q

Methods in an interface are implicity abstract and public.

A

True.

32
Q

An interface method cannot be static.

A

False, it can be static as long as it has a body.

33
Q

An interface method cannot be defined as protected.

A

True.

34
Q

An interface method can be declared as private as long as the method has a body.

A

True.

35
Q

Interfaces inherit from java.lang.Object.

A

False, only classes inherit java.lang.Object.

36
Q

A method defined with the final modifier can be overridden as long as the method has the same parameters.

A

False, final methods cannot be overridden.

37
Q

Checked exceptions are subclasses of the Exception class.

A

True.

38
Q

You are required to handle Unchecked Exceptions.

A

False

39
Q

Throwable is a subclass of the Exception class.

A

False, it is a super class of Exception.

40
Q

IOException is a subclass of …

A

Exception

41
Q

SecurityException is a subclass of …

A

RuntimeException

42
Q

ClassCastException is a subclass of …

A

RuntimeException

43
Q

NullPointerException is a subclass of …

A

RuntimeException

44
Q

IndexOutOfBoundsException is a subclass of …

A

RuntimeException

45
Q

You can override a parent class static method with a non-static method of the same name and parameters in its subclass.

A

False, you cannot override a static method with a non static method, and vice versa.

46
Q

Variables can be defined as abstract.

A

False

47
Q

You can concatenate a char with a String without casting.

A

True

48
Q

The wrapper classes of the primitive data types are mutable.

A

False, they are immutable, but using operators on them that change them, like ++ or –, will return an object with the new value to the reference.

49
Q

All interface variables are considered public, static, and final, even if not declared as such.

A

True.

50
Q

The compiler checks the validity of a call on a reference variable by looking at the declared class of that reference.

A

True.