class overload { int x; double y; void add(int a , int b) { x = a + b; } void add(double c , double d){ y = c + d; } overload() { this.x = 0; this.y = 0; } } class Overload_methods { public static void main(String args[]) { overload obj = new overload(); int a = 2; double b = 3.2; obj.add(a, a); obj.add(b, b); System.out.println(obj.x + " " + obj.y); } }
Options:
A .  6 6
B .  6.4 6.4
C .  6.4 6
D .  4 6.4
Answer: Option D
For obj.add(a,a); ,the function in line number 4 gets executed and value of x is 4. For the next
function call, the function in line number 7 gets executed and value of y is 6.4 output: $ javac Overload_methods.java $ java Overload_methods 4 6.4
Submit Your Solution hear: