Ask Question

What will be the output of the following code snippet? boolean token1 = true; while (token1) { for (int i = 0; i < 10; i++) { System. out. println ("Hello"); } token1 = false; }

+1
Answers (1)
  1. 9 August, 18:48
    0
    The output of the code snippet will be ten "Hello" messages

    Explanation:

    while token = true

    i = 0 sends "Hello" to the screen

    i = 1 sends "Hello" to the screen

    i = 2 sends "Hello" to the screen

    i = 3 sends "Hello" to the screen

    i = 4 sends "Hello" to the screen

    i = 5 sends "Hello" to the screen

    i = 6 sends "Hello" to the screen

    i = 7 sends "Hello" to the screen

    i = 8 sends "Hello" to the screen

    i = 9 sends "Hello" to the screen
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “What will be the output of the following code snippet? boolean token1 = true; while (token1) { for (int i = 0; i < 10; i++) { System. out. ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers