Tuesday, March 4, 2014

7. POLYMORPHISM

1. In C++, polymorphism is achieved through

(a) Inheritance (b) Encapsulation (c) Data hiding (d) Overloading

2. In how many ways polymorphism is achieved in C++?

(a) 3 (b) 4 (c) Many (d) 2

3. Which of the following terms means a name having two or more distinct meanings?

(a) Inheritance (b) Overriding (c) Encapsulation (d) Overloading

4. Which refers to a function having more than one distinct meaning?

(a) Overloaded operator (b) Overloaded operand

(c) Overloaded expression (d) Overloaded function

5. The ability of function to process the message in more than one form is called as

(a) Function overloading (b) Data abstraction (c) Operator overloading (d) Data hiding

6. Which strategy is adopted by the compiler when functions are invoked in function over loading?

(a) First Match (b) Matching (c) Match Best (d) Best Match

7. Which adopts best match strategy to invoke function over loading?

(a) Compiler (b) Overloaded function(c) Interpreter (d) Overloaded operator

8. The mechanism of giving special meaning to an operator is called as

(a) Function overloading (b) Operator overloading

(c) Data overloading (d) Variable overloading

9. How many explicit argument(s) are taken by binary operators overloaded through a member function?

(a) 4 (b) 3 (c) 1 (d) 2

10. During integral promotion, a char data type can be converted to

(a) float (b) integer (c) double (d) all the other three choices

11. Which data type can be converted to integer/char/double in integral data promotion?

(a) double (b) float (c) int (d) char

12. Which data type can be converted to char/double /float in integral data promotion?

(a) float (b) double (c) char (d) int

13. Which of overloaded functions are not considered by the C++ compiler as part of the parameter list?

(a) Formal arguments (b) Default arguments (c) Actual arguments 
(d) Dummy parameters

14. Which of the following operators can be over loaded?

(a) Membership (b) Unary (c) sizeof 
(d) Conditional

15. Which of the following is used to declare the operator function?

(a) method( ) (b) function( ) (c) void( ) 
(d) operator( )

16 Which of the following must have atleast one operand of use defined type?

(a) Constructor overloaded   
(b) Operator overloaded

(c) Function overloaded      
(d) Method overloaded

17. Which function is used to concatenate strings?

(a) strcmp( ) (b) strplus( ) 
(c) strcpy( ) (d) strcat( )

18. The sign for membership operator is

(a) ?: (question colon) (b) :: (double colon) 
(c) . (dot) (d) : (colon)

19. Which operator is used to concatenate two objects of the type Strings?

(a) + (b) * (c) & (d) and

20. Which is one of the facets of C++ that supports object oriented programming?

(a) Data hiding (b) Operator overloading (c) Data abstraction (d) Function overloading

21. The prototype of the overloaded member function is
(a) negative operator - () (b) void operator - (negative) (c) void operator - () (d) void operator minus

22. Which of the following statements invokes the over loaded member function?

(a) Negative n1() (b) n2+; (c) -n2; (d) --n2()

23. Which of the following cannot have same return type ?

(a) void fun(int x, int y); void fun(int x, float y); (b) int fun(int x); void fun(float x);

(c) void fun(int x); void fun(int y); (d) void fun(char x); void fun(char x, int y);

24. In operator overloading, the operator functions must be defined as

(a) member function (b) either member function or friend function

(c) None of these three choices (d) friend function

25. Which of the following operators cannot be over loaded?

(a) += (b) ++ (c) + (d) ::

26. While over loading functions, the possible integral promotions are

(a) Both int_char and char_int (b) char_int (c) int_char (d) None of these

27. The functionality of '+' operator can be extended to strings through

(a) operator overloading (b) function overloading (c) class (d) inheritance

28. The over loaded operator must have atleast one operand of

(a) user-defined type (b) derived (c) array (d) built-in type

29. During over loading of which of the following operators, the left hand object must be an object of their relevant class

(a) Unary (b) None of these three choices (c) Binary (d) Ternary

30. The over loaded function definitions are permitted for which of the following data types?

(a) All of these three choices (b) User defined (c) Derived (d) Built in

31. Which of the following is not true related to function over loading?

(a) Do not use the same function name for two unrelated functions

(b) The return type of overloaded functions may be the same data type.

(c) Each overloaded function must differ by the number of its formal parameter.

(d) The default arguments are considered by the C++ compiler as part of the parameter list

32. Integral promotions are purely -------

(a) program oriented (b) compiler oriented (c) data oriented (d) computer oriented

33. The function operator() is declared in which part of the class ?

(a) static (b) private (c) public (d) protected

34. Which of the following statement is false in case of operator overloading?

(a) Only existing operators can be overloaded

(b) Binary operators overloaded through member function take one explicit argument

(c) The overloaded operator must have at least one operand of user defined type

(d) The basic definition of an operator can be replaced

No comments:

Post a Comment