PRACTICE • LEARN • GROW
Module 6 Final Quiz: Abstract Classes, Interfaces & Relationships MCQs
Solve topic-wise placement questions and improve your skills.
Module 6 Final Quiz: Abstract Classes, Interfaces & Relationships Progress
0 of 11 completed
0%
Topic Track
You are viewing MCQs in preview mode. Log in to select options, submit answers, and track your progress.
Log In to Answer
1
Which of the following can an Abstract Class have that a traditional Interface CANNOT?
A.
Abstract method declarations
B.
Constructors, instance variables (state), and protected members
C.
Public methods
D.
Subclasses
Explanation & Key
Correct Answer:
2
What type of relationship exists between 'Department' and 'Professor' where professors survive if the department closes?
A.
Composition
B.
Aggregation (Weak Has-A)
C.
Inheritance (Is-A)
D.
Generalization
Explanation & Key
Correct Answer:
3
What type of relationship exists between 'House' and 'Room' where rooms cannot exist without the house?
A.
Loose Association
B.
Composition (Strong Has-A)
C.
Multiple Inheritance
D.
Weak Aggregation
Explanation & Key
Correct Answer:
4
In UML class diagrams, how is Composition distinguished from Aggregation?
A.
Composition uses a dashed line; Aggregation uses a double line
B.
Composition uses a solid filled diamond; Aggregation uses a hollow/empty diamond
C.
Composition uses a circle; Aggregation uses a square
D.
Composition has an arrow; Aggregation has no arrow
Explanation & Key
Correct Answer:
5
How does a class implement multiple behaviors in Java if multiple class inheritance is disallowed?
A.
By using multiple catch blocks
B.
By implementing multiple Interfaces (e.g. 'implements Serializable, Cloneable, Runnable')
C.
By defining multiple main() methods
D.
It cannot be done in Java
Explanation & Key
Correct Answer:
6
What is a Marker Interface in Java?
A.
An interface with exactly 100 methods
B.
An interface with zero methods and zero constants, used to tag a class for runtime JVM behavior (e.g. Serializable, Cloneable)
C.
An interface used only for drawing UI graphics
D.
A deprecated class
Explanation & Key
Correct Answer:
7
What is a Functional Interface in modern Java (Java 8+)?
A.
An interface with no methods
B.
An interface that contains exactly one abstract method, suitable for lambda expressions
C.
An interface that only contains static methods
D.
An interface that cannot be implemented
Explanation & Key
Correct Answer:
8
In C++, what makes a class abstract?
A.
Declaring the class with the 'abstract' keyword
B.
Declaring at least one pure virtual function (e.g. 'virtual void draw() = 0;')
C.
Removing all constructors
D.
Inheriting from std::exception
Explanation & Key
Correct Answer:
9
Which relationship is modeled when a method accepts an object as a local parameter and invokes a method on it (Uses-A)?
A.
Association / Dependency
B.
Inheritance
C.
Composition
D.
Aggregation
Explanation & Key
Correct Answer:
10
Why should developers favor Composition over Inheritance according to GoF design principles?
A.
Composition runs faster on older CPUs
B.
Composition provides loose coupling, allows dynamic runtime behavior swapping, and avoids fragile base class issues
C.
Inheritance requires more lines of code
D.
Composition prevents garbage collection
Explanation & Key
Correct Answer:
11
Can an interface extend another interface?
A.
No, interfaces can only be implemented by classes
B.
Yes, an interface can extend one or more other interfaces using the 'extends' keyword
C.
Only in C#
D.
Only if both interfaces have no methods
Explanation & Key
Correct Answer:
Question Palette
Answered
Current
Not Attempted
Wrong