Why did the program print the first "40" without a decimal point, but printed the second one with a decimal point as "40.0" ?

A good answer might be:

The first value was stored in a variable of data type long, an integer type. Integers do not have fractional parts. The second forty was the result of a calculation involving a variable of data type double, a floating point type.

Calculation

Here is the program again:

class example
{
  public static void main ( String[] args )
  {
    long   hoursWorked = 40;    
    double payRate     = 10.0, taxRate = 0.10;    

    System.out.println("Hours Worked: " + hoursWorked );
    System.out.println("pay Amount  : " + (hoursWorked * payRate) );
    System.out.println("tax Amount  : " + (hoursWorked * payRate * taxRate) );
  }
}

Look carefully at the statement highlighted in red. The parentheses around  (hoursWorked * payRate)  show that we want to multiply  hoursWorked  by  payRate  and then to append the result (converted to characters) to the string.

When you have a calculation as part of a  System.out.println()  statement, it is a good idea to surround the arithmetic part with parentheses to show that you want it done first. Sometimes this is not necessary, but it will not hurt, and makes the program more readable. More on this later.

QUESTION 8:

Would it be convenient write some of those statements on two lines?