edited by
4,865 views
2 votes
2 votes

Consider the following Java code fragment:

public class While
{
    public void loop()
    {
        int x = 0;
        while(1)
        {
            System.out.println("x plus one is" +(x+1));
        }
    }
}
  1. There is syntax error in line no. 1
  2. There is syntax errors in line nos. 1 & 6
  3. There is syntax error in line no. 8
  4. There is syntax error in line no. 6
edited by

3 Answers

Best answer
17 votes
17 votes
In Java, while(1) will give compiler time error as it treats as Type mismatch to convert from int to Bool value. Hence Ans :D
selected by
1 votes
1 votes
No syntax error..
0 votes
0 votes
I think answer is A as we cannot have class While
Answer:

Related questions

0 votes
0 votes
1 answer
1
admin asked Apr 1, 2020
945 views
Is null an object?YesNoSometimes yesNone of these
0 votes
0 votes
1 answer
2
admin asked Mar 31, 2020
683 views
Earlier name of Java programming language was:OAKDNetbeanEclipse
0 votes
0 votes
1 answer
3
admin asked Mar 31, 2020
998 views
Which of the following is a platform free language?JAVACAssemblyFortran