Software-Engineering
August 25, 2024OOPS
August 25, 2024OOPS
|
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 }
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 }
|
There is syntax error in line no. 1
|
|
|
There is syntax errors in line nos. 1 & 6
|
|
|
There is syntax error in line no. 8
|
|
|
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.
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.
So we cannot use integers in the while() statement.
So line number 6 will give syntax error.
