For the following code, how many times would the while loop execute? 2. StringTokenizer st = new StringTokenizer(“The quick brown-fox jumped over the lazy dog while (st.hasMoreTokens0) System.out.println(st.nextTokenO): Show transcribed image text For the following code, how many times would the while loop execute? 2. StringTokenizer st = new StringTokenizer(“The quick brown-fox jumped over the lazy dog while (st.hasMoreTokens0) System.out.println(st.nextTokenO):
Answer
There are 8 words in the sentence.
1)The
2)quick
3)brown-fox
4)jumped
5)over
6)the
7)lazy
8)dog
So,
8(eight) times the while loop executes.
The loop iterates for each word
OR
OR