A

Admin • 828.70K Points
Coach

Q. What will be the output of following Java code?

Code:
import java.util.Scanner;

class ThisKeyword {
private int a = 4;
private int b = 1;

void getSum(int a, int b) {
this.a = a;
this.b = b;
System.out.println(this.a + this.b);
}
}

public class Main {
public static void main(String args[]) {
ThisKeyword T = new ThisKeyword();
T.getSum(3, 5);
}
}
  • (A) Error
  • (B) [mango, orange, guava, mango, apple]
  • (C) [mango, orange, guava, apple]
  • (D) None of these
  • Correct Answer - Option(B)
  • Views: 19
  • Filed under category Java
  • Hashtags:

Explanation by: Admin
The output of the above program is:

[mango, orange, guava, mango, apple]

You must be Logged in to update hint/solution

Discusssion

Login to discuss.

Be the first to start discuss.