Polymorphism and abstract function - placement practice test

Polymorphism and abstract function - placement practice test


1. We can create objects of the abstract class.

a. True
b. False
View Answer / Hide Answer

ANSWER: b. False
Explanation: Objects of abstract class never be created. It is just used as a base class to be derived by other classes.




2. Run time polymorphism can be achieved with______

a. Virtual Base class
b. Container class
c. Virtual function
d. Both a and c
View Answer / Hide Answer

ANSWER: c. Virtual function




3. ________________ is a member function that is declared within a base class and redefined by derived class.

a. virtual function
b. static function
c. friend function
d. const member function
View Answer / Hide Answer

ANSWER: a. virtual function




4. Runtime polymorphism is achieved only when a virtual function is accessed through a pointer to the base class.

a. True
b. False
View Answer / Hide Answer

ANSWER: a. True




5. When a virtual function is redefined by the derived class, it is called___________

a. Overloading
b. Overriding
c. Rewriting
d. All of these
View Answer / Hide Answer

ANSWER: b. Overriding




6. Which of the followings are true about Virtual functions?

a. They must be non-static member function of the class
b. They cannot be friends
c. Constructor Functions cannot be virtual
d. All of these
View Answer / Hide Answer

ANSWER: d. All of these




7. While redefining a virtual function in the derived class, if its prototype is changed then___________________

a. It will be overloaded by the compiler
b. Its virtual nature will be lost
c. both a and b
d. Compiler will generate “Prototype mismatch error”
View Answer / Hide Answer

ANSWER: c. both a and b




8. If a class contains pure virtual function, then it is termed as_____________________

a. Virtual class
b. Sealed class
c. Pure Local class
d. Abstract Class
View Answer / Hide Answer

ANSWER: d. Abstract Class




9. Syntax for Pure Virtual Function is______________

a. virtual void show()==0
b. void virtual show()==0
c. virtual void show()=0
d. void virtual show()=0
View Answer / Hide Answer

ANSWER: c. virtual void show()=0




10. If abstract class is inherited by derived class, then_______________

a. Derived class should provide definition for all the pure virtual functions
b. Derived class also become abstract if fails to implement pure virtual functions
c. Objects of derived class can’t be created if it fails to implement pure virtual functions
d. All of these
View Answer / Hide Answer

ANSWER: d. All of these




11. A virtual function that has no definition within the base class is called____________

a. Pure virtual function
b. Pure static function
c. Pure Const function
d. Friend function
View Answer / Hide Answer

ANSWER: a. Pure virtual function




12. Find the wrong statement/s about Abstract Class.

a. We can’t create its objects
b. We can’t create pointers to an abstract class
c. It contains at least one pure virtual function
d. We can create references to an abstract class
View Answer / Hide Answer

ANSWER: b. We can’t create pointers to an abstract class



Post your comment

    Discussion

  • RE: Polymorphism and abstract function - placement practice test -Minh Khuu (08/14/14)
  • my mistake the correct answer is c
  • RE: Polymorphism and abstract function - placement practice test -Minh Khuu (08/14/14)
  • #9 answer should be a not c