CSE 205 Final Study-Guide UPDATED
ACTUAL Exam Questions and Correct |
CSE 205 Final Exam (UPDATED)
Section 1: Object-Oriented Programming Fundamentals (Q1–15)
Q1. Which of the following best describes encapsulation?
A) Hiding implementation details and bundling data with methods
B) Allowing a class to inherit from multiple parents
C) Hiding methods from other classes using the private keyword only
D) Using interfaces to define behavior
Correct Answer: A
Rationale:
• A (Correct): Encapsulation is about bundling data (fields) and methods that operate
on that data into a single unit (class) and restricting direct access to some
components.
• B: This describes multiple inheritance, not encapsulation.
• C: Too narrow; encapsulation uses private, protected, and package-private.
• D: Interfaces relate to abstraction, not encapsulation per se.
Q2. Which access modifier allows access only within the same class?
A) public
B) protected
C) private
D) default (no modifier)
Correct Answer: C
Rationale:
• C (Correct): private members are accessible only inside the class they are declared.
• A: public → anywhere.
, • B: protected → same package + subclasses.
• D: default → same package only.
Q3–Q15 (Continue with similar style covering: constructors, this, static, method overloading,
overriding, super, polymorphism, abstraction, interfaces, enums, inner classes, etc.)
Section 2: Inheritance & Polymorphism (Q16–30)
Q16. Given classes:
java
class Animal { public void sound() { System.out.print("Animal "); } }
class Dog extends Animal { public void sound() { System.out.print("Dog "); } }
What is output?
Animal a = new Dog(); a.sound();
A) Animal
B) Dog
C) Compilation error
D) Runtime error
Correct Answer: B
Rationale: Dynamic method dispatch – even though reference type is Animal, object type is
Dog, so overridden method in Dog executes.
Q17. Which of the following is true about super keyword?
A) Calls parent class constructor
B) Accesses parent class methods/variables hidden by subclass
C) Must be first statement in constructor
D) All of the above
Correct Answer: D
Rationale: super() calls parent constructor (must be first), super.method() calls overridden
parent method, super.var accesses hidden variable.
Q18–Q30 (Cover: instanceof, casting, abstract classes vs interfaces, multiple inheritance via
interfaces, diamond problem, etc.)
ACTUAL Exam Questions and Correct |
CSE 205 Final Exam (UPDATED)
Section 1: Object-Oriented Programming Fundamentals (Q1–15)
Q1. Which of the following best describes encapsulation?
A) Hiding implementation details and bundling data with methods
B) Allowing a class to inherit from multiple parents
C) Hiding methods from other classes using the private keyword only
D) Using interfaces to define behavior
Correct Answer: A
Rationale:
• A (Correct): Encapsulation is about bundling data (fields) and methods that operate
on that data into a single unit (class) and restricting direct access to some
components.
• B: This describes multiple inheritance, not encapsulation.
• C: Too narrow; encapsulation uses private, protected, and package-private.
• D: Interfaces relate to abstraction, not encapsulation per se.
Q2. Which access modifier allows access only within the same class?
A) public
B) protected
C) private
D) default (no modifier)
Correct Answer: C
Rationale:
• C (Correct): private members are accessible only inside the class they are declared.
• A: public → anywhere.
, • B: protected → same package + subclasses.
• D: default → same package only.
Q3–Q15 (Continue with similar style covering: constructors, this, static, method overloading,
overriding, super, polymorphism, abstraction, interfaces, enums, inner classes, etc.)
Section 2: Inheritance & Polymorphism (Q16–30)
Q16. Given classes:
java
class Animal { public void sound() { System.out.print("Animal "); } }
class Dog extends Animal { public void sound() { System.out.print("Dog "); } }
What is output?
Animal a = new Dog(); a.sound();
A) Animal
B) Dog
C) Compilation error
D) Runtime error
Correct Answer: B
Rationale: Dynamic method dispatch – even though reference type is Animal, object type is
Dog, so overridden method in Dog executes.
Q17. Which of the following is true about super keyword?
A) Calls parent class constructor
B) Accesses parent class methods/variables hidden by subclass
C) Must be first statement in constructor
D) All of the above
Correct Answer: D
Rationale: super() calls parent constructor (must be first), super.method() calls overridden
parent method, super.var accesses hidden variable.
Q18–Q30 (Cover: instanceof, casting, abstract classes vs interfaces, multiple inheritance via
interfaces, diamond problem, etc.)