Discussion Forum : Introduction To Methods And Streams
Question -


What is the output of this program?


class overload {
int x;
int y;
void add(int a){
x = a + 1;
}
void add(int a , int b){
x = a + 2;
}
}
class Overload_methods {
public static void main(String args[])
{
overload obj = new overload();
int a = 0;
obj.add(6, 7);
System.out.println(obj.x);
}
}
Options:
A .  6
B .  7
C .  8
D .  9
Answer: Option C

None.
output:
$ javac Overload_methods.java
$ java Overload_methods
8



Was this answer helpful ?
Next Question
Submit Your Solution hear:

Your email address will not be published. Required fields are marked *