Vidyalelo
Java Programming · Q46

Overriding and Overloading

Programming · Java Programming · question 46

Q46

What will be the output of the following Java code? 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);

A.
6
B.
7
C.
8
Answer
D.
9

Answer: Option C

Solution

Answer: Option C
No explanation is given for this question Let's Discuss on Board