Answer:
D. 7
Explanation:
Given code:
String str = ("Ben and Jerry's ice cream is great.");
String[] tokens = str.split(" ");
for (String s : tokens) System.out.println(s);
Splitting the given sentence on space character yields 7 tokens, namely:
Ben , and , Jerry's , ice , cream , is , great.
So the for loop will execute 7 times, once for each token because the loop variable s is assigned an individual token on each iteration.