Polymorphism can be static or dynamic. The following example shows using function print() to print different data types , When the above code is compiled and executed, it produces the following result . b) Operator functions Note: Even though the class Two_values is a general purpose container that can store any data, method custom_add() limits its use. a) I only Only base class function will get called irrespective of object. All Rights Reserved. Such determination happens via different methods at different time. Which of the following provides a reuse mechanism? View Answer, 7. Which concept is used to implement late binding?

Which concept means the addition of new components to a program as it runs? Which of the following is correct?

b) Member functions This set of C++ Programming Objective Questions & Answers focuses on OOPs Concept 3. c) Constant functions d) All of the mentioned It is necessary to initialize static data. Which statement is true about a static nested class? What is the other name used for functions inside a class? 4. d) An object is an instance of the data type of the class Which of the following is not a type of inheritance? Which of the following is a mechanism of static polymorphism? b) II only Wrapping data and its related functionality into a single entity is known as _____________. Reading the third function call custom_add( int , float ), compiler tries to substitute T with int which leads to custom_add ( int , int ) and with float resulting in custom_add ( float , float ) none of which is a match to an original call. c) It decreases the compilation time View Answer, 14. Operator overloading, Function overloading, and Templates are the mechanisms of static polymorphism. The derived classes have more specialized functionality. View Answer, 15. View Answer, 12. b) Multilevel c) Distributive Compiler reports an error on compilation. Calling function custom_add(c, r) with int c and float r is ambiguous and will result in compile time error. Why references are different from pointers? Which of the following is not a type of inheritance? Which of the following cannot be used with the virtual keyword? They both provide polymorphic behavior during compilation process, both are useful, and both should be in your toolbox. However, calling custom_add(p, e) with int p and float e will cause a compile time error. d) Structure members are private by default c) Both I and II Here are the rules about abstract classes , You cannot create an instance of an abstract class, You cannot declare an abstract method outside an abstract class. Which concept is used to implement late binding? However, you are free to pick the one that either is agreed upon in your working environment or makes more sense to you. b) << Which of the following cannot be used with the keyword. Out of the following, which is not a member of the class? Point to remember: each time you leave something for compiler to deduce make sure there is no room for ambiguity left. In this case, type of input value will be neglected which sometimes can lead to nasty hard-to-debug errors. The same function name has many definitions in the same scope due to function overloading. However, the term polymorphism is used to characterize both compile-time and run-time type so often, that it is hard to avoid describing one or another. Function custom_add() from a previous example works perfectly for adding two numerical values, but adding two chars and getting numerical result makes little sense in given context.

Only derived class function will get called irrespective of object.

Instance functions can call static functions and access static data.

d) It will neither have a constructor or destructor b) It will not have a destructor b) II only Types, Pointers, Arrays & Structures in C++, Functions, Namespaces & Exceptions in C++, Source Files, Classes & Operator Overloading in C++, Derived Classes, Templates & Exception Handling in C++, here is complete set of 1000+ Multiple Choice Questions and Answers, Prev - C++ Programming Questions and Answers OOPs Concept 2, Next - C++ Programming Questions and Answers OOPs Concept 4, C++ Programming Questions and Answers OOPs Concept 4, C++ Programming Questions and Answers OOPs Concept 2, C++ Programming Questions and Answers OOPs Concept 1, Object Oriented Programming using C++ Questions and Answers OOPs Features, C++ Programming Questions and Answers Operator Overloading 1, Object Oriented Programming using C++ Questions and Answers Member Operator Function, C++ Programming Questions and Answers Operator Functions, C++ Programming Questions and Answers Function Call, C++ Programming Questions and Answers Operator Overloading 2, C++ Programming Questions and Answers Functors, Object Oriented Programming MCQ Questions, Dynamic Programming Problems and Solutions. Instead of creating several classes (each for each data type) you can easily apply the previous approach of creating generalized code using a class template. d) Hierarchical 1. Which of the following is not a type of Constructor? (Press Ctrl+g to toggle between English and the chosen language), Question Answer in malayalam-kerala-psc-questions, Multiple Choice Question in malayalam-kerala-psc-questions, Question Answer in kerala-psc-questions-in-malayalam, Multiple Choice Question in kerala-psc-questions-in-malayalam, Question Answer in India-general-knowledge-in-malayalam, Multiple Choice Question in mechanical-engineering-machine-design, Question Answer in kerala-general-knowledge-in-malayalam, Multiple Choice Question in java-programming-inner-classes, Multiple Choice Question in aptitude-surds-and-indices, Multiple Choice Question in current-affairs-2017-01-04, Multiple Choice Question in electronics-capacitors, Multiple Choice Question in electrical-engineering-series-parallel-circuits. Compilers responsibility is to generate code for different input types based on instructions you gave. All rights reserved. The HAVING clause does which of the following? Which of the following is correct about the statements given below? 5. Which of the following class allows to declare only one object of it? How compile-time polymorphisms are implemented in C++? Which operator is overloaded for a cout object? Implementation is completed when a derived class inherits from it. 1.

