Home / Programming MCQs / JAVA MCQs / Question

R

Ram Sharma • 188.01K Points
Coach

Q. What is the output of the Java program with Enhanced FOR loop below?

Code:
String countries[] = {"BRAZIL", "CHILE", "SYDNEY"};
int i=0;
for(String str: countries)
{
  if(i<2)
    ;
  else
    break;
  System.out.print(str + ",");
  i++;
}
(A) BRAZIL,CHILE,SYDNEY,
(B) BRAZIL,CHILE,
(C) BRAZIL,
(D) Compiler error

No solution found for this question.
Add Solution and get +2 points.

You must be Logged in to update hint/solution

Discusssion

Login to discuss.