Deck 8: Objects and Classes

Full screen (f)
exit full mode
Question
_________ returns the last character in a StringBuffer variable named strBuf? _________ returns the last character in a StringBuffer variable named strBuf?  <div style=padding-top: 35px>
Use Space or
up arrow
down arrow
to flip the card.
Question
________ 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
Question
What is the output of the following program? What is the output of the following program?  <div style=padding-top: 35px>
Question
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.
Question
Analyze the following code. 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.<div style=padding-top: 35px> 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.
Question
What is the printout for the third print statement in the main method? 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<div style=padding-top: 35px> 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<div style=padding-top: 35px> A. j is 3 B. j is 2
C) j is 1
D) j is 0
Question
Analyze the following code: 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.<div style=padding-top: 35px> 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.
Question
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
Question
What is the value of myCount.count displayed? <strong>What is the value of myCount.count displayed?  </strong> A) 99 B) 101 C) 100 D) 98 <div style=padding-top: 35px>

A) 99
B) 101
C) 100
D) 98
Question
  A. 0 B. 2 C) -2 D) -1 E) 1<div style=padding-top: 35px> A. 0 B. 2
C) -2
D) -1
E) 1
Question
Analyze the following code. 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.<div style=padding-top: 35px> 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.
Question
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.
Question
Analyze the following code: <strong>Analyze the following code:  </strong> 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. <div style=padding-top: 35px>

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.
Question
Analyze the following code: 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.<div style=padding-top: 35px> 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.
Question
Analyze the following code: 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.<div style=padding-top: 35px> 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.
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/15
auto play flashcards
Play
simple tutorial
Full screen (f)
exit full mode
Deck 8: Objects and Classes
1
_________ returns the last character in a StringBuffer variable named strBuf? _________ 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
D
3
What is the output of the following program? 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.
Unlock Deck
Unlock for access to all 15 flashcards in this deck.
Unlock Deck
k this deck
5
Analyze the following code. 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. 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.
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? 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 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 A. j is 3 B. j is 2
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: 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. 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.
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
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? <strong>What is the value of myCount.count displayed?  </strong> 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
  A. 0 B. 2 C) -2 D) -1 E) 1 A. 0 B. 2
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. 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. 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.
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.
Unlock Deck
Unlock for access to all 15 flashcards in this deck.
Unlock Deck
k this deck
13
Analyze the following code: <strong>Analyze the following code:  </strong> 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: 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. 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.
Unlock Deck
Unlock for access to all 15 flashcards in this deck.
Unlock Deck
k this deck
15
Analyze the following code: 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. 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.
Unlock Deck
Unlock for access to all 15 flashcards in this deck.
Unlock Deck
k this deck
locked card icon
Unlock Deck
Unlock for access to all 15 flashcards in this deck.