What is the result?

Given:
<code>
public class DoBreak1 {
public static void main(String[] args) {
String[] table = {“aa”, “bb”, “cc”, “dd”};
for (String ss: table) {
if ( “bb”.equals(ss)) {
continue;
}
System.out.println(ss);
if ( “cc”.equals(ss)) {
break;
}
</code>
What is the result?

Given:

public class DoBreak1 {
public static void main(String[] args) {
String[] table = {"aa", "bb", "cc", "dd"};
for (String ss: table) {
if ( "bb".equals(ss)) {
continue;
}
System.out.println(ss);
if ( "cc".equals(ss)) {
break;
}

What is the result?

A.
aa
cc

B.
aa
bb
cc

C.
cc
dd

D.
cc

E.
Compilation fails.



Leave a Reply 2

Your email address will not be published. Required fields are marked *


sully

sully

so continue brings it to the next iteration of the loop
so i get why it prints aa, skips bb and then prints cc but wouldn’t it also print out dd
can anyone explain?

dafuq

dafuq

Breaks out of loop after printing cc