Skip to main content

Abstraction

1).What is abstraction in C++?

1) Hiding implementation details
2) Separating data from methods
3) Providing access to all data members
4) None of the above

2).Which type of class supports abstraction?

1) Abstract class
2) Derived class
3) Friend class
4) None of the above

3).Which keyword is used to declare an abstract class?

1) virtual
2) abstract
3) pure
4) None of the above

4).What is the difference between abstraction and encapsulation?

1) Abstraction focuses on design, encapsulation focuses on implementation
2) Encapsulation hides data, abstraction hides implementation
3) Both A and B
4) None of the above

5).What is a pure virtual function?

1) A function with no implementation
2) A function with default implementation
3) A function that initializes data members
4) None of the above

6).Can an abstract class have a constructor?

1) Yes
2) No
3) Only for derived classes
4) None of the above

7).What happens when you try to instantiate an abstract class?

1) Compiler error
2) A default object is created
3) The derived class is instantiated
4) None of the above

8).Why are abstract classes used in C++?

1) To provide a base for derived classes
2) To create objects directly
3) To ensure data hiding
4) None of the above

9).Can an abstract class have non-pure virtual functions?

1) Yes
2) No
3) Only in derived classes
4) None of the above

10).Which of the following is an example of abstraction in C++?

1) Using interfaces
2) Using private members
3) Using inline functions
4) None of the above