Java
T
point
Home
Python
Java
JavaScript
HTML
SQL
PHP
C#
C++
DS
Aptitude
Reasoning
Selenium
DBMS
C
Android
Interview Q
Content Menu ▼
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
Question 1
:
public class Tea {
public static void main(String [] args) {
int x = 5;
Tea t = new Tea();
t.doStuff(x);
System.out.print(" main x = " + x);
}
void doStuff(int x) {
System.out.print(" doStuff x = " + x++);
}
}
What is the result?
1.
Compilation fails.
2.
An exception is thrown at runtime.
3.
doStuff x = 6 main x = 6
4.
doStuff x = 5 main x = 5