Final answer:
In the given Java code, StringTokenizer breaks the string using the '+' sign as delimiter. The variable 'foo' is assigned the first token 'c = 1 ' and 'bar' is assigned the second token ' 2 '. Thus, the values of foo and bar are 'c = 1 ' and ' 2 ', respectively.
Step-by-step explanation:
The Java code segment in question involves creating a StringTokenizer object that tokenizes (breaks up) a given string into tokens, separated by the specified delimiter, which in this case is the "+" sign. The StringTokenizer takes two arguments, the string to be tokenized and the delimiter. Here, the string line1 contains the following sequence: "c = 1 + 2 + 3".
When the StringTokenizer is executed, the first token it retrieves is everything up to the first occurrence of the delimiter. Therefore, foo will be assigned the token "c = 1 ". The next token, bar, will be assigned the next available token which is " 2 ", as the spaces are not stripped by the tokenizer. The plus signs and spaces are considered as delimiters, therefore they are not included in the result tokens.
Therefore, the correct answer is d. foo is "c = 1 ", bar is " 2 ".