Q. What is the output of the below Java program with a decrement operator and WHILE-loop?

Code:
int a=4;
while(a>0)
{
 System.out.print(a + " ");
 a--;
}
  • (A) 4 3 2 1
  • (B) 3 2 1
  • (C) Compiler error
  • (D) None
πŸ’¬ Discuss
βœ… Correct Answer: (A) 4 3 2 1

You must be Logged in to update hint/solution

πŸ’¬ Discussion


πŸ“Š Question Analytics

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