Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

answer the above all questions . 1) Consider the following overloaded functions,

ID: 3868540 • Letter: A

Question

answer the above all questions .

1) Consider the following overloaded functions, declared in a program X: int sum (int,int) float sum (float, float) double sum (double, double) If you are asked to declare one more overloaded function of sum0 in the same program X, such that the new overloaded function should not conflict with the existing three overloaded functions or should not rise error. Which one of the following functions, you will not select to declare? a) float sum (int, int); b) int sum (float, double) c) float sum (double, int) d) double sum (string, string)

Explanation / Answer

1)
all input arguments including int,float and double are acceptable
because they are subset of each other.
String input argument cannot be used inside function
hence double sum(String, String) cann be used
answer: (d)

2)
since sentence is NULL, hence string "Helloworld"
cannot be copied to senstence string
hence, it will result in SEGMENTATION FAULT
answer: (a)

3)
object of class Dericed is created and x is initialized to 100 since
Derived is extended from base class.
Inside base class x: 100
Inside base class after execution of static, x: 201
Inside Derived class, before execution of static, x: 201
Inside Derived class, after execution of static, x: 400
Inside Derived class, after execution of final statement (x = x++ - ++x;), x: -2
final x: -2
answer: (c)


4)
i++ = use i and then increment i
--i = decrement i and then use i
++i = incrmenet i and then use i
i-- = use i and then decrement i

solution:
i = 0
i is reduced by 1 and assigned to j
j = -1
i = -1

i++ + --i + i-- + j-- + --i + i = -10

answer: (c)