Final Exam Flashcards

1
Q

A program that translates Java source code into a platform-independent format

A

compiler

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

A program that executes Java files

A

interpreter

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

You can use a Scanner object to:

A

get the next token in an input line

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

Groups of related classes are organized into

A

packages

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

The order of precedence, from first to last, for arithmetic operations is

A

increment, multiply, add

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

A boolean operator that only evaluates the second condition when necessary is a(n)

A

short-circuit

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

Modification is not a what?

A

Basic Control Structure

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

The Java implementation of the case structure uses which keyword?

A

switch

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

The keyword used to code a class method is

A

static

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

Which statement is always optional in exception handling?

A

finally

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

Which statement is required to match a try block?

A

catch

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

Division by zero would be an example of which type of exception class?

A

Arithmetic

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

Exception handing using the try statement is done by

A

coding a try block around the statement that may cause the exception

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

An object that contains information about an error that has occurred is a(n)

A

exception

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

After an exception has occurred, the remaining statement in the try block are

A

skipped

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

What is the value of the variable x after the following statements have run?

int[ ] a = {1, 2, 3};
int x = 0;
for (int n : a)
x+=n;

A

6

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

What is printed by the following for loop?

int[ ][ ] m = { {4, 3}, { 2, 1} };

for (int i=0; i<m.length; i++)
System.out.print (m[i][i]);

A

41

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

What is the value of nums.length for the following array?

int[ ][ ] nums = { {1, 2}, {3, 4, 5}, {6, 7, 8, 9}, {10} };

A

4

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

What is the value nums[1].length for the following array?

A

3

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

What is the value of the variable len after the following statements have run?

String s = “abc”;
int len = s.length( );

A

3

Remember length is different than value.

21
Q

Which of the following would be most appropriate to sort an array of strings?

A

Arrays.sort( )

22
Q

Which Java keyword refers to the current object?

A

this

23
Q

Another name for an object that belongs to a particular class is a(n):

A

instance

24
Q

Class data (or fields) are typically implemented as

A

instance variables

25
Q

A class that is intentionally left incomplete and therefore cannot be instantiated is

A

abstract

26
Q

Which is the default visibility when none is stated?

A

package

27
Q

When a method is overridden, which keyword allows access to the method’s original form?

A

super

28
Q

Extending a parent class and then including a new version of its methods in the child class is

A

overriding

29
Q

Which keyword used in a class declaration to create a subclass?

A

extends

30
Q

The parent class for all other classes is

A

object

31
Q

Assuming a parent class named Product uses a constructor named Product( ), which of the following is required by the constructor for its child class?

A

super()

32
Q

Making a method abstract means that the method

A

must be overridden by a child class

33
Q

Which type of visibility allows access from everywhere?

A

public

34
Q

Which keyword is used to create a constant in Java?

A

final

35
Q

Which type of visibility does not allow methods or data to be inherited?

A

private

36
Q

What is the lower bound for an ArrayList?

A

0

37
Q

What type of visibility allows access only by other classes within the same package or by inheritance?

A

protected

38
Q

A class that cannot be extended or modified by inheritance is referred to as

A

final

39
Q

Which of the following defines a set of public methods to be implemented by a class?

A

interface

40
Q

When a class implements an interface, it must?

A

provide an implementation for each method defined by the interface

41
Q

An interface that defines specific code to implements its methods will?

A

cause a compile error

42
Q

Declaring a parameter an as interface type will?

A

allow passing any object that implements the interface

43
Q

Forgetting to implement a method required by an interface will cause?

A

cause a compile error

44
Q

When an interface inherits from other interfaces, the implementing class?

A

must implement all inherited methods as well, unless the implementing class is abstract

45
Q

When comparing abstract classes and interfaces?

A

both can use static constants

46
Q

Which type of stream is used to read and write text files?

A

character

47
Q

What do you do to append text to an existing file?

A

specify true in the FileWriter constructor

48
Q

Which method return true if the path name exists and refers to a directory?

A

isDirectory( )