b) It reduces maintenance cost Correct choice is (d) All of the mentioned. The mechanism of linking a function with an object during compile time is called early binding. Setting up a development environment for Egeria on a Windows machine, Positive feedback as a tool of influence (in a team), The annoying part of APIs with associative arrays, Seeking successful IT projects? You cannot overload function declarations that differ only by return type. View Answer, 13. Learn more. d) Both private and protected c) Protected Electronics and Communication Engineering. a) >> Which of the following explains the overloading of functions? Abstract classes contain abstract methods, which are implemented by the derived class. In static polymorphism, the response to a function is determined at the compile time. In this case, compiler can not decide on which one to use and reports the issue. Static functions can access only static data. By using this website, you agree with our Cookies Policy. Now the idea of polymorphism starts to emerge: you are using the same interface (the same function name) to work with objects of different types. Doing so does not affect operators in generalyou just add yet another definition of the operator to the pool. Which of the following is correct in C++? Which of the following are available only in the class hierarchy chain? View Answer, 10. Which of the following cannot be used with the virtual keyword? Note, our program has two potential candidates, custom_add( float , float ) and custom_add( int , int ) with both functions equally fulfilling (or not fulfilling) the purpose. It might look like you are using the same + sign over and over again although the compiler deduces arguments types, decides which definition of + operator suits best, and puts the chosen version of operator in your code. In dynamic polymorphism, it is decided at run-time. Which of the following is true? Which of the following term is used for a function defined inside a class? and also has a short definition of polymorphic class: A class that declares or inherits a virtual function is called a polymorphic class. As a general rule of thumb, use: Love podcasts or audiobooks? - Check GATE Apply Online Link, Dates & Procedure, GATE 2023 Admit Card Download - Release Date And Download Link, PSU Recruitment Through GATE 2022: Jobs, Eligibility, Selection Process, Indian Coast Guard Previous Year Question Paper. Think of a situation where you need a basic container which would store two values: container for two ints, two chars, two floats, etc. The following program demonstrates this , We make use of cookies to improve our user experience. b) An object is an instance of its class The definition of the function must differ from each other by the types and/or the number of arguments in the argument list. It is also called static binding. When you have a function defined in a class that you want to be implemented in an inherited class(es), you use virtual functions. b) Structures can have member functions

I) All operators in C++ can be overloaded. d) > #include class IndiaBix { static int count; public: static void First(void) { count = 10; } static void Second(int x) { count = count + x; } static void Display(void) { cout<< count << endl; } }; int IndiaBix::count = 0; int main() { IndiaBix :: First(); IndiaBix :: Second(5); IndiaBix :: Display(); return 0; }. MCQ->What will be the output of the program ? Compiler searches for function with signature custom_add( int , int ), and uses the one that fits best. Dynamic polymorphism is implemented by abstract classes and virtual functions. View Answer, 6. Putting type specifier when using a template function is not required, but is generally considered as a good practice. There is a nice handy way to have everything working as is and having an exception for char values. Which of the following is a static polymorphism mechanism? b) Public Function template can be seen as a pattern for producing specialized functions fit for a particular purpose. d) C++ allows both static and dynamic type checking a) Classes cannot have protected data members It might be hard to grasp, but examples will make understanding of the concept easier. Its Official: Team Oasis is KYC Audited! It works perfectly with numerical values, and even has a special behavior for non-numerical built-in types. Which of the following is correct? Which members are inherited but are not accessible in any case? Base class object will call base class function and derived class object will call derived class function. Which of the following is used to make an abstract class? milena lrde olena output View Answer. No answer description available for this question. a) It reduces the testing time Which of the following is a static polymorphism mechanism? View Answer, 9. We can change the basic meaning of an operator in C++. What happens if the base and derived class contains definition of a function with same prototype? However, such operators are sometimes seen as a basic polymorphism feature, and they are helpful in explaining overloaded functions true implementation of polymorphic behavior. They are . Agree polymorphism providing a single interface to entities of different types. c) Both I and II MCQ->Which of the following statement is correct about the program given below? Static functions cannot call instance functions. Which of the following is a mechanism of static polymorphism? Prev 1 2 3 4 5 6 7 8 9 10 11 12 Next, 2009 - 2022 by IndiaBIX Technologies. a) By using virtual keyword in front of a class declaration Sanfoundry Global Education & Learning Series C++ Programming Language. Which of the following statement is true? Important note: Bjarne Stroustrups definition of static polymorphism omits overloaded operators. WWCode Taipei x Dell Women in Action Summer Coding Camp 2020. Which of the following operators cannot be overloaded? 6. View Answer, 11. #include static double gDouble; static float gFloat; static double gChar; static double gSum = 0; class BaseOne { public: void Display(double x = 0.0, float y = 0.0, char z = 'A') { gDouble = x; gFloat = y; gChar = int(z); gSum = gDouble + gFloat + gChar; cout << gSum; } }; class BaseTwo { public: void Display(int x = 1, float y = 0.0, char z = 'A') { gDouble = x; gFloat = y; gChar = int(z); gSum = gDouble + gFloat + gChar; cout << gSum; } }; class Derived : public BaseOne, BaseTwo { void Show() { cout << gSum; } }; int main() { Derived objDev; objDev.BaseTwo::Display(10, 20, 'Z'); return 0; }. MCQ->What will be the output of the following program? Function overloading is a mechanism of static polymorphism. How run-time polymorphisms are implemented in C++? I) In Procedural programming languages, all function calls are resolved at compile-time a) C++ allows static type checking There is a drawback: adding type specifier custom_add(p, e) will tell compiler to treat both inputs as int values (despite value e being a float) and hide the compile-time error. Compiler reports the issue and aborts compilation process.

To understand why, you need to look at the process of function creation in a step-by-step manner. How many types of polymorphisms are supported by C++? C# provides two techniques to implement static polymorphism.

The virtual functions could be implemented differently in different inherited class and the call to these functions will be decided at runtime.