BO_Test1

Is this your test? Login to manage it. If not, you can make an exam just like it.

This is a non-interactive preview of the quiz content.

1.
1 point
Q14:What will be the output of following program?

class Test
public class Test
{
   public static void leftshift(int i, int j)
   {
       i <<= j;
   }
   public static void main(String args[])
   {
       int i = 4, j = 2;
       leftshift(i, j);
       System.out.printIn(i);
   }
}
2.
1 point
Q.7What will be the output of following program?

class Test
class Test
{
   public static void main(String [] args)
   {
       int x= 0;
       int y= 0;
       for (int z = 0; z < 5; z++)
       {
           if (( ++x > 2 ) && (++y > 2))
           {
               x++;
           }
       }
       System.out.println(x + " " + y);
   }
}
3.
1 point
Q13:What will be the output of following program?

class Test
class BoolArray
{
   boolean [] b = new boolean[3];
   int count = 0;

   void set(boolean [] x, int i)
   {
       x[i] = true;
       ++count;
   }

   public static void main(String [] args)
   {
       BoolArray ba = new BoolArray();
       ba.set(ba.b, 0);
       ba.set(ba.b, 2);
       ba.test();
   }

   void test()
   {
       if ( b[0] && b[1] | b[2] )
           count++;
       if ( b[1] && b[(++count - 2)] )
           count += 7;
       System.out.println("count = " + count);
   }
}
4.
1 point
Q15:What will be the output of following program?

public class App
{
   public static void main( String[] args )
   {
       short x = 1;
       int i = 123456;
       x = x + i;
       System.out.println(x);
   }
}
5.
1 point
Q1.What will be the output of following program?

class A
{
   final public int GetResult(int a, int b) { return 0; }
}
class B extends A
{
   public int GetResult(int a, int b) {return 1; }
}
public class Test
{
   public static void main(String args[])
   {
       B b = new B();
       System.out.println("x = " + b.GetResult(0, 1));  
   }
}
6.
1 point
Q5.What will be the output of following program?

class Equals
{
   public static void main(String [] args)
   {
       int x = 100;
       double y = 100.1;
       boolean b = (x = y);
       System.out.println(b);
   }
}
7.
1 point
Q.9What will be the output of following program?

class Test
class Bitwise
{
   public static void main(String [] args)
   {
       int x = 11 & 9;
       int y = x ^ 3;
       System.out.println( y | 12 );
   }
}
8.
1 point
Q.8:What will be the output of following program?

class Test
class Test
{
   public static void main(String [] args)
   {
       int x= 0;
       int y= 0;
       for (int z = 0; z < 5; z++)
       {
           if (( ++x > 2 ) || (++y > 2))
           {
               x++;
           }
       }
   System.out.println(x + " " + y);
   }
}
9.
1 point
Q:4-What will be the output of following program?

class BitShift
{
   public static void main(String [] args)
   {
       int x = 0x80000000;
       System.out.print(x + " and  ");
       x = x >>> 31;
       System.out.println(x);
   }
}
10.
1 point
Q.3What will be the output of following program?

class TestClass
{
   public static void main(String [] args)
   {
       TestClass obj = new TestClass();
       obj.start();
   }

   void start()
   {
       String str1 = "hi";
       String str2 = method(str1);
       System.out.print(str1 + str2);
   }

   String method(String str1)
   {
       str1 = str1 + "hello";
       System.out.print(str1);
       return "hello";
   }
}
11.
1 point
Q.12What will be the output of following program?

class Test
class Two
{
   byte x;
}

class PassO
{
   public static void main(String [] args)
   {
       PassO p = new PassO();
       p.start();
   }

   void start()
   {
       Two t = new Two();
       System.out.print(t.x + " ");
       Two t2 = fix(t);
       System.out.println(t.x + " " + t2.x);
   }

   Two fix(Two tt)
   {
       tt.x = 42;
       return tt;
   }
}
12.
1 point
Q.6What will be the output of following program?

class Test
{
   public static void main(String [] args)
   {
       int x=20;
       String sup = (x < 15) ? "small" : (x < 22)? "tiny" : "huge";
       System.out.println(sup);
   }
}
13.
1 point
Q.10What will be the output of following program?

class Test
class SSBool
{
   public static void main(String [] args)
   {
       boolean b1 = true;
       boolean b2 = false;
       boolean b3 = true;
       if ( b1 & b2 | b2 & b3 | b2 )
           System.out.print("first ");
       if ( b1 & b2 | b2 & b3 | b2 | b1 )
           System.out.println("second");
   }
}
14.
1 point
Q11:What will be the output of following program?

class Test
class Test
{
   static int s;
   public static void main(String [] args)
   {
       Test p = new Test();
       p.start();
       System.out.println(s);
   }

   void start()
   {
       int x = 7;
       twice(x);
       System.out.print(x + " ");
   }

   void twice(int x)
   {
       x = x*2;
       s = x;
   }
}
15.
1 point
Q2.What will be the output of following program?

class TestClass
{
   public static void main(String [] args)
   {
       TestClass obj = new TestClass();
       obj.start();
   }

   void start()
   {
       long [] array1 = {3,4,5};
       long [] array2 = method(array1);
       System.out.print(array1[0] + array1[1] + array1[2] + " ");
       System.out.println(array2[0] + array2[1] + array2[2]);
   }

   long [] method(long [] a3)
   {
       a3[1] = 7;
       return a3;
   }
}