1.

Which among the following function can be called without arguments?(a) void add(int x, int y=0)(b) void add(int=0)(c) void add(int x=0, int y=0)(d) void add(char c)I got this question during an online interview.My question is taken from Default Arguments in division Default Arguments vs Overloading, Upcasting and Downcasting of Object Oriented Programming

Answer» RIGHT choice is (c) void add(INT x=0, int y=0)

The best explanation: For the FUNCTION to be called WITHOUT arguments, EITHER it must have zero arguments or it must have all the default arguments. Here the function in option void add(int x=0, int y=0) have all the default arguments and hence can be called directly with zero argument.


Discussion

No Comment Found

Related InterviewSolutions