Inheritance Flashcards
What is an abstract class?
A) A class with no methods
B) A class with at least one abstract method, intended as a base class
C) A fully implemented class with complete methods
D) A class that can be instantiated directly
Correct Answer: B
Why can’t you instantiate an abstract class?
A) It is fully defined and meant for creating objects
B) It is incomplete and meant only to provide a base for other classes
C) It has private constructors
D) It lacks access modifiers
Correct Answer: B
What is required for a class to be considered abstract?
A) It must have at least one abstract method
B) It must be instantiated directly
C) It must inherit another class
D) It must not contain any methods
Correct Answer: A
What keyword is used to declare an abstract method?
A) virtual
B) override
C) abstract
D) protected
Correct Answer: C
What does an abstract method NOT include?
A) Method signature
B) Access modifiers
C) Code implementation
D) Parameters
Correct Answer: C
What is the purpose of an abstract class in object-oriented programming?
A) To define exact details for all subclasses
B) To provide a common blueprint that subclasses can implement
C) To avoid inheritance
D) To allow for multiple instantiation
Correct Answer: B
Where are abstract classes typically found in a class hierarchy?
A) At the bottom level
B) Only in middle levels
C) Often at the top as base classes
D) Only as interfaces
Correct Answer: C
In terms of hierarchy, what does aggregation resemble?
A) A linear structure
B) A tree with parent-child relationships
C) A graph with flexible connections
D) A single path structure
Correct Answer: B
Which of the following best describes a graph in object organization?
A) A strict parent-child relationship
B) Connections where objects link freely without a set structure
C) A hierarchy where each object has only one parent
D) A single top-level parent and multiple children
Correct Answer: B
What is an interface?
A) A class with private fields
B) A structure providing complete code for subclasses
C) A contract specifying required methods and properties
D) A type of static class
Correct Answer: C
Which of the following cannot be included in an interface?
A) Method declarations
B) Field variables
C) Event declarations
D) Property declarations
Correct Answer: B
What is true about the members of an interface?
A) They can have private access modifiers
B) They are all public by default
C) They can contain member variables
D) They include full implementations
Correct Answer: B
What level of abstraction does an interface provide?
A) Partial abstraction
B) No abstraction
C) Full abstraction
D) Limited abstraction
Correct Answer: C
Which of the following best describes multiple inheritance in C#?
A) Only interfaces support multiple inheritance
B) Both abstract classes and interfaces support it
C) Only abstract classes support it
D) It is not possible with either
Correct Answer: A