ICSE Class 10 Computer Applications
Question 32 of 43
User-Defined Methods — Question 32
Back to all questions 32
Question Question 30
Which of the following function-definitions are overloading the method given below :
int sum(int x, int y) {}- int sum(int x, int y, int z) { }
- float sum(int x, int y) { }
- int sum (float x, float y) { }
- int sum (int a, int b) { }
- float sum(int x, int y, float z) { }
- int sum(int x, int y, int z) { }
- int sum (float x, float y) { }
- float sum(int x, int y, float z) { }
Reason — Function prototypes 1,3 and 5 have different signatures. Thus, they are overloading the function sum(). Prototypes 2 and 4 have same signatures as both are taking two int arguments, which will generate compile time error.