A

Admin • 825.56K 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) 5
  • (B) 9
  • (C) 8
  • (D) 4
  • Correct Answer - Option(C)
  • Views: 9
  • Filed under category Java
  • Hashtags:

Explanation by: Admin
The above Java program is an example to demonstrate the use of this keyword.

You must be Logged in to update hint/solution

Discusssion

Login to discuss.

Be the first to start discuss.