Midterm T/F Flashcards

1
Q

unsigned int is a value type in Java for representing unsigned integer numeric values

A

False

Java does not support unsigned data types

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

String is a built-in value type in Java

A
False
String is a built-in class in java
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

A class name usually starts with a capital letter.

A

True

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

switch is a valid variable name

A

False

switch is a statement in java.

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

An instance of a class is always a reference type in Java

A

True

An object is a reference type.

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

An object reference is not a valid expression

A

False.

The reference of an object is valid

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

A variable can be assigned the result of any expression

A

False

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

An if statement is a type of loop

A

False.

An if statement does not loop

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

A continue statement within the body of a loop exits the loop

A

False
continue (keyword) is used in loops
for: causes control to immediately jump to the update statement
while: control immediately jumps to the boolean expression.

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

A continue statement within the body of a loop exits the loop

A

False
continue (keyword) is used in loops
for: causes control to immediately jump to the update statement
while: control immediately jumps to the boolean expression.

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

A local variable declared within a loop is not available outside of the body of the loop.

A

True.

No.

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

Several case statements within a switch statement may be associated with the same block of statements to be executed.

A

True.

Yes.

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

A method must return a value that can be used in an expression

A

False

A method can be void

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

To invoke (i.e., call) a method, you must provide a value for each parameter declared in the method’s signature.

A

True

Yes.

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

Invoking a class method - a static method - requires a reference to a particular instance (i.e., object) of the class.

A

False

A static method can be invoked without the need for creating an instance of a class.

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

When a method is called from within another method, the code within method A can access local variable within method B at the point where the call to method A was made.

A

False

No.

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

The length of an array in Java cannot be changed after the array is created

A

True

You can not modify the length of an array after it is created.

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

A specific array in java cannot be changed after the array is created.

A

True

Yes.

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

A specific array can hold values of any type.

A

False

No.

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

The individual characters of a String object can be changed

A

False

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

The principle of encapsulation encourages object fields to be marked private

A

True

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

Every method of a class should be included in at least one of the interfaces that the class implements.

A

False

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

Overloading a method is an example of the principle of encapsulation

A

False

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

Setters should never be provided for an immutable object

A

True

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

To adhere to the principle of encapsulation, a public method should not make use of (i.e., call) a private method declared in the same class.

A

False

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

It is possible to create an instance of a class that does not explicitly define a constructor

A

True

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

Multiple constructors that accept different types and number of parameters is an example of polymorphism.

A

True
Polymorphism= many forms
General principle of providing access to an abstraction or method in many forms.
Ex: constructor overloading, method overloading, subinterfaces

28
Q

A constructor that chains to another constructor must do so as the first statement of the constructor body

A

True.

Ex: super();

29
Q

Two different versions of the same method can be declared to accept the same number and type of parameters as long as the parameters have been given different names.

A

False

30
Q

All of the methods declared in an interface must be implemented as public methods

A

True

31
Q

An interface may only extend a single parent interface

A
False
A class can only extend one parent class. But an interface can extend more than one parent interface.
32
Q

Every class must implement at least one interface

A

False

Ex: main

33
Q

An interface may declare several different versions (overload) the same method name

A

True

34
Q

The name of an interface is a valid type name that can be used as the type of a variable

A

True

35
Q

A class that implements an extended interface must implement all of the methods declared in the parent interface of the extended interface.

A

True

36
Q

A subclass that extends a parent class automatically implements any interfaces that the parent class implements

A

True

37
Q

An instance field marked as private can be directly accessed by outside of that class

A

False

38
Q

An instance of a subclass can always be used wherever a reference to an object with the parent class type is required

A

True

39
Q

A subclass can extend from more than one parent class.

A

False

40
Q

The scope of a local variable in a method is limited to the statement block where it is declared

A

True

41
Q

A constructor may throw an exception

A

True

42
Q

One constructor can call another constructor in the same class using the super keyword as if it were a method name.

A

False

We use super for the constructor of that specific class’s parent class.

43
Q

A setter method conforming to the Java Beans convention should return the new value of the property.

A

False

44
Q

An interface definition can includde private or protected methods

A

False

45
Q

An iterator provides a way to access elements of an aggregate object sequentially by exposing its underlying representation

A

False

46
Q

Traversing an array using an integer index incremented as a for-loop variable is an example of the iterator design pattern.

A

False

47
Q

An expression can always be used where ever a value is required

A

True

48
Q

The state of an object is defined by the current values of all of its instance fields.

A

True

49
Q

An iterator assumes that the underlying collection is not changed or modified while the traversal occurs

A

True

50
Q

Class names, interface names, and enumeration names can all serve as the data type of a variable

A

True

Think: a4 sushi

51
Q

In an instance method, the this keyword always provides a reference to the specific instance used to invoke (call) the method.

A

True

52
Q

A method’s signature is defined by its return type and the sequence of types associated with its parameters

A

True

53
Q

Polymorphic methods with the same name may have different return types

A

True

54
Q

Polymorphic methods with the same name must have distinct method signatures

A

True

55
Q

Enumerations provide a type-safe mechanism for an object property that can be set to one of a distinct set of values

A

True

Basically the definition

56
Q

Different classes that implement the same set of interfaces may also have different and additional behavior not declared by those interfaces

A

True

57
Q

Two object references that have the same value always refer to the same object.

A

True

58
Q

A class that implements a subinterface must provide implementations for methods declared by the subinterface as well as any parent interfaces that subinterface

A

True

59
Q

A subclass has direct access to private and protected fields and methods in its parent class

A

False

60
Q

The catch or specify policy applies to all subclasses of Exception

A

False

61
Q

In general, you should catch an exception at the earliest point at which the exception can be detected.

A

False

62
Q

*All overriding methods in Java are virtual

A

True

63
Q

If a catch block is provided for the Exception parent class. it should appear first before any other catch blocks.

A

False

64
Q

An abstract class can not be instantiated directly

A

True

65
Q

The return type of a getter method following JavaBeans conventions may bee void

A

False