Difficulty: Medium
Correct Answer: 3
Explanation:
Introduction / Context:
In object oriented design with C plus plus, developers often categorise classes into broad kinds based on their role and capabilities. A useful teaching model groups classes into concrete classes, abstract classes, and template classes. This question asks you to recall how many broad kinds there are in that simple classification and is designed to check whether you are familiar with this way of thinking about class design.
Given Data / Assumptions:
Concept / Approach:
Concrete classes are classes for which objects can be instantiated directly. Abstract classes are classes that contain at least one pure virtual function and are meant to be used as base classes. Template classes, also known as class templates, are parameterised by types and allow generic programming. In this simplified model, these three categories cover the most important ways that C plus plus developers design classes.
Step-by-Step Solution:
Step 1: Identify the first category, concrete classes, which represent standard classes with full implementations.
Step 2: Identify the second category, abstract classes, which declare pure virtual functions and cannot be instantiated directly.
Step 3: Identify the third category, template classes, which use template parameters to create generic class definitions.
Step 4: Count these categories and see that there are three broad kinds in this classification.
Step 5: Select the option that matches this count, which is three.
Verification / Alternative check:
You can verify this by recalling examples from real projects. A simple class such as Point with x and y coordinates is a concrete class. An interface like Shape that declares a pure virtual draw method is an abstract class. A class template such as vector in the standard library is a template class. These examples show the three categories clearly and confirm the count.
Why Other Options Are Wrong:
Option A: Suggests there is only one kind of class, which ignores both abstraction and templates.
Option B: Claims there are two kinds, which is insufficient to include concrete, abstract, and template classes together.
Option D: States that there are four kinds without providing a consistent standard fourth category in this simplified model.
Common Pitfalls:
One pitfall is to mix different classification schemes, such as classifying by access control or by design pattern, and then becoming confused about the count. Another mistake is to assume that every style of class design must have a separate category. For exam purposes, it is enough to remember that a simple and practical grouping into concrete, abstract, and template classes yields three broad kinds.
Final Answer:
In this basic C plus plus classification, there are 3 broad kinds of classes: concrete, abstract, and template classes.
Discussion & Comments