What is the result?
What is the result?
The given code initializes an array of prime numbers and a string to store the result. The while loop runs while 'i' is less than the length of the array. The condition inside the loop checks if 'i' is equal to 3 and breaks if true. The variable 'i' is incremented before appending the value of 'primes[i]' to the result string. The loop starts with 'i' equal to 0, increments it and appends the next prime number each time. So, primes[1]=3 and primes[2]=5 are appended, the loop breaks when 'i' becomes 3. Thus, the correct result is '35'.
The line that contains i++ removes the option to print the first number, that is, it verifies that it prints 357, and "A" is the correct
private static int i ; private static int primes[] = {2,3,5,7}; private static String resulet = ""; public static void main(String[] args) { while (i < primes.length) { if( i == 3) { break; } i++; resulet += primes[i]; } System.out.println(resulet); } A: is correct only know what happend with i = 2 case, event before append increment so when is 2 increment i = 3 and array contain element 3, so append its ok. After that while is break for if condition
Answer: A
A is correct
A is correct