Home »
MCQs »
Java MCQs
What will be the output of following Java code (4)?
50. What will be the output of following Java 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);
}
}
- Error
- 8
- 5
- None of these
Answer: B) 8
Explanation:
The output of the above program is:
8