Multiple choice questions on polymorphism in c++
Ngày đăng:
16/12/2022
Trả lời:
0
Lượt xem:
50
Show Read Also: OOPs Interview Questions and Answers Polymorphism Online Quiz - Multiple Choice Questions and Answers (MCQ)1. How Polymorphism is achieved in Javaa. Overloading b. Overriding c. Static Function d. Final Class The correct answers are A and B. 2. Which statements are true a. Overriding can be achieved with static methods b. Final marked methods can be overridden c. Overloading is runtime. d. Return type can change in case of Overloading. The correct answer is D. 3. Which statements are true a. Parent class method method1 return type is Class A and child class of Parent class overrides the method method1 and can change the return type from Class A to Class B (B is the subclass of A) b. Child class can use covariant return types in case of method overriding. c. Covariant return types can be used in case of method overloading d. Method parameters sequence can change in overriding. The correct answers are A, B, and C. 4. Output of this program is : a. Prints 2. Addition of two numbers: 50 b. Prints 1. Addition of two numbers: 50 c. Compile time error d. Runtime error The correct answer is C. 5. Output of this program is : a. Two One b. One Two c. Compile time error d. Runtime error The correct answer is B. 6. Which statements are true a. In case of overloading, binding of objects with methods happens at runtime. b. In the case of Dynamic polymorphism, method behavior is decided at runtime. c. In the case of Overriding, the creation of objects happen at compile time and these objects are used for calling objects at runtime. d. In the case of Overriding, it is the responsibility of the compiler to bind the method calls with the method body. The correct answer is B. 7. Which statements are true a. Overriding can only be achieved when there is a has-a relationship b. Data members can be used in Polymorphism c. In case of overloading, it's the responsibility of the compiler to bind the method calls with the method body based on method signatures. d. Constructor overloading is static Polymorphism The correct answers are C and D. 8. Output of this program is : a. Output is : Two, One a. Output is : One, Two c. Compile time error d Runtime error The correct answer is A. 9. Which statements are true a. There are 3 types of binding in java early(Overloading), intermediate(methods which are neither overloaded nor overridden), late(Overriding) b. Performance of early binding is better compared to late binding c. Private methods always fall in the early binding category. d. Static method falls in the dynamic binding category The correct answers are B and C. 10. Which statements are true a. Parent p = new Child();//upcasting declaration b. Child c = new Parent();// downcasting declaration c. List d. List The correct answers are A and C. 11. Which statements are true a. We can override Constructors b. We can override static methods c. We can overload abstract methods d. We can overload final methods The correct answers are C and D. 12. Which statements are true a. Same method names and same method signature is called Overriding b. Same method names and same method signature just changing the return type is called Overloading c. Method signature includes return type, number of arguments, arguments type, and arguments sequence only and nothing else d. Unchecked exceptions are part of the method signature The correct answer is A. That's all for today. Please mention in the comments if you have faced any other Polymorphism online quiz MCQ question that needs to be added to the above list. What is polymorphism in Mcq?Explanation: It is actually the ability for a message / data to be processed in more than one form. The word polymorphism indicates many-forms. So if a single entity takes more than one form, it is known as polymorphism. 2.
How many types of polymorphism are there Mcq?Explanation: There are two types of polymorphism in C++ namely run-time and compile-time polymorphisms.
What is polymorphism in C ==?The word polymorphism means having many forms. Typically, polymorphism occurs when there is a hierarchy of classes and they are related by inheritance. C++ polymorphism means that a call to a member function will cause a different function to be executed depending on the type of object that invokes the function.
Which statement is incorrect for polymorphism Mcq?1 Answer. For explanation: It never increases function definition overhead, one way or another if you don't use polymorphism, you will use the definition in some other way, so it actually helps to write efficient codes.
|