CS 151 EXAM QUESTIONS AND
ANSWERS. VERIFIED 2025/2026.
The criteria for testing an app is its functional spec - ANS True
Superclass and subclass can declare attributes with the same name but thats a bad idea -
ANS True
Architectural design patterns are the second level of abstraction - ANS False
In Java Exception hierarchy, the subclasses of "Throwable" class are "Exception" and "Error:
classes - ANS True
Pick all that we get from obeying "Open-Closed Principle"
A) More efficient application
B) Decreasing the cost of app's maintenance
C) Higher possibility to cope with change and complexity
D) Increasing the complexity of the code - ANS B, C
What do we learn from "Interface Segregation Principle (ISP)" ?
1 @COPYRIGHT 2025/2026 ALLRIGHTS RESERVED.
, A) the role of segregation in inheritance
B) some inheritances are not polymorphic
C) the role of precondition in inheritance
D) interfaces should not be too big - ANS D
Class B inherits from class A, and both define their own preconditions.
If we want to use them in a polymorphic relationship, which of the following is correct?
A) Preconditions of class A must be either stronger than or equal to the preconditions of class B.
B) Preconditions of class A must be either weaker than or equal to the preconditions of class B.
C) Preconditions of class A must be equal to preconditions of class B.
D) Preconditions of class A must be weaker than preconditions of class B. - ANS A
Pick all true statements about "Singleton design pattern".
A) Only one instance of the class can exist.
B) It decreases dependency between classes.
C) None is correct.
D) This is a "creational" design pattern. - ANS A, D
What do we learn from "Liskov Substitution Principle (LSP)" ?
A) Interfaces should not be too big.
B) We should pick preconditions and postconditions carefully if we want to use an inheritance in
a polymorphic relationship.
2 @COPYRIGHT 2025/2026 ALLRIGHTS RESERVED.
ANSWERS. VERIFIED 2025/2026.
The criteria for testing an app is its functional spec - ANS True
Superclass and subclass can declare attributes with the same name but thats a bad idea -
ANS True
Architectural design patterns are the second level of abstraction - ANS False
In Java Exception hierarchy, the subclasses of "Throwable" class are "Exception" and "Error:
classes - ANS True
Pick all that we get from obeying "Open-Closed Principle"
A) More efficient application
B) Decreasing the cost of app's maintenance
C) Higher possibility to cope with change and complexity
D) Increasing the complexity of the code - ANS B, C
What do we learn from "Interface Segregation Principle (ISP)" ?
1 @COPYRIGHT 2025/2026 ALLRIGHTS RESERVED.
, A) the role of segregation in inheritance
B) some inheritances are not polymorphic
C) the role of precondition in inheritance
D) interfaces should not be too big - ANS D
Class B inherits from class A, and both define their own preconditions.
If we want to use them in a polymorphic relationship, which of the following is correct?
A) Preconditions of class A must be either stronger than or equal to the preconditions of class B.
B) Preconditions of class A must be either weaker than or equal to the preconditions of class B.
C) Preconditions of class A must be equal to preconditions of class B.
D) Preconditions of class A must be weaker than preconditions of class B. - ANS A
Pick all true statements about "Singleton design pattern".
A) Only one instance of the class can exist.
B) It decreases dependency between classes.
C) None is correct.
D) This is a "creational" design pattern. - ANS A, D
What do we learn from "Liskov Substitution Principle (LSP)" ?
A) Interfaces should not be too big.
B) We should pick preconditions and postconditions carefully if we want to use an inheritance in
a polymorphic relationship.
2 @COPYRIGHT 2025/2026 ALLRIGHTS RESERVED.