Question 1
4 out of 4 points
Which superclass members are inherited by all subclasses of that superclass?
Selected
Answer:
protected instance variables and
methods.
Question 2
4 out of 4 points
Inheritance is also known as the
Selected
Answer:
is-a
relationship.
Question 3
4 out of 4 points
When a subclass constructor calls its superclass constructor, what happens if the
superclass’s constructor does not assign a value to an instance variable?
Selected
Answer:
The program compiles and runs because the instance variables are
initialized to their default values.
Question 4
4 out of 4 points
The default equals implementation of class Object determines:
Selected
Answer:
whether two references refer to the same object in
memory.
Question 5
4 out of 4 points
Which of the following statements is false?
Selected
Answer:
If the class you're inheriting from declares instance variables as private, the
inherited class can access those instance variables directly.
Question 6
4 out of 4 points
When must a program explicitly use the this reference?
Selected
Answer:
Accessing an instance variable that is shadowed by a
local variable.
Question 7
4 out of 4 points
Set methods are also commonly called ________ methods and get methods are also
commonly called ________ methods.
Selected
Answer:
mutator,
accessor.
Question 8
4 out of 4 points
Which of the following statements is true?
Selected
Answer:
Methods and instance variables can both be either public
or private.
Question 9
4 out of 4 points
Every class in Java, except ________, extends an existing class.
Selected
Answer:
Objec
t.
Question 10
4 out of 4 points
When implementing a method, use the class’s set and get methods to access the class’s
________ data.
Selected
Answer:
privat
e.
Question 11
4 out of 4 points
Which interface is used to identify classes whose objects can be written to or read from
some type of storage or transmitted across a network?
Selected
Answer:
Serializab
le
Question 12
4 out of 4 points
Which of the following statements is false?
Selected
Answer:
Anonymous methods provide a shorthand notation for
creating lambdas.
Question 13
4 out of 4 points
Declaring a method final means:
Selected
Answer:
it cannot be
overridden.
Question 14
4 out of 4 points
Which keyword is used to specify that a class will define the methods of an interface?
Selected
Answer:
implemen
ts
Question 15
4 out of 4 points
Consider classes A, B and C, where A is an abstract superclass, B is a concrete class that
inherits from A and C is a concrete class that inherits from B. Class A declares abstract
method originalMethod, implemented in class B. Which of the following statements is true
of class C?
Selected
Answer:
None of the
above.
Question 16
4 out of 4 points
Assigning a subclass reference to a superclass variable is safe ________.
Selected
Answer:
because the subclass object is an object of its
superclass.
Question 17
4 out of 4 points
Polymorphism allows for specifics to be dealt with during:
Selected
Answer:
executio
n.
Question 18
4 out of 4 points
Which of the following could be used to declare abstract method method1 in abstract
class Class1 (method1 returns an int and takes no arguments)?
Selected
Answer:
public abstract int
method1();
Question 19
4 out of 4 points
It is a UML convention to denote the name of an abstract class in ________.
Selected
Answer:
italic
s.
Question 20
4 out of 4 points
Polymorphism enables you to:
Selected
Answer:
program in the
general.
Question 21
4 out of 4 points
Consider the Java segment:
String line1 = new String("c = 1 + 2 + 3") ;
StringTokenizer tok = new StringTokenizer(line1);
int count = tok.countTokens();
The value of count is ________.
Selected
Answer:
7
.
Question 22
4 out of 4 points
For
String c = "Hello. She sells sea shells";
The Java statements
int i = c.indexOf("ll");
int j = c.lastIndexOf("ll");
will result in:
Selected
Answer:
i = 2 and j =
24.
Question 23
4 out of 4 points
To find the character at a certain index position within a String, use the method ________.
Selected
Answer:
charAt, with the index as an
argument
Question 24
4 out of 4 points
Which of the following statements is true?
Selected
Answer:
All of the
above.
Question 25
4 out of 4 points
The length of a string can be determined by ________.
Selected
Answer:
the String method
length()
Question 26
0 out of 4 points
Which of the following is not a method of class String?
Selected
Answer:
toCharArr
ay
Question 27
4 out of 4 points
Consider the Java segment:
String line1 = new String("c = 1 + 2 + 3");
StringTokenizer tok = new StringTokenizer(line1, delimArg);
For the String line1 to have 4 tokens, delimArg should be:
Selected
Answer:
String delimArg =
"+=";
Question 28
4 out of 4 points
Which of the Java strings represent the regular expression ,\s*?
Selected
Answer:
",\\s*
"
Question 29
0 out of 4 points
Consider the statement below:
StringBuilder sb1 = new StringBuilder("a toyota");
Which of the following creates a String object with the value "toy"?
Selected
Answer:
char dest[] = new
char[sb1.length()];
sb1.getChars(2, 5,
dest, 0);
String res = new
String(dest);
Question 30
4 out of 4 points
Consider the String below:
String r = "a toyota";
Which of the following will create the String r1 = "a TOYOTa"?
Selected
Answer:
String r1 = r.replace('t','T').replace('o',
'O').replace('y', 'Y');
Question 31
4 out of 4 points
Which statement is false?
Selected
Answer:
Class SortedSet implements
TreeSet.
Question 32
4 out of 4 points
Collections method sort that accepts a List as an argument. It sorts the List elements,
which must implement the __________ interface.
Selected
Answer:
Comparab
le.
Question 33
4 out of 4 points
Which statement about hashing is false?
Selected
Answer:
A load factor of 1.0 usually results in good hashing performance, but less
efficient utilization of memory.
Question 34
4 out of 4 points
The collections framework algorithms are __________, i.e., each of these algorithms can
operate on objects that implement specified interfaces without concern for the underlying
implementations.
Selected
Answer:
polymorphi
c.
Question 35
0 out of 4 points
Maps allocate keys to values and cannot contain duplicate keys, i.e., the key-to-value
mapping is a __________ mapping.
Selected
Answer:
d.
one-to-
one.
Question 36
4 out of 4 points
Which statement is false?
Selected
Answer:
A List cannot contain duplicate
elements.
Question 37
4 out of 4 points
Which statement is false?
Selected
Answer:
The methods for primitive types correspond to the methods for the
corresponding type-wrapper classes.
Question 38
4 out of 4 points
If the desired Object is not found, binarySearch returns __________.
Selected
Answer:
a negative
value
Question 39
4 out of 4 points
Which of the following performs a boxing conversion?
Selected
Answer:
Integer x
= 7;
Question 40
0 out of 4 points
Which of the following performs an unboxing conversion? Assume x refers to an Integer
object.
Selected
Answer:
Integer y
= x;
Question 41
4 out of 4 points
__________ enable programmers to specify, with a single method declaration, a set of
related methods.
Selected
Answer:
Generic
methods.
Question 42
4 out of 4 points
When the compiler translates a generic method into Java bytecodes, it uses __________ to
replace the type parameters with actual types.
Selected
Answer:
erasur
e.
Question 43
4 out of 4 points
Fractals that yield an exact copy of the original when a portion of the original image is
magnified are called fractals.
Selected
Answer:
strictly self-
similar.
Question 44
4 out of 4 points
Class Number is ________ of both Integer and Double.
Selected
Answer:
the
superclass
Question 45
4 out of 4 points
All generic method declarations have a type parameter section delimited by __________.
Selected
Answer:
angle brackets (<
and >).
Question 46
4 out of 4 points
Which of the following statements is true?
Selected
Answer:
Both a) and b) are
true.
Question 47
4 out of 4 points
A wildcard type argument is denoted by a(n) __________.
Selected
Answer:
question mark
(?).
Question 48
0 out of 4 points
In recursive backtracking, if one set of recursive calls does not result in a solution to the
problem, what happens?
Selected The program backs up to the original
Answer: method call.
Question 49
4 out of 4 points
Suppose Stack is a generic class that has one type parameter. The assignment
Stack<Integer> integerStack = new Stack(10);
Selected
Answer:
is permitted but unsafe, the compiler issues a
warning message.
Question 50
4 out of 4 points
One generic Stack class could be the basis for creating many Stack classes, e.g.,
Stack<Double>, Stack<Integer> and Stack<Employee>. These classes are known as
__________.
Selected
Answer:
parameterized
classes.
Wednesday, July 1, 2020 7:46:07 AM EDT
Powered by TCPDF (www.tcpdf.org)