πŸ“Š JAVA
Q. What will be the output after compiling and running following code?
Code:
public class Test{
      public static void main(String... args){
            int x =5;
            x *= 3 + 7;
            System.out.println(x);
      }
}
  • (A) 22
  • (B) 50
  • (C) 10
  • (D) 10D.Compilation fails with an error at line 4
πŸ’¬ Discuss
βœ… Correct Answer: (B) 50

Explanation: x *= 3 + 7; is same as x = x * (3 +7) = 5 * (10) = 50 because expression on the right side is always placed inside parentheses.

Explanation by: Sonali Mishra
x *= 3 + 7; is same as x = x * (3 +7) = 5 * (10) = 50 because expression on the right side is always placed inside parentheses.

πŸ’¬ Discussion


πŸ“Š Question Analytics

πŸ‘οΈ
171
Total Visits
πŸ“½οΈ
1 y ago
Published
πŸŽ–οΈ
Sonali Mishra
Publisher
πŸ“ˆ
84%
Success Rate