TEST BANK
, ITSC 1213 FINAL EXAM PRACTICE (TEST BANK)– 50+
MCQS WITH 100% VERIFIED ANSWERS
1. What happens if a test case returns an error even when the code is correct?
A. It's due to a compiler bug
B. It indicates a logical error
C. The test is invalid
D. It’s impossible
Answer: B. It indicates a logical error
A logical error means the code compiles but doesn’t behave as expected.
2. An abstract class can be:
A. Instantiated directly
B. Created without a constructor
C. Extended by another class
D. Only used with interfaces
Answer: C. Extended by another class
Abstract classes cannot be instantiated but are designed to be extended.
3. An array can store:
A. Multiple data types
B. Strings and integers together
C. Only a single value
D. Multiple values of the same data type
Answer: D. Multiple values of the same data type
Java arrays are homogenous, storing one data type only.
, 4. What will happen if you attempt to instantiate an interface in Java?
A. It will compile but not run
B. Compilation error
C. Returns null
D. Interface will act like a class
Answer: B. Compilation error
Interfaces cannot be instantiated directly in Java.
5. Which of the following could hold Book type objects?
A. ArrayList<String>
B. ArrayList<Book>
C. ArrayList<Object>
D. ArrayList<Product>
Answer: B, C, D
Book is a subclass of Product and Object, so all those can hold it.
6. What output does the following code produce? System.out.println(c.contract(3));
with Contractor implements Contract returning a string.
A. 3
B. Compilation error
C. "The project will be done in 3 months"
D. No output
Answer: C. "The project will be done in 3 months"
The contract() method is properly overridden in Contractor.
7. What access does a superclass have to methods defined only in the subclass?
A. Full access
B. Inherited access
C. No access
D. Limited access
Answer: C. No access
Superclasses do not know about subclass-specific methods.