cpp abstraction exercise

C++ Abstraction Exercise

1. Which class is used to design the base class ?

a. derived class.
b. abstract class
c. base class
d. derived & base class.

Show Answer

The correct option is (b)
Explanation:
Explanation: Abstract class is used to design base class because functions of abstract class can be overridden in derived class.

2. Which is also called as abstract class?

a. pure virtual function
b. derived class.
c. virtual function.
d. base class

Show Answer

The correct option is (a)
Explanation:
Classes that contain at least one pure virtual function are called as abstract base classes.

3. Class is _________ abstraction

a. Logical.
b. Real.
c. Hypothetical.
d. Object

Show Answer

The correct option is (a)
Explanation:
Class is logical abstraction because it provides a logical structure for all of its objects

4. Abstraction can apply to ____________ ?

a. Only data
b. Only methods
c. Control and data
d. Classes

Show Answer

The correct option is (c)
Explanation:
Abstraction applies to both. Control abstraction involves use of subroutines and control flow abstraction.

5. Which among the following is not a level of abstraction?

a. Physical level
b. View level
c. Logical level
d. External level

Show Answer

The correct option is (d)
Explanation:
Abstraction is generally divided into 3 different levels, namely, logical, physical and view level.

6. A class is made abstract by declaring at least one of its functions as?

a. impure virtual function.
b. pure abstract function.
c. impure abstract function
d. pure virtual function

Show Answer

The correct option is (b)
Explanation:
A class is made abstract by declaring at least one of its functions as pure virtual function

7. A pure virtual function is specified by placing?

a. -1
b. 0
c. 1
d. 2

Show Answer

The correct option is (b)
Explanation:
A pure virtual function is specified by placing “= 0” in its declaration

8. Classes that can be used to instantiate objects are called?

a. interface.
b. abstract class
c. concrete classes
d. None of the above

Show Answer

The correct option is (c)
Explanation:
Classes that can be used to instantiate objects are called concrete classes.

9. Which of the following is true?

a. The purpose of an abstract class is to provide an appropriate base class from which other classes can inherit.
b. Abstract classes cannot be used to instantiate objects and serves only as an interface
c. The C++ interfaces are implemented using abstract classes
d. All of the mentioned

Show Answer

The correct option is (d)
Explanation:
All the above mention is true

10. Where does the abstract class is used?

a. both derived & base class
b. derived class
c. base class only
d. virtual class

Show Answer

The correct option is (c)
Explanation:
As base class only as it helps in encapsulation of similar functioning of derived classes.

  • C++ Dynamic Initialization of Objects
  • C++ Copy Constructor
  • C++ Dynamic Constructor
  • C++ Destructors
  • C++ Exercise
  • C++ Operator Overloading
  • C++ Overloading Unary Operators
  • Const pointer in C
  • Void pointer in c
  • C++ Overloading Binary Operators
  • C++ Overloading Binary Operators Using Friends
  • C++ Manipulation String Using Operators
  • C++ Rules for overloading operators
  • C++ Exercise
  • C++ Basic To class Type
  • C++ Class TO Basic Type
  • C++ One class To another class type
  • C++ Exercise
  • C++ Inheritance introduction
  • C++ Single Inheritance
  • C++ Multiple Inheritance
  • C++ Ambiguity Resolution in inheritance
  • C++ Hierarchical Inheritance
  • C++ Hybrid Inheritance
  • C++ Virtual Base Classes
  • C++ Exercise
  • C++ abstract class
  • C++ nesting of classes
  • C++ Exercise
  • C++ polymorphism
  • C++ Exercise
  • C++ pointers
  • C++ Pointers TO object
  • C++ this pointer
  • C++ Pointer to Derived class
  • C++ Virtual functions
  • C++ Exercise
  • C++ streams
  • C++ unformatted I/O operations
  • C++ Put() and get()
  • C++ getline() and write()
  • C++ Formatted console I/O
  • C++ Manipulators
  • C++ Exercise
  • C++ file handling
  • C++ file stream classes
  • C++ Open and closing file
  • C++ open using constructor
  • C++ open using open()
  • C++ Detecting End of file
  • C++ File modes
  • C++ File pointers and Manipulators
  • C++ Sequential I/O
  • C++ Reading and Writing
  • C++ Updating a File
  • C++ Error handling In File
  • C++ Command Line Arguments
  • C++ Exercise
  • C++ Template introduction
  • C++ Class Templates with multiple Parameters
  • C++ Function templates
  • C++ Function templates with multiple parameters
  • C++ member function Template
  • C++ Exercise
  • C++ Exception handling
  • C++ Basics of Exception Handling
  • C++ Exception Handling Mechanism
  • C++ Throwing Mechanism
  • C++ Catch Mechanism
  • C++ Catch all Exceptions
  • C++ Re-Throwing An Exception
  • C++ Specifying Exceptions
  • C++ Exercise