InterviewSolution
This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.
| 1. |
What is meant by overloading implements polymorphism? |
|
Answer» The overloading helps to apply polymorphism because Function overloading means two or more functions having same name but different types of arguments or different number of arguments. Whereas polymorphism refers to one name having many forms of an object behaviour depending on situations. |
|
| 2. |
What are the advantages of inline functions? |
|
Answer» The advantages of inline functions are: 1. The speed of execution of a program increases. 2. Efficient code can be generated. 3. Readability of the program increases. |
|
| 3. |
Write the advantages of inline functions. |
Answer»
|
|
| 4. |
Write any three characteristics of friend function. |
|
Answer» The characteristics of friend function are:
|
|
| 5. |
What are the restrictions on overloaded functions? |
Answer»
|
|
| 6. |
When is function overloading needed? |
|
Answer» Function overloading is normally used when several function of the same name perform identical tasks on different data types. |
|
| 7. |
Write an advantage of function overloading. |
|
Answer» The overloading function helps to reduce the use of different names for many functions. |
|
| 8. |
Name one condition for overloading of functions. |
|
Answer» The parameters/arguments should differ in the number of arguments or if they have same number of argument then they should differ in the type of the arguments. |
|
| 9. |
What is an inline function? |
|
Answer» Inline functions are those functions whose body is inserted in place of the function call. |
|
| 10. |
Write one advantage of inline function. |
|
Answer» The speed of execution of a program increases. |
|
| 11. |
The inline function is always converted to a code block. True/False. |
|
Answer» The inline function is always converted to a code block. True |
|
| 12. |
Explain friend functions and their characteristics. |
|
Answer» A friend function is a non-member function and is a friend of a class. It is declared inside a class with the prefix friend and defined outside the class like any other normal function without the prefix friend. This friend function can access private and protected data members if it is a friend function of that class.
|
|
| 13. |
What is a friend function? |
|
Answer» A friend function is a non-member function and is a friend of a class. It is declared inside a class with the prefix friend and defined outside the class line any other normal function without the prefix friend. |
|
| 14. |
Write any two characteristics of friend function. |
|
Answer» The characteristics of friend function are:
|
|
| 15. |
When are friend functions used? Write syntax for declaration of friend function. |
|
Answer» A friend function is useful when a function to be shared between the two classes by syntax for declaration of friend function: |
|
| 16. |
Can the keyword friend be used while declaring a friend function? |
|
Answer» Yes, the keyword friend is used while declaring friend function. For example, friend int Avg marks(PUC, cet); |
|
| 17. |
When is it possible that an inline function may not work? |
|
Answer» The inline function may not work under following situations:
|
|
| 18. |
Write the advantages and disadvantages of inline functions. |
|
Answer» Advantages of inline functions:
|
|