No. The programmer probably wants
the three statements after the else
to be part of a false block,
but has not used braces to show this.
The false block was not put inside braces:
if ( num < 0 )
System.out.println("The number " + num + " is negative");
else
System.out.println("The number " + num + " is positive");
System.out.print ("positive numbers are greater ");
System.out.println("or equal to zero ");
System.out.println("Good-bye for now");
Our human-friendly indenting shows what we want, but the compiler ignores indenting. The compiler groups statements according to the braces. What it sees is the same as this:
if ( num < 0 )
System.out.println("The number " + num + " is negative"); // true-branch
else
System.out.println("The number " + num + " is positive"); // false-branch
System.out.print ("positive numbers are greater "); // always executed
System.out.println("or equal to zero "); // always executed
System.out.println("Good-bye for now"); // always executed
How would you fix the above?