Computer Science 2 Final Exam
Graded A+
A class' constructor usually defines - ANSWER-B.) How an object is initialized
A helper is a method that supports other methods in the class. If you are creating a
helper method, you would most likely make it____. - ANSWER-D.) private
A java main method uses the parameter (String[] variable) so that a user can run the
program and supply "command-line" parameters. Since the parameter is a String array,
however, the user does not have to supply any parameters - ANSWER-A.) True
A linked list that stores int values would be compromised of a group of Nodes. We might
define the Node by - ANSWER-B.) class Node
{
int data;
Node next;
}
A method defined in a class can access the class' instance data without needing to pass
them as parameters or declare them as local variables - ANSWER-A.) True
A recursive method without a base case leads to seemingly infinite recursion. -
ANSWER-A.) True
After the instructions execute, x has the value - ANSWER-A.) 19
After the instructions execute, z has the value - ANSWER-C.) 9
An array, when instantiated, is fixed in size, but an ArrayList can dynamically change in
size when new elements are added to it. - ANSWER-A.) True
Consider a method defined with the header: public void foo(int a, int b). Which of the
following method calls is legal? - ANSWER-B.) foo(0/, 2*3);
From the following list, which one will be parent class?
Car, Vehicle, Truck - ANSWER-D.) Vehicle
Function of the dot operator? - ANSWER-E.) Both B and C
Given a String s, which is assumed to have at least one character in it, which of the
following conditions would determine if the first character of the String is the same as
the last character? - ANSWER-D.)
Graded A+
A class' constructor usually defines - ANSWER-B.) How an object is initialized
A helper is a method that supports other methods in the class. If you are creating a
helper method, you would most likely make it____. - ANSWER-D.) private
A java main method uses the parameter (String[] variable) so that a user can run the
program and supply "command-line" parameters. Since the parameter is a String array,
however, the user does not have to supply any parameters - ANSWER-A.) True
A linked list that stores int values would be compromised of a group of Nodes. We might
define the Node by - ANSWER-B.) class Node
{
int data;
Node next;
}
A method defined in a class can access the class' instance data without needing to pass
them as parameters or declare them as local variables - ANSWER-A.) True
A recursive method without a base case leads to seemingly infinite recursion. -
ANSWER-A.) True
After the instructions execute, x has the value - ANSWER-A.) 19
After the instructions execute, z has the value - ANSWER-C.) 9
An array, when instantiated, is fixed in size, but an ArrayList can dynamically change in
size when new elements are added to it. - ANSWER-A.) True
Consider a method defined with the header: public void foo(int a, int b). Which of the
following method calls is legal? - ANSWER-B.) foo(0/, 2*3);
From the following list, which one will be parent class?
Car, Vehicle, Truck - ANSWER-D.) Vehicle
Function of the dot operator? - ANSWER-E.) Both B and C
Given a String s, which is assumed to have at least one character in it, which of the
following conditions would determine if the first character of the String is the same as
the last character? - ANSWER-D.)