Bryoh
Bryoh
05.11.2020 • 
Computers and Technology

The following code is intended to test whether the int variable num is less than 10, and if so print a warning and set it to 10. The code then prints the value of num. if (num < 10)
System.out.println( "This is smaller than 10" );
num = 10;
System.out.println("Value of num is " + num);
What correction should be made so the code functions as intended?

An else statement should be added between the 3rd and 4th lines
The final line should be printed every time, not just when num hasn’t been changed.
A semicolon should be added at the end of the first line
The operator ‘<’ should be changed to ‘<=’ in the if statement
No correction should be made
Curly braces ‘{ }‘ should be added to enclose the second and third lines


The following code is intended to test whether the int variable num is less than 10, and if so prin

Solved
Show answers

Ask an AI advisor a question