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.
| 51. |
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(); |
|
| 52. |
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) |
|
| 53. |
Which among the following is correct?(a) void test(int x=0, int y, int z=0)(b) void test(int x=0, int=0)(c) void test(int x, int y=0)(d) void test(int x=’c, int y)I have been asked this question in an interview for job.This interesting question is from Default Arguments in chapter Default Arguments vs Overloading, Upcasting and Downcasting of Object Oriented Programming |
|
Answer» Right choice is (c) void test(int x, int y=0) |
|
| 54. |
If a function have all the default arguments but still some values are passed to the function then ______________(a) The function will use the values passed to it(b) The function will use the default values as those are local(c) The function can use any value whichever is higher(d) The function will choose the minimum valuesI had been asked this question in an internship interview.This intriguing question originated from Default Arguments topic in division Default Arguments vs Overloading, Upcasting and Downcasting of Object Oriented Programming |
|
Answer» Correct choice is (a) The FUNCTION will use the values PASSED to it |
|
| 55. |
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. |
|
| 56. |
If a member function have to be made both zero argument and parameterized constructor, which among the following can be the best option?(a) Two normal and one default argument(b) At least one default argument(c) Exactly one default argument(d) Make all the arguments defaultThis question was posed to me at a job interview.Question is from Default Arguments topic in division Default Arguments vs Overloading, Upcasting and Downcasting of Object Oriented Programming |
|
Answer» RIGHT answer is (d) Make all the arguments default Explanation: All the arguments MUST be made default. This will make sure that none of the arguments are mandatory to be passed. Which in turn MEANS that the function can work WITHOUT any ARGUMENT and can be passed with arguments too. |
|
| 57. |
Which is the correct condition for the default arguments?(a) Those must be declared as last arguments in argument list(b) Those must be declared first in the argument list(c) Those can be defined anywhere in the argument list(d) Those are declared inside the function definitionI have been asked this question in an internship interview.Asked question is from Default Arguments topic in section Default Arguments vs Overloading, Upcasting and Downcasting of Object Oriented Programming |
|
Answer» Right option is (a) Those must be declared as last arguments in ARGUMENT list |
|
| 58. |
What are default arguments?(a) Arguments which are not mandatory to be passed(b) Arguments with default value that aren’t mandatory to be passed(c) Arguments which are not passed to functions(d) Arguments which always take same data valueI got this question in final exam.My enquiry is from Default Arguments in chapter Default Arguments vs Overloading, Upcasting and Downcasting of Object Oriented Programming |
|
Answer» The correct answer is (b) ARGUMENTS with default VALUE that aren’t mandatory to be passed |
|