Java Control Flow

Answer all questions carefully. After submission, you will see a detailed result and answer review.

Question 1
What will be the output? <pre class="prettyprint"> public class Test{ public static void main(String[] args){ int x=10, y=0; if(x && y){ System.out.print("TRUE"); } else{ System.out.print("FALSE"); } } } </pre>
Question 2
In java, ________ can only test for equality, where as ________ can evaluate any type of the Boolean expression.
Question 3
Determine output: <pre class="prettyprint"> public class Test{ public static void main(String args[]){ int i; for(i = 1; i < 6; i++){ if(i > 3) continue ; } System.out.println(i); } } </pre>
Question 4
What all gets printed when the following program is compiled and run. <pre class="prettyprint"> public class Test{ public static void main(String args[]){ int i, j=1; i = (j>1)?2:1; switch(i){ case 0: System.out.println(0); break; case 1: System.out.println(1); case 2: System.out.println(2); break; case 3: System.out.println(3); break; } } } </pre>
Question 5
Determine output: <pre class="prettyprint"> public class Test{ public static void main(String args[]){ int i, j; for(i=1, j=0;i<10;i++) j += i; System.out.println(i); } } </pre>
Question 6
What will be the output of the following program? <pre class="prettyprint"> public class Test{ public static void main(String args[]){ int i = 0, j = 5 ; for( ; (i < 3) && (j++ < 10) ; i++ ){ System.out.print(" " + i + " " + j ); } System.out.print(" " + i + " " + j ); } } </pre>
Question 7
How many times will the following code print "Welcome to Examveda"? <pre class="prettyprint"> int count = 0; do { System.out.println("Welcome to Examveda"); count++; } while (count < 10); </pre>
Question 8
What will be the result of the following code? <pre class="prettyprint"> public class Test{ static public void main(String args[]){ //line 2 int i, j; for(i=0; i<3; i++){ for(j=1; j<4; j++){ i%=j; System.out.println(j); } } } } </pre>
Question 9
Which option, inserted at line 4, produces the output 12? <pre class="prettyprint"> 1. public class Test{ 2. public static void main(String [] args){ 3. int x = 0; 4. // insert code here 5. do{ } while(x++ < y); 6. System.out.println(x); 7. } 8. } </pre>
Question 10
What will be the result of compiling and runnig the following code: <pre class="prettyprint"> public class Test{ public static void main(String... args) throws Exception{ Integer i = 34; int l = 34; if(i.equals(l)){ System.out.println("true"); }else{ System.out.println("false"); } } } </pre>