Explore BrainMass
Share

Explore BrainMass

    Java Programming : Switch Statements and Switch blocks

    This content was COPIED from BrainMass.com - View the original, and get the already-completed solution here!

    If x is currently equal to 5, what will the value of x be after the switch statement executes? Answer is 11. Please explain.The switch statement is

    switch (x)
    {
    case 3:
    x+=1
    case 4:
    x+=2
    Case 5:
    x+=3
    case 6:
    x++;
    case 7:
    x+=2
    case8:
    x--
    case 9:
    x++

    © BrainMass Inc. brainmass.com October 9, 2019, 7:48 pm ad1c9bdddf
    https://brainmass.com/math/optimization/java-programming-switch-statements-and-switch-blocks-129558

    Solution Preview

    Let's go through the switch block.
    Since x=5, then it goes to Case 5 directly and get x+=3. This means ...

    Solution Summary

    Switch statements and switch blocks and Java programming are investigated.

    $2.19