πŸ“Š JAVA
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
πŸ’¬ Discuss
βœ… Correct Answer: (A) 40

You must be Logged in to update hint/solution

πŸ’¬ Discussion


πŸ“Š Question Analytics

πŸ‘οΈ
3486
Total Visits
πŸ“½οΈ
4 y ago
Published
πŸŽ–οΈ
Ram Sharma
Publisher
πŸ“ˆ
88%
Success Rate