A

Admin • 831.35K Points
Coach

Q. Predict the output of following Java program

Code:
class T {
int t = 20;
T() {
t = 40;
}
}
class Main {
public static void main(String args[]) {
T t1 = new T();
System.out.println(t1.t);
}
}
  • (A) 40
  • (B) 20
  • (C) Compiler Error
  • (D) Runtime Error
  • Correct Answer - Option(A)
  • Views: 18
  • Filed under category Java
  • Hashtags:

No solution found for this question.
Add Solution and get +2 points.

You must be Logged in to update hint/solution

Discusssion

Login to discuss.

Be the first to start discuss.