Midterm T/F Flashcards

(65 cards)

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
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.
False
26
It is possible to create an instance of a class that does not explicitly define a constructor
True
27
Multiple constructors that accept different types and number of parameters is an example of polymorphism.
True Polymorphism= many forms General principle of providing access to an abstraction or method in many forms. Ex: constructor overloading, method overloading, subinterfaces
28
A constructor that chains to another constructor must do so as the first statement of the constructor body
True. | Ex: super();
29
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.
False
30
All of the methods declared in an interface must be implemented as public methods
True
31
An interface may only extend a single parent interface
``` False A class can only extend one parent class. But an interface can extend more than one parent interface. ```
32
Every class must implement at least one interface
False | Ex: main
33
An interface may declare several different versions (overload) the same method name
True
34
The name of an interface is a valid type name that can be used as the type of a variable
True
35
A class that implements an extended interface must implement all of the methods declared in the parent interface of the extended interface.
True
36
A subclass that extends a parent class automatically implements any interfaces that the parent class implements
True
37
An instance field marked as private can be directly accessed by outside of that class
False
38
An instance of a subclass can always be used wherever a reference to an object with the parent class type is required
True
39
A subclass can extend from more than one parent class.
False
40
The scope of a local variable in a method is limited to the statement block where it is declared
True
41
A constructor may throw an exception
True
42
One constructor can call another constructor in the same class using the super keyword as if it were a method name.
False | We use super for the constructor of that specific class's parent class.
43
A setter method conforming to the Java Beans convention should return the new value of the property.
False
44
An interface definition can includde private or protected methods
False
45
An iterator provides a way to access elements of an aggregate object sequentially by exposing its underlying representation
False
46
Traversing an array using an integer index incremented as a for-loop variable is an example of the iterator design pattern.
False
47
An expression can always be used where ever a value is required
True
48
The state of an object is defined by the current values of all of its instance fields.
True
49
An iterator assumes that the underlying collection is not changed or modified while the traversal occurs
True
50
Class names, interface names, and enumeration names can all serve as the data type of a variable
True | Think: a4 sushi
51
In an instance method, the this keyword always provides a reference to the specific instance used to invoke (call) the method.
True
52
A method's signature is defined by its return type and the sequence of types associated with its parameters
True
53
Polymorphic methods with the same name may have different return types
True
54
Polymorphic methods with the same name must have distinct method signatures
True
55
Enumerations provide a type-safe mechanism for an object property that can be set to one of a distinct set of values
True | Basically the definition
56
Different classes that implement the same set of interfaces may also have different and additional behavior not declared by those interfaces
True
57
Two object references that have the same value always refer to the same object.
True
58
A class that implements a subinterface must provide implementations for methods declared by the subinterface as well as any parent interfaces that subinterface
True
59
A subclass has direct access to private and protected fields and methods in its parent class
False
60
The catch or specify policy applies to all subclasses of Exception
False
61
In general, you should catch an exception at the earliest point at which the exception can be detected.
False
62
*All overriding methods in Java are virtual
True
63
If a catch block is provided for the Exception parent class. it should appear first before any other catch blocks.
False
64
An abstract class can not be instantiated directly
True
65
The return type of a getter method following JavaBeans conventions may bee void
False