Q. What will be the output of the following Java program?

Code:
class comma_operator 
{
    public static void main(String args[]) 
    {    
         int sum = 0;
         for (int i = 0, j = 0; i < 5 & j < 5; ++i, j = i + 1)
             sum += i;
   System.out.println(sum);
    } 
}
  • (A) 5
  • (B) 6
  • (C) 14
  • (D) compilation error
πŸ’¬ Discuss
βœ… Correct Answer: (B) 6

You must be Logged in to update hint/solution

πŸ’¬ Discussion


πŸ“Š Question Analytics

πŸ‘οΈ
409562
Total Visits
πŸ“½οΈ
1 y ago
Published
πŸŽ–οΈ
Ritu Nagar
Publisher
πŸ“ˆ
92%
Success Rate