122). Which of these selection statements test only for equality?

[A]if
[B] switch
[C]if & switch
[D] none of the mentioned

Show Answer

126). Which of this statement is incorrect?

[A] switch statement is more efficient than a set of nested ifs
[B] two case constants in the same switch can have identical values
[C]switch statement can only test for equality, whereas if statement can evaluate any type of boolean expression
[D] it is possible to create a nested switch statements

Show Answer

127). What will be the output of the following Java program?
  class selection_statements 
    {
        public static void main(String args[])
        {
            int var1 = 5; 
            int var2 = 6;
            if ((var2 = 1) == var1)
                System.out.print(var2);
            else 
                System.out.print(++var2);
        } 
    }

[A]1
[B]2
[C]3
[D]4

Show Answer

128). What will be the output of the following Java program?
 class comma_operator 
    {
        public static void main(String args[]) 
        {    
             int sum = 0;
             for (int i = 0, j = 0; i < 5 & j < 5; ++i, j = i + 1)
                 sum += i;
 	     System.out.println(sum);
        } 
    }

[A]5
[B]6
[C]14
[D]compilation error

Show Answer

129). What will be the output of the following Java program?
    class jump_statments 
    {
        public static void main(String args[]) 
        {        
             int x = 2;
             int y = 0;
             for ( ; y < 10; ++y) 
             {
                 if (y % x == 0) 
                     continue;  
                 else if (y == 8)
                      break;
                 else
                    System.out.print(y + " ");
             }
        } 
    }

[A]1 3 5 7
[B] 2 4 6 8
[C]1 3 5 7 9
[D]1 2 3 4 5 6 7 8 9

Show Answer

130). What will be the output of the following Java program?
class Output 
{
        public static void main(String args[]) 
        {    
           final int a=10,b=20;
          while(a

[A]Hello
[B] run time error
[C]Hello world
[D]compile time error

Show Answer

131). What will be the output of the following Java program?
    class Output 
    {
        public static void main(String args[]) 
        {    
             int a = 5;
             int b = 10;
             first: 
             {
                second: 
                {
                   third: 
                   { 
                       if (a ==  b >> 1)
                           break second;
                   }
                   System.out.println(a);
                }
                System.out.println(b);
             }
        } 
    }

[A]5 10
[B] 10 5
[C]5
[D]10

Show Answer