πŸ“Š JAVA
Q. 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);
System.out.println(obj.x);
}
}
  • (A) 5
  • (B) 6
  • (C) 7
  • (D) 8
πŸ’¬ Discuss
βœ… Correct Answer: (C) 7

You must be Logged in to update hint/solution

πŸ’¬ Discussion


πŸ“Š Question Analytics

πŸ‘οΈ
76
Total Visits
πŸ“½οΈ
12 mo ago
Published
πŸŽ–οΈ
Admin
Publisher
πŸ“ˆ
97%
Success Rate