result += primes[i];
JLS 15.18:
If just one operand to + is a String, the other operand is converted to a string, and then string concatenation is used.
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
This section is not available anymore. Please use the main Exam Page.1z0-819 Exam Questions
Log in to ExamTopics
Sign in:
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.
Upvoting a comment with a selected answer will also increase the vote count towards that answer by one.
So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.
ASPushkin
9 months, 3 weeks agoedwMr9
11 months, 1 week agod7bb0b2
1 year, 5 months agotmuralimanohar
1 year, 11 months agoStavok
1 year, 12 months agoTADIEWA
2 years, 5 months ago