Computer Applications
Select the infinite loop:
- for(int i = 1; i <= 10; i++)
- for(int i = 2; i != 0; i -= 3)
- for(int i = 5; i <= 5; i++)
- for(int i = 1; i >= 1; i--)
Java Iterative Stmts
7 Likes
Answer
for(int i = 2; i != 0; i -= 3)
Reason — The loop for(int i = 2; i != 0; i -= 3) is an infinite loop because the value of i starts at 2 and decreases by 3 in every iteration. Since i will never become 0 (it will take values like 2, -1, -4, -7, etc.), the condition i != 0 will always be true. Therefore, the loop will continue to run forever.
Answered By
4 Likes
Related Questions
Consider the two-dimensional array P[2][3], of peripherals (input/output devices) given below, state the index of the device Barcode Scanner.
![Consider the two-dimensional array P[2][3], of peripherals (input/output devices) given below, state the index of the device Barcode Scanner. ICSE 2025 Computer Applications Solved Question Paper.](https://cdn1.knowledgeboat.com/img/abp10/1/q1-5-icse-computer-board-2025-year-1134x730.png)
- P[1][1]
- P[0][1]
- P[1][2]
- P[0][0]
Which of the following is user-defined data type?

- only 1
- 1 and 3
- only 2
- only 4
The output of
Math.max(-7, Math.min(-5, -4))is:- -5
- -4
- -7
- error
Which of the following is true for the given object creation statement?
Game cricket = new Game();- Game is an object of cricket class
- New keyword creates object Game
- Game is a class and cricket is an object
- Game and cricket are objects