-
What is the output of this program?
class method
{
int p;
int q;
void add(int n)
{
p = n + 2;
}
void add(int n, int b)
{
p = n + 5;
}
}
public class method_overloading
{
public static void main(String args[])
{
method obj = new method();
int n = 0;
obj.add(10);
System.out.println(obj.p);
}
}
-
- 10
- 11
- 12
- 13
- 14
Correct Option: B
Output: 12