1.

What function will be called with the independent syntax “test(5,6,7);”?(a) void test(int x, int y)(b) void test(int x=0, int y, int z)(c) int test(int x=0, y=0, z=0)(d) void test(int x, int y, int z=0)This question was posed to me in an internship interview.Asked question is from Default Arguments topic in chapter Default Arguments vs Overloading, Upcasting and Downcasting of Object Oriented Programming

Answer»

The CORRECT choice is (d) void test(int x, int y, int z=0)

To explain: There are three arguments that are getting passed to the function test(). Only the last option have all the default argument at last in the argument list. And the total number of the arguments is three. The third option is wrong because the return type is int and the SYNTAX given is INDEPENDENT which means it doesn’t return any VALUE.



Discussion

No Comment Found

Related InterviewSolutions