go to previous page   go to home page   go to next page hear noise highlighting

Answer:

No. The incorrect splittings are highlighted in red:

cla
    ss 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  : " + (hours
        Worked * payRate) );

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

The last statement is correct, although not done in a good style for easy human comprehension. The extra blank lines are OK.


Assignment Statements

public class AssignmentExample
{
  public static void main ( String[] args )
  {
    long payAmount ;  // payAmount is declared without an initial value

    payAmount = 123;  // an assignment statement
    System.out.println("The variable contains: " + payAmount );
  }
}

So far, the example programs have been using the value initially put into a variable. Programs can change the value in a variable. An assignment statement changes the value that is held in a variable. The program uses an assignment statement.

The assignment statement puts the value 123 into the variable. In other words, while the program is executing there will be a 64 bit section of memory that holds the value 123.

Remember that the word "execute" is often used to mean "run". You speak of "executing a program" or "executing" a line of the program.


QUESTION 10:

What does the program print to the monitor?


go to previous page   go to home page   go to next page