Software-Engineering
August 25, 2024
OOPS
August 25, 2024
Software-Engineering
August 25, 2024
OOPS
August 25, 2024

OOPS

Question 91
Consider the following Java code fragment:
1   public class While
2   {
3          public void loop()
4          {
5                      int x = 0;
6                      while(1)
7                      {
8                                  System.out.println(“x plus one is” +(x+1));
9                      }
10        }
11  }
A
There is syntax error in line no. 1
B
There is syntax errors in line nos. 1 & 6
C
There is syntax error in line no. 8
D
There is syntax error in line no. 6
Question 91 Explanation: 
Java does not – unlike C – interpret 0 as false and 1 as true.
So we cannot use integers in the while() statement.
So line number 6 will give syntax error.
Correct Answer: D
Question 91 Explanation: 
Java does not – unlike C – interpret 0 as false and 1 as true.
So we cannot use integers in the while() statement.
So line number 6 will give syntax error.

Leave a Reply

Your email address will not be published. Required fields are marked *