-
What is the output of this program?
class method
{
int p;
double q;
void add(int n1 , int n2)
{
p = n1 + n2;
}
void add(double n3 , double n4)
{
q = n3 + n4;
}
method()
{
this.p = 0;
this.q = 0;
}
}
public class method_overload
{
public static void main(String args[])
{
method obj = new method();
int n1 = 5;
double n2 = 7.5;
obj.add(n1, n1);
obj.add(n2, n2);
System.out.println(obj.p + " " + obj.q);
}
}
-
- 10 15.0
- 10.0 15
- 15 10
- 10.0 15.0
- None of these
Correct Option: A
Output: 10 15.0