Chapter 11 JAVA Flashcards

1
Q

What is a class?

A. A class is a section of computer memory containing objects.

B. A class is a section of the hard disk reserved for object oriented programs.

C. A class is a description of a kind of object.

D. A class is the part of an object that contains the variables.

A

C. A class is a description of a kind of object.

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

How many objects of a given class may be constructed in a program?

A. Only one object is constructed per run of the program.

B. As many as the program asks for.

C. Only one per class.

D. One object per variable.

A

B. As many as the program asks for.

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

Which of the following is a correct way to construct a String object?

A. String alpha(“Hello Quiz!”) ;

B. String = “Hello Quiz!” ;

C. String alpha = new “Hello Quiz!” ;

D. String alpha = new String(“Hello Quiz!”) ;

A

D. String alpha = new String(“Hello Quiz!”) ;

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

What is an object?

A. An object is a chunk of memory that can contain data along with methods to process data.

B. An object is a tiny box of memory that contains only data.

C. “Object” is another word for “program”.

D. An object is a description of a potential class.

A

A. An object is a chunk of memory that can contain data along with methods to process data.

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

Just as a program starts running, do any objects exist?

A. Yes. All the objects that the program describes are created just as the program starts running.

B. Yes. All the objects that the program describes are created when the program is compiled.

C. No. Objects are a way to think about programming, but don’t actually exist.

D. No. Objects are created one by one as the program runs.

A

D. No. Objects are created one by one as the program runs.

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

Which of the following invokes the method length() of the object referenced by str and stores the result in val?

A. val = str.length() ;

B. val = length.str() ;

C. val = length().str ;

D. val = length( str ) ;

A

A. val = str.length() ;

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

Examine the following:

String myString;
What is myString?

A. myString is a reference variable.

B. myString is an object.

C. myString always points to an object.

D. myString is a String.

A

A. myString is a reference variable.

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

What is a reference to an object?

A. one of the object’s methods.

B. one of the object’s variables.

C. data on where the object is located.

D. a place in a program that created an object.

A

C. data on where the object is located.

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

Examine the following:

String stringA = “Olde Frothingslosh” ;
String stringB;

stringB = stringA.substring(6);
What characters are in the String referred to by stringB?

A. Olde

B. Froth

C. rothingslosh

D. Frothingslosh

A

C. rothingslosh

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

What is the class of the type wrapper for primitive type int?

A. int

B. INT

C. Integer

D. integer

A

C. Integer

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