Midterm T/F Flashcards Preview

Comp 401 > Midterm T/F > Flashcards

Flashcards in Midterm T/F Deck (65):
1

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

False
Java does not support unsigned data types

2

String is a built-in value type in Java

False
String is a built-in class in java

3

A class name usually starts with a capital letter.

True

4

switch is a valid variable name

False
switch is a statement in java.

5

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

True
An object is a reference type.

6

An object reference is not a valid expression

False.
The reference of an object is valid

7

A variable can be assigned the result of any expression

False

8

An if statement is a type of loop

False.
An if statement does not loop

9

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

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.

10

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

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.

11

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

True.
No.

12

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

True.
Yes.

13

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

False
A method can be void

14

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

True
Yes.

15

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

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

16

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.

False
No.

17

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

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

18

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

True
Yes.

19

A specific array can hold values of any type.

False
No.

20

The individual characters of a String object can be changed

False

21

The principle of encapsulation encourages object fields to be marked private

True

22

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

False

23

Overloading a method is an example of the principle of encapsulation

False

24

Setters should never be provided for an immutable object

True

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