public class IncrDemo
{
    public static void main(String[] args)
    {
      int myVal, yourVal;
      myVal = 10;
      System.out.println("My initial value is " + myVal);
      yourVal = ++myVal;
      System.out.println("My new value is " + myVal);
      System.out.println("Your value is " + yourVal):
    }
}
?
Using the above code, describe how the three println output commands will appear. Explain the values stored in the variables during code execution.

What will be an ideal response?


The myVal variable is initialized to 10. The first println statement will display:"My initial value is 10".?myVal is then incremented by 1 and the value is stored in yourVal. At this point, both myVal and yourVal have a value of 11.?The second println statement will display:"My new value is 11."?And the third println statement will display:"Your value is 11."

Computer Science & Information Technology

You might also like to view...

Consider the if statement: if(condition) yes_clause; else no_clause; Under which of the following circumstances will both the yes_clause and the no_clause will be executed?

a. When the condition is true. b. When the condition is false. c. When the condition is ambiguous. d. This will not happen.

Computer Science & Information Technology

The argument and the parameters of a function

A. must agree in number, and identifier name. B. must agree in data type and identifier name. C. must agree in number and order. D. must agree in order and identifier name.

Computer Science & Information Technology

Similar to the examples above, show the steps involved in evaluating each of the following mixed expressions:

a. 'The sum is' + 12 + 20 b 12 + 20 + ' is the sum' c. 12 + 20 + ' is the sum'

Computer Science & Information Technology

The ________ clause, if it appears after a try suite, always executes.

Fill in the blank(s) with the appropriate word(s).

Computer Science & Information Technology