CSE 205 Final UPDATED ACTUAL Exam
Questions and Correct|
CSE 205 Final Exam
Actual Exam Practice Questions (90+ Verified Questions)
Question 1: Which of the following could be used to instantiate a new Student object
named s1?
a) new Student(s1);
b) new Student s1 = ("Jane Doe", "Computer Science", 3.333, 33);
c) Student s1 = new Student("Jane Doe", "Computer Science", 3.333, 33);
d) Student s1 = new Student( );
Correct Answer: c) Student s1 = new Student("Jane Doe", "Computer Science", 3.333, 33);
Rationale: In Java, object instantiation requires the new keyword followed by a call to the
class constructor. Option c correctly declares a variable of type Student and assigns it a new
object using a valid constructor. Option a incorrectly passes an object as a parameter to the
constructor; options b and d have syntax errors regarding type declaration and instantiation.
Question 2: Consider a method defined with the header: public void foo(int a, int b). Which
of the following method calls is legal?
a) foo(, 2 * 3);
b) foo(0, 0.1);
c) foo(0);
d) foo(1 + 2, 3 * 0.1);
Correct Answer: a) foo(, 2 * 3);
Rationale: The method expects two integer arguments. Option a evaluates 0/1 (which is 0)
and 2*3 (which is 6), both of which are integers. Options b and d attempt to pass a double
(0.1) to an int parameter. Option c provides only one argument.
Question 3: What is the superclass of every class in Java?
a) Main
b) String
, c) Object
d) Class
Correct Answer: c) Object
Rationale: The Java class hierarchy is rooted at the java.lang.Object class. Every class in Java,
whether explicitly stated or not, directly or indirectly extends the Object class.
Question 4: A variable declared to be of one class type can later reference an object of a
subclass of that class. This is known as a:
a) Protected variable
b) Cloneable variable
c) Polymorphic variable
d) Derivative variable
Correct Answer: c) Polymorphic variable
Rationale: Polymorphism allows a variable of a superclass type to hold a reference to an
object of any of its subclasses. This enables dynamic method dispatch, where the specific
method executed is determined at runtime based on the actual object type, not the variable
type.
Question 5: Which of the following statements is completely true regarding abstract
classes?
a) If a class is declared abstract, all methods in it must be abstract.
b) If a class is declared abstract, all instance variables must be overridden in a concrete
subclass.
c) If a class is declared abstract, some methods in the class may have their bodies omitted.
d) If a class is declared abstract, it cannot have any concrete methods.
Correct Answer: c) If a class is declared abstract, some methods in the class may have their
bodies omitted.
Rationale: An abstract class is a class that cannot be instantiated. It can contain a mix of
abstract methods (without a body) and concrete methods (with a body). Abstract methods
are intended to be implemented by non-abstract subclasses.
Question 6: In order for a class to use an interface, the class must use the keyword:
a) extends
b) inherits
c) implements
d) realizes
Correct Answer: c) implements
Rationale: In Java, the implements keyword is used by a class to indicate that it is providing
concrete implementations for all abstract methods declared in the specified interface. A
class can implement multiple interfaces.
Questions and Correct|
CSE 205 Final Exam
Actual Exam Practice Questions (90+ Verified Questions)
Question 1: Which of the following could be used to instantiate a new Student object
named s1?
a) new Student(s1);
b) new Student s1 = ("Jane Doe", "Computer Science", 3.333, 33);
c) Student s1 = new Student("Jane Doe", "Computer Science", 3.333, 33);
d) Student s1 = new Student( );
Correct Answer: c) Student s1 = new Student("Jane Doe", "Computer Science", 3.333, 33);
Rationale: In Java, object instantiation requires the new keyword followed by a call to the
class constructor. Option c correctly declares a variable of type Student and assigns it a new
object using a valid constructor. Option a incorrectly passes an object as a parameter to the
constructor; options b and d have syntax errors regarding type declaration and instantiation.
Question 2: Consider a method defined with the header: public void foo(int a, int b). Which
of the following method calls is legal?
a) foo(, 2 * 3);
b) foo(0, 0.1);
c) foo(0);
d) foo(1 + 2, 3 * 0.1);
Correct Answer: a) foo(, 2 * 3);
Rationale: The method expects two integer arguments. Option a evaluates 0/1 (which is 0)
and 2*3 (which is 6), both of which are integers. Options b and d attempt to pass a double
(0.1) to an int parameter. Option c provides only one argument.
Question 3: What is the superclass of every class in Java?
a) Main
b) String
, c) Object
d) Class
Correct Answer: c) Object
Rationale: The Java class hierarchy is rooted at the java.lang.Object class. Every class in Java,
whether explicitly stated or not, directly or indirectly extends the Object class.
Question 4: A variable declared to be of one class type can later reference an object of a
subclass of that class. This is known as a:
a) Protected variable
b) Cloneable variable
c) Polymorphic variable
d) Derivative variable
Correct Answer: c) Polymorphic variable
Rationale: Polymorphism allows a variable of a superclass type to hold a reference to an
object of any of its subclasses. This enables dynamic method dispatch, where the specific
method executed is determined at runtime based on the actual object type, not the variable
type.
Question 5: Which of the following statements is completely true regarding abstract
classes?
a) If a class is declared abstract, all methods in it must be abstract.
b) If a class is declared abstract, all instance variables must be overridden in a concrete
subclass.
c) If a class is declared abstract, some methods in the class may have their bodies omitted.
d) If a class is declared abstract, it cannot have any concrete methods.
Correct Answer: c) If a class is declared abstract, some methods in the class may have their
bodies omitted.
Rationale: An abstract class is a class that cannot be instantiated. It can contain a mix of
abstract methods (without a body) and concrete methods (with a body). Abstract methods
are intended to be implemented by non-abstract subclasses.
Question 6: In order for a class to use an interface, the class must use the keyword:
a) extends
b) inherits
c) implements
d) realizes
Correct Answer: c) implements
Rationale: In Java, the implements keyword is used by a class to indicate that it is providing
concrete implementations for all abstract methods declared in the specified interface. A
class can implement multiple interfaces.