CSE 205 2026/2027 Final Examination
Revision Package: Structured Quizzes, Past
Papers, and Concept Review for Exam
Success
Question 1: Method Overriding in Inheritance
To override a superclass method in a subclass, the subclass method must:
A. Use a different method name
B. Use the same method name and the same parameter types
C. Use a different method name and the same parameter types
D. Use a different method name and different parameter types
Correct Answer: B. Must use the same method name and the same parameter
types
Rationale:
Method overriding in Java requires that the subclass method has the exact same
method signature as the superclass method, including the method name and parameter
list. This ensures runtime polymorphism works correctly. Changing the name or
parameters results in method overloading, not overriding. Therefore, options A, C,
and D are incorrect because they violate the rules of inheritance-based method
overriding.
Question 2: Accessing Constants in Interfaces
Given the interface:
public interface Sizable {
int LARGE_CHANGE = 100;
void changeSize();
}
How should the constant be accessed in another class?
A. LARGE-CHANGE
B. Sizable.LARGE_CHANGE
C. Sizable(LARGE_CHANGE)
D. You cannot use it directly
Correct Answer: B. Sizable.LARGE_CHANGE
,2026/2027
Rationale:
Interface variables are implicitly public, static, and final. Therefore, they are accessed
using the interface name followed by the variable name. Option B is correct. The
other options are invalid syntax or incorrect assumptions about interface constants.
Question 3: Comparable Interface Error
public class BankAccount implements Comparable<BankAccount> {
public int compareTo(T other) {
What is the issue in this code?
A. Wrong interface type
B. Missing generic declaration
C. Incorrect compareTo parameter type
D. No error exists
Correct Answer: C. Incorrect compareTo parameter type
Rationale:
The compareTo method must match the type declared in Comparable. Since the class
uses Comparable<BankAccount>, compareTo must accept a BankAccount parameter.
Using a generic T causes a mismatch, leading to a compilation error.
Question 4: Properties of Interfaces
Which statement is true about Java interfaces?
A. Interfaces have methods and instance variables
B. Interfaces have methods but no instance variables
C. Interfaces have neither methods nor variables
D. Interfaces have instance variables but no methods
Correct Answer: B. Interfaces have methods but no instance variables
Rationale:
Interfaces define behavior through abstract methods and constants, but they do not
contain instance variables. This allows multiple classes to implement the same
behavior contract.
Question 5: Interface Method Requirement
Which statement about Java interfaces is NOT true?
A. Interfaces define required methods
B. Interfaces must contain more than one method
,2026/2027
C. Interfaces define behavior contracts
D. Methods are abstract by default
Correct Answer: B. Interfaces must contain more than one method
Rationale:
An interface can contain one or many methods. There is no requirement for multiple
methods, making option B incorrect.
Question 6: Generalized Interface Parameter
double measure(__________ anObject);
Which parameter allows all object types?
A. Class
B. Object
C. Any
D. Void
Correct Answer: B. Object
Rationale:
Using Object allows the method to accept any Java class since all classes inherit from
Object.
Question 7: Type Checking in Java
Which operator checks if an object belongs to a specific type?
A. this
B. subclassOf
C. instanceof
D. equals
Correct Answer: C. instanceof
Rationale:
The instanceof operator is used for runtime type checking in Java. The other options
are not valid Java type-checking constructs.
Question 8: Object Comparison
Which statement is correct?
, 2026/2027
A. equals compares memory addresses
B. equals compares object content
C. == compares object content
D. equals and == behave the same
Correct Answer: B. equals compares object content
Rationale:
The equals method is used for logical equality (content), while == compares memory
references.
Question 9: Default toString Behavior
What happens if toString() is not overridden?
A. Returns object fields
B. Returns only object name
C. Returns class name + hash code
D. Compilation error
Correct Answer: C. Returns class name + hash code
Rationale:
The default Object.toString() method returns class name plus hashcode representation.
Question 10: Access Modifier – protected
Protected members can be accessed by:
A. Only the class itself
B. Any class
C. Same package + subclasses
D. Only subclasses in other packages
Correct Answer: C. Same package + subclasses
Rationale:
Protected allows access within the same package and by subclasses, even across
packages.
Question 11: Final Class Behavior
Which statement is FALSE about final classes?
A. Cannot be extended
B. Cannot be subclassed