Test Series - java

Test Number 40/64

Q: State TRUE or FALSE. You can exit an inner loop without using a BREAK statement but with a CONTINUE and Label on the outer loop.
A. FALSE
B. TRUE
C. blank
D. None
Solution: no solution
Q: The keyword "goto" can be used in Java programs with labels. (TRUE/FALSE)
A. FALSE
B. TRUE
C. blank
D. None
Solution: The keyword "goto" is still a reserved keyword. It can not be used.
Q: Is it possible to break all loops with a single BREAK with a Label statement? (YES/NO)
A. YES
B. NO
C. blank
D. None
Solution: no solution
Q: What is the output of the Java code snippet below?
outer:
for(int i=1; i<=4;i++)
{
  inner:
  for(int j=1; j<=4;j++)
  {
    if(j==1)
      break outer;
  }
System.out.print("A");
}
A. A
B. AAAA
C. No Output
D. Compiler error
Solution: Even before reaching the PRINT statement, the outer loop will stop because of BREAK outer.
Q: What is the output of the below Java program?
outer:
for(int i=1; i<=2;i++)
{
  inner:
  for(int j=1; j<=2;j++)
  {
    if(j>i)
      break inner;
    System.out.print(j +",");	
  }
}
A. 1,1,1
B. 1,2,2,
C. 1,1,2,
D. Compiler error
Solution: no solution

You Have Score    /5