Deck 8: Objects and Classes
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/15
Play
Full screen (f)
Deck 8: Objects and Classes
1
_________ returns the last character in a StringBuffer variable named strBuf? 

D
2
________ is invoked to create an object. A. The main method
B) A method with a return type
C) A method with the void return type
D) A constructor
B) A method with a return type
C) A method with the void return type
D) A constructor
D
3
What is the output of the following program? 

D
4
Given the declaration Circle[] x = new Circle[10], which of the following statement is most accurate.
A) x contains an array of ten int values.
B) x contains a reference to an array and each element in the array can hold a Circle object.
C) x contains an array of ten objects of the Circle type.
D) x contains a reference to an array and each element in the array can hold a reference to a Circle object.
A) x contains an array of ten int values.
B) x contains a reference to an array and each element in the array can hold a Circle object.
C) x contains an array of ten objects of the Circle type.
D) x contains a reference to an array and each element in the array can hold a reference to a Circle object.
Unlock Deck
Unlock for access to all 15 flashcards in this deck.
Unlock Deck
k this deck
5
Analyze the following code.
A. The program has a compile error because x has not been initialized. B. The program has a compile error because test is not initialized.
C) The program has a runtime NullPointerException because test is null while executing test.x.
D) The program has a compile error because you cannot create an object from the class that defines the object.
E) The program has a compile error because Test does not have a default constructor.

C) The program has a runtime NullPointerException because test is null while executing test.x.
D) The program has a compile error because you cannot create an object from the class that defines the object.
E) The program has a compile error because Test does not have a default constructor.
Unlock Deck
Unlock for access to all 15 flashcards in this deck.
Unlock Deck
k this deck
6
What is the printout for the third print statement in the main method?
A. j is 3 B. j is 2
C) j is 1
D) j is 0


C) j is 1
D) j is 0
Unlock Deck
Unlock for access to all 15 flashcards in this deck.
Unlock Deck
k this deck
7
Analyze the following code:
A. The program compiles and runs fine. B. The program has no compile errors but will get a runtime error because radius is not initialized.
C) The program has compile errors because the variable radius is not initialized.
D) The program has a compile error because a constant PI is defined inside a method.

C) The program has compile errors because the variable radius is not initialized.
D) The program has a compile error because a constant PI is defined inside a method.
Unlock Deck
Unlock for access to all 15 flashcards in this deck.
Unlock Deck
k this deck
8
When invoking a method with an object argument, ___________ is passed. A. a copy of the object
B) the object is copied, then the reference of the copied object
C) the reference of the object
D) the contents of the object
B) the object is copied, then the reference of the copied object
C) the reference of the object
D) the contents of the object
Unlock Deck
Unlock for access to all 15 flashcards in this deck.
Unlock Deck
k this deck
9
What is the value of myCount.count displayed? 
A) 99
B) 101
C) 100
D) 98

A) 99
B) 101
C) 100
D) 98
Unlock Deck
Unlock for access to all 15 flashcards in this deck.
Unlock Deck
k this deck
10

C) -2
D) -1
E) 1
Unlock Deck
Unlock for access to all 15 flashcards in this deck.
Unlock Deck
k this deck
11
Analyze the following code.
A. The program has a runtime error because s is not initialized, but it is referenced in the println statement. B. The program has a compile error because s is not initialized, but it is referenced in the println statement.
C) The program has a runtime error because s is null in the println statement.
D) The program compiles and runs fine.

C) The program has a runtime error because s is null in the println statement.
D) The program compiles and runs fine.
Unlock Deck
Unlock for access to all 15 flashcards in this deck.
Unlock Deck
k this deck
12
Given the declaration Circle x = new Circle(), which of the following statement is most accurate. A. x contains an object of the Circle type.
B) You can assign an int value to x.
C) x contains a reference to a Circle object.
D) x contains an int value.
B) You can assign an int value to x.
C) x contains a reference to a Circle object.
D) x contains an int value.
Unlock Deck
Unlock for access to all 15 flashcards in this deck.
Unlock Deck
k this deck
13
Analyze the following code: 
A) The program has compile errors because the variable radius is not initialized.
B) The program compiles and runs fine.
C) The program has no compile errors but will get a runtime error because radius is not initialized.
D) The program has a compile error because a constant PI is defined inside a method.

A) The program has compile errors because the variable radius is not initialized.
B) The program compiles and runs fine.
C) The program has no compile errors but will get a runtime error because radius is not initialized.
D) The program has a compile error because a constant PI is defined inside a method.
Unlock Deck
Unlock for access to all 15 flashcards in this deck.
Unlock Deck
k this deck
14
Analyze the following code:
A. The program has a compile error because you cannot assign radius to radius. B. The program will compile, but you cannot create an object of Circle with a specified radius. The object will always have radius 0.
C) The program does not compile because Circle does not have a default constructor.
D) The program has a compilation error because it does not have a main method.

C) The program does not compile because Circle does not have a default constructor.
D) The program has a compilation error because it does not have a main method.
Unlock Deck
Unlock for access to all 15 flashcards in this deck.
Unlock Deck
k this deck
15
Analyze the following code:
A. The program compiles and runs fine. B. The variable t is private and therefore cannot be accessed in the main method.
C) The variable x is not initialized and therefore causes errors.
D) t is non-static and it cannot be referenced in a static context in the main method.
E) The variable t is not initialized and therefore causes errors.

C) The variable x is not initialized and therefore causes errors.
D) t is non-static and it cannot be referenced in a static context in the main method.
E) The variable t is not initialized and therefore causes errors.
Unlock Deck
Unlock for access to all 15 flashcards in this deck.
Unlock Deck
k this deck