Q: What is the output of the below Java program? int time=50; do { System.out.print(time + ","); time++; }while(time < 53)
Solution: The semicolon after the WHILE (Condition) is missing.
Q: What is the output of the below Java program? String str[] = {"A","B","C"}; int i=0; do { if(i>= str.length) break; System.out.print(str[i] + ","); i++; }while(true);
Solution: no solution
Q: What is the output of the below Java code with a FOR loop? for(int i=1; i<5; i++) { System.out.print(i +","); }
Solution: no solution
Q: What is the output of the below Java code? boolean[] ary = {true, false, true, true}; for(int i=0; i
Solution: no solution
Q: What is the output of the below Java code? int score=1; for(; true; score++) { System.out.print(score +","); if(score > 3) break; }
Solution: BREAK condition is checked after printing the variable "score". So, it prints 4 also.
Q: What is the output of the below Java program with FOR loop? for(int j=0; j<5;j++;) System.out.print(j + ",");
Solution: The semicolon after the INCREMENT/DECREMENT part is not allowed.
Q: State TRUE or FALSE. In a FOR loop, the Initialization-part, Condition-part and Increment/Decrement part can be empty.
Solution: for(;;) is valid.
Q: Any loop can be nested inside any loop in Java. (TRUE/FALSE).
Solution: no solution
Q: A Loop in Java language may contain ___.
Solution: no solution
You Have Score    | /9 |