Inheritance Flashcards

1
Q

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

A

Correct Answer: B

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q
A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

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

A

Correct Answer: B

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

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

A

Correct Answer: A

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What keyword is used to declare an abstract method?

A) virtual
B) override
C) abstract
D) protected

A

Correct Answer: C

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What does an abstract method NOT include?

A) Method signature
B) Access modifiers
C) Code implementation
D) Parameters

A

Correct Answer: C

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

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

A

Correct Answer: B

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

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

A

Correct Answer: C

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

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

A

Correct Answer: B

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

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

A

Correct Answer: B

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

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

A

Correct Answer: C

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Which of the following cannot be included in an interface?

A) Method declarations
B) Field variables
C) Event declarations
D) Property declarations

A

Correct Answer: B

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

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

A

Correct Answer: B

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What level of abstraction does an interface provide?

A) Partial abstraction
B) No abstraction
C) Full abstraction
D) Limited abstraction

A

Correct Answer: C

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

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

A

Correct Answer: A

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What member types can an abstract class include that an interface cannot?

A) Events
B) Properties
C) Field variables
D) Method declarations

A

Correct Answer: C

17
Q

How many interfaces can a class implement in C#?

A) Only one
B) Up to five
C) Unlimited number
D) None, as C# does not support interfaces

A

Correct Answer: C

18
Q

What can an abstract class in C# include that an interface cannot?

A) Public method declarations
B) Method implementations
C) Event declarations
D) Property declarations

A

Correct Answer: B

19
Q

Which access modifiers are allowed in an abstract class?

A) Only public and private
B) All standard access modifiers like public, protected, etc.
C) None
D) Only protected and internal

A

Correct Answer: B

20
Q

In what way is an interface similar to a contract?

A) It specifies methods that must be implemented by any class using the interface
B) It provides default method implementations
C) It restricts method access based on access modifiers
D) It allows inheritance from multiple classes

A

Correct Answer: A

20
Q

Which keyword cannot be used with interface members in C#?

A) public
B) private
C) abstract
D) static

A

Correct Answer: B

21
Q

Why is an abstract class considered a partial abstraction?

A) It does not allow method implementation
B) It can have both implemented and unimplemented methods
C) It only includes abstract methods
D) It cannot be inherited

A

Correct Answer: B

22
Q

Which of the following statements about interfaces is true?

A) They can inherit from multiple classes
B) They provide method implementation
C) They only define method signatures
D) They are instantiated directly

A

Correct Answer: C

23
Q

What is the purpose of abstract methods in an abstract class?

A) To provide full implementation of a method
B) To define required methods that subclasses must implement
C) To prevent method overriding
D) To allow multiple instances of the abstract class

A

Correct Answer: B

24
Q

Which of these relationships is an example of an association in object design?

A) A library and its books where each book belongs to one library
B) A teacher and student where each can exist independently
C) A house and its rooms where rooms cannot exist independently
D) A car and its wheels where wheels cannot exist independently

A

Correct Answer: B

25
Q

How does the structure of a hierarchy differ from a graph in object-oriented design?

A) A hierarchy has flexible connections; a graph has a strict structure
B) A hierarchy has clear parent-child relationships; a graph has flexible, unrestricted connections
C) Both have unrestricted, flexible connections
D) Both have strictly enforced parent-child relationships

A

Correct Answer: B