Related questions with answers

Question

Find the errors in the following code:

// Warning! This code contains ERRORS!

if (x = 1)
 System.out.println(x);
else if( x == 2);
{
 x++;
 System.out.println(x);
}

Solutions

Verified
Answered 1 year ago
Step 1
1 of 3

The code given contains error(s). We have to find the errors in the given code.

  1.    if (x=1)
    
  2.    System.out.println(x);
    
  3.    else if (x ==2)
    
  4.    {
    
  5.        x++;
    
  6.        System.out.println(x);
    
  7.    }
    

Create an account to view solutions

Create an account to view solutions

More related questions

1/4

1/7