CSIS 212 FINAL EXAM – QUESTION AND ANSWERS (Graded A)
CSIS 212 FINAL EXAM
CSIS 212 FINAL EXAM – QUESTION AND ANSWERS
CSIS 212
CSIS 212 FINAL
... [Show More] EXAM – QUESTION AND ANSWERS (Graded A)
Attempt Score 144 out of 150 points
Question 1
3 out of 3 points
Which statement below could be used to simulate the outputs of tossing a quarter to get heads or tails? Suppose random Numbers is a Secure Random object.
Selected Answer: Random Numbers. nextInt(2);
Question 2
3 out of 3 points
Overloaded methods always have the same _________.
Selected Answer: method name
Question 3
3 out of 3 points
The identifiers in an enumeration ________.
Selected Answer: Must be unique.
Question 4
3 out of 3 points
Declaring main as static allows the JVM to invoke main ________.
Selected Answer: Without creating an instance of the class in which main is declared.
Question 5
3 out of 3 points
Variables should be declared as fields only if ________.
Selected Answer: they are required for use in more than one method or their values must be saved between calls to the class’s methods
Question 6
3 out of 3 points
The java.text package contains classes for manipulating all of the following items except ________.
Selected Answer: classes
Question 7
3 out of 3 points
Which set of statements totals the items in each row of two-dimensional array items, and displays each row’s total?
Selected Answer:
for (int row = 0; row < items.length; row++) {
int total = 0;
for (int column = 0; column < items[row].length; column++) {
total += items[row][column];
System.out.printf("Row %d's total is %d%n", row, total);
}
Question 8
3 out of 3 points
Which of the following statements is false?
Selected Answer: When an argument is passed by reference, the called method can access the argument’s value in the caller directly but cannot modify it.
Question 9
3 out of 3 points
A programmer must do the following before using an array:
Selected Answer: declare then create the array.
Question 10
0 out of 3 points
How many Book objects are created by the following statement?
Book[] books = new Book[10];
Selected Answer: None of the above.
Question 11
3 out of 3 points
In Java, multidimensional arrays ________.
Selected Answer: All of the above.
Question 12
3 out of 3 points
What do the following statements do?
double[] array;
array = new double[14];
Selected Answer: Create a double array containing 14 elements.
Question 13
3 out of 3 points
A constructor cannot:
Selected Answer: specify return types or return values.
Question 14
3 out of 3 points
Constructors:
Selected Answer: Both (a) and (c).
Question 15
3 out of 3 points
Which syntax imports all static members of class Math?
Selected Answer: import static java.lang.Math.*.
Question 16
3 out of 3 points
Using public set methods helps provide data integrity if:
Selected Answer: Both b and c.
Question 17
3 out of 3 points
Instance variables declared final do not or cannot:
Selected Answer: Be modified after they are initialized.
Question 18
3 out of 3 points
When no access modifier is specified for a method or variable, the method or variable:
Selected Answer: Has package access.
Question 19
3 out of 3 points
Overriding a method differs from overloading a method because:
Selected Answer: Overridden methods have the same signature.
Question 20
3 out of 3 points
Which statement is true when a superclass has protected instance variables?
Selected Answer: All of the above.
Question 21
3 out of 3 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 22
3 out of 3 points
Which superclass members are inherited by all subclasses of that superclass?
Selected Answer: protected instance variables and methods.
Question 23
3 out of 3 points
To avoid duplicating code, use ________, rather than ________.
Selected Answer: inheritance, the “copy-and-past” approach.
Question 24
3 out of 3 points
Using the protected keyword also gives a member:
Selected Answer: package access.
Question 25
3 out of 3 points
Which of the following is not a superclass/subclass relationship?
Selected Answer: Sailboat/Tugboat.
Question 26
3 out of 3 points
Which of the following keywords allows a subclass to access a superclass method even when the subclass has overridden the superclass method?
Selected Answer: super.
Question 27
3 out of 3 points
The default implementation of method clone of Object performs a ________.
Selected Answer: shallow copy.
Question 28
3 out of 3 points
Consider the classes below, declared in the same file: Which of the statements below is false?
class A {
int a;
public A() {
a = 7;
}
}
class B extends A {
int b;
public B() {
b = 8;
}
}
Selected Answer: A reference of type A can be treated as a reference of type B.
Question 29
3 out of 3 points
Private fields of a superclass can be accessed in a subclass
Selected Answer: by calling public or protected methods declared in the superclass.
Question 30
3 out of 3 points
Superclass methods with this level of access cannot be called from subclasses.
Selected Answer: private.
Question 31
3 out of 3 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 32
3 out of 3 points
Every class in Java, except ________, extends an existing class.
Selected Answer: Object.
Question 33
3 out of 3 points
Which of the following is the superclass constructor call syntax?
Selected Answer: keyword super, followed by a set of parentheses containing the superclass constructor arguments.
Question 34
3 out of 3 points
The default equals implementation of class Object determines:
Selected Answer: whether two references refer to the same object in memory.
Question 35
3 out of 3 points
Which of the following statements is false?
Selected Answer: You cannot prevent client code from creating objects of a class.
Question 36
3 out of 3 points
When a superclass variable refers to a subclass object and a method is called on that object, the proper implementation is determined at execution time. What is the process of determining the correct method to call?
Selected Answer: late binding.
Question 37
0 out of 3 points
Which of the following statements is false?
Selected Answer: An interface also may extend one or more other interfaces.
Question 38
3 out of 3 points
Which of the following is not possible?
Selected Answer: A class that inherits from two classes.
Question 39
3 out of 3 points
Every object in Java knows its own class and can access this information through method .
Selected Answer: getClass.
Question 40
3 out of 3 points
Which keyword is used to specify that a class will define the methods of an interface?
Selected Answer: implements
Question 41
3 out of 3 points
Which of the following statements is false?
Selected Answer: Anonymous methods provide a shorthand notation for creating lambdas.
Question 42
3 out of 3 points
Non-abstract classes are called ________.
Selected Answer: concrete classes.
Question 43
3 out of 3 points
Which statement best describes the relationship between superclass and subclass types?
Selected Answer: A subclass reference can be assigned to a superclass variable, but a superclass reference cannot be assigned to a subclass variable.
Question 44
3 out of 3 points
Polymorphism enables you to:
Selected Answer: program in the general.
Question 45
3 out of 3 points
Which of the following is false?
Selected Answer: It’s OK to any of a class’s methods from its constructors.
Question 46
3 out of 3 points
Which of the following statements is false?
Selected Answer: References to interface types do not have access to method toString.
Question 47
3 out of 3 points
It is a UML convention to denote the name of an abstract class in ________.
Selected Answer: italics.
Question 48
3 out of 3 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 49
3 out of 3 points
Classes and methods are declared final for all but the following reasons:
Selected Answer: final methods are static.
Question 50
3 out of 3 points
A(n) ____________ class cannot be instantiated.
Selected Answer: abstract.
Friday, March 6, 2020 8:45:35 PM EST
OK [Show Less]