1.

Which among the following is a wrong call to the function void test(int x, int y=0, int z=0)?(a) test(5,6,7);(b) test(5);(c) test();(d) test(5,6);This question was posed to me during an interview for a job.Question is from Default Arguments in division Default Arguments vs Overloading, Upcasting and Downcasting of Object Oriented Programming

Answer»

Right ANSWER is (c) test();

The EXPLANATION is: The function must be PASSED with at least one argument. There is two default arguments and one NORMAL argument which must be passed with some value. Hence the third call to the function is wrong as it doesn’t pass even a SINGLE parameter to the func



Discussion

No Comment Found

Related InterviewSolutions