Submitted by c-admin on Tue, 06/04/2019 - 22:47
Using a continue in a while loop causes the loop to break the current iteration and start the next iteration of the loop.
Select 1 option
A. True
B. False
Submitted by c-admin on Tue, 06/04/2019 - 22:45
What is the effect of compiling and running the code shown in exhibit?
public class TestClass{
public static void main (String args []){
int sum = 0;
for (int i = 0, j = 10; sum > 20; ++i, --j) // 1
{
sum = sum+ i + j;
}
System.out.println("Sum = " + sum);
}
}
Select 1 option
A. Compile time error at line 1.
B. It will print Sum = 0
C. It will print Sum = 20
D. Runtime error.
E. None of the above.
Submitted by c-admin on Tue, 06/04/2019 - 22:12
Given the following code fragment, which of the following lines would be a part of the output?
outer:
for ( int i = 0 ; i<3 ; i++ ){
for ( int j = 0 ; j<2 ; j++ ){
if ( i == j ){
continue outer;
}
System.out.println( "i=" + i + " , j=" + j );
}
}
Select 2 options
A. i = 1, j = 0
B. i = 0, j = 1
C. i = 1, j = 2
D. i = 2, j = 1
E. i = 2, j = 2
Submitted by c-admin on Tue, 06/04/2019 - 22:09
Which of the following are true about the enhanced for loop?
Select 3 options
A. It can iterate over an array or a Collection but not a Map.
B. Using an enhanced for loop prevents the code from going into an infinite loop
C. Using an enhanced for loop on an array may cause infinite loop.
D. An enhanced for loop can iterate over a Map.
E. You cannot find out the number of the current iteration while iterating.
Submitted by c-admin on Tue, 06/04/2019 - 22:06
Which of these for statements are valid?
1. for (int i=5; i=0; i--) { }
2. int j=5;
for(int i=0, j+=5; i<j ; i++) { j--; }
3. int i, j;
for (j=10; i<j; j--) { i += 2; }
4. int i=10;
for ( ; i>0 ; i--) { }
5. for (int i=0, j=10; i<j; i++, --j) {;}
Select 1 option
A. 1, 2
B. 3, 4
C. 1, 5
D. 4, 5
E. 5
Pages