Unit 9 Summative Review III - MCQ Practice
Unit 9 Summative Review III - MCQ Practice
public Book()
{
bookTitle = "";
}
The following code segment appears in a method in a class other than Book or TextBook.
Which of the following best describes the effect of executing the code segment?
(A) The TextBook constructor initializes the instance variable subject with the value of "Geometry", and
then calls the default Book constructor, which initializes the instance variable bookTitle to "".
(B) The TextBook constructor initializes the instance variable subject with the value of "Geometry", and
then invokes the one-parameter Book constructor, which initializes the instance variable bookTitle to
"Geometry".
(C) There is an implicit call to the default Book constructor first, and the instance variable bookTitle is then
initialized to "". Then, the instance variable subject is initialized with the value of "Geometry".
(D) There is an implicit call to the default Book constructor first, and the instance variable bookTitle is then
initialized to "Geometry". Then, the instance variable subject is initialized with the value of "Geometry".
(E) The code segment will not execute because the TextBook constructor does not contain an explicit call to
one of the Book constructors.
The next two questions refer to the two classes defined below:
(A) Nothing is printed, Java will not let us initialize an object declared as a different type.
(B) better make it
(C) make it
(D) make it better
(E) better
example.speak();
(A) faster
(B) do it
(C) do it faster
(D) faster do it
(E) Nothing is printed. speak is a ThisClass method and example is a ThatClass object
Use the following classes to answer the questions that follow.
B 4) Which of the following is a correct way to implement the parameter constructor in exampleB?
(A) I only
(B) I and II only
(C) II and III only
(D) I and III only
(E) I, II, and III
D 5) Which of the following is the correct way to implement the toString() method in exampleB so that
it returns its two instance variables?
B 6) Which of the following is a correct way to implement the equals method in exampleA so that it returns
true if both exampleB objects have the same data and false otherwise?
public WhatsIt()
{
//implementation not shown
}
public Athlete() {
name = "Athlete 1";
}
public TrackStar() {
super();
mile = 8.5;
}
(A) I only
(B) I and II only
(C) II and III only
(D) I and III only
(E) I, II, and III
(A) roster[0].play();
(B) roster[0].run();
(C) roster[1].play();
(D) roster[1].run();
(E) roster[0].play();
roster[1].run();