Q.- Given the code fragment:
public static void main(String[] args) {
int data[ ] = {2010, 2013, 2014, 2015, 2014};
int key = 2014;
int count = 0;
for (int e : data) {
if (e != key) {
continue;
count++;
}
}
System.out.print (count + “Found");
}
What is the result?
A) Compilation fails.
B) O Found
C) 3 Found
D) 1 Found
⧪ please give your answer in a comment section.
public static void main(String[] args) {
int data[ ] = {2010, 2013, 2014, 2015, 2014};
int key = 2014;
int count = 0;
for (int e : data) {
if (e != key) {
continue;
count++;
}
}
System.out.print (count + “Found");
}
What is the result?
A) Compilation fails.
B) O Found
C) 3 Found
D) 1 Found
⧪ please give your answer in a comment section.
3 Comments
b
ReplyDeleteC
ReplyDeleteA. can't use continue within if statement. continue and break are jump statements which we can use in loops
ReplyDelete