cpp polymorphism exercise

C++ Polymorphism Exercise

1. What do you call the languages that support the classes but not polymorphism?

a. Procedure Oriented language.
b. Object-based language
c. If classes are supported, polymorphism will always be supported
d. Object-based language

Show Answer

The correct option is (d)
Explanation:
Explanation:The languages which support classes but doesn’t support polymorphism, are known as object-based languages. Polymorphism is such an important feature, that is a language doesn’t support this feature, it can’t be called as a OOP language.

2. Which of the following is the language which supports the classes but not polymorphism?

a. Java
b. C++
c. Ada.
d. SmallTalk

Show Answer

The correct option is (c)
Explanation:
Ada is the language which supports the concept of the classes but doesn’t support the polymorphism feature. It is an object-based programming language. Note that it is not an OOP language..

3. Which type of function among the following shows polymorphism?

a. Class member functions.
b. Inline function.
c. Undefined functions.
d. Virtual function

Show Answer

The correct option is (d)
Explanation:
Only virtual functions among these can show polymorphism.

4. Which among the following can’t be used for polymorphism?

a. Member functions overloading
b. Predefined operator overloading
c. Constructor overloading
d. Static member functions

Show Answer

The correct option is (d)
Explanation:
Static member functions are not property of any object.

5. Compile time polymorphism in C++ programming are ?

a. Function overloading
b. Operator overloading
c. Function overriding
d. a & b

Show Answer

The correct option is (d)
Explanation:
No Explanation

6. C++ abstract class can contain ?

a. Only pure virtual function
b. Non-virtual function.
c. Both pure virtual and non-virtual function
d. Pure virtual function

Show Answer

The correct option is (c)
Explanation:
No Explanation

7. Which of the following cannot be overloaded in C++?

a. Constructor
b. Destructor
c. New and delete operator
d. Increment operator

Show Answer

The correct option is (b)
Explanation:
No Explanation

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