Question:
What will be the output of the following Java program?
    class dynamic_initialization     {        public static void main(String args[])         {            double a, b;            a = 3.0;            b = 4.0;	    double c = Math.sqrt(a * a + b * b);	    System.out.println(c);        }     }

Choices:
- 5.0
- 25.0
- 7.0
- Compilation Error


Question:
What is the prototype of the default constructor of this Java class?
    public class prototype { }

Choices:
- prototype( )
- prototype(void)
- public prototype(void)
- public prototype( )


Question:
What will be the error in the following Java code?
    byte b = 50;
    b = b * 50;

Choices:
- b cannot contain value 100, limited by its range
- * operator has converted b * 50 into int, which can not be converted to byte without casting
- b cannot contain value 50
- No error in this code


Question:
What will be the output of the following Java code?
    class char_increment     {        public static void main(String args[])         {            char c1 = 'D';            char c2 = 84;            c2++;            c1++;            System.out.println(c1 + " "  + c2);        }     }

Choices:
- E U
- U E
- V E
- U F


Question:
What will be the output of the following Java code?
    class conversion     {        public static void main(String args[])         {            double a = 295.04;            int  b = 300;            byte c = (byte) a;            byte d = (byte) b;            System.out.println(c + " "  + d);        }     }

Choices:
- 38 43
- 39 44
- 295 300
- 295.04 300


Question:
What will be the output of the following Java code?
    class A     {        final public int calculate(int a, int b) { return 1; }     }     class B extends A     {         public int calculate(int a, int b) { return 2; }     }      public class output      {        public static void main(String args[])         {             B object = new B();             System.out.print("b is " + b.calculate(0, 1));          }     }

Choices:
- b is : 2
- b is : 1
- Compilation Error
- An exception is thrown at runtime


Question:
What will be the output of the following Java program, if we run as “java main_arguments 1 2 3”?
    class main_arguments     {        public static void main(String [] args)         {            String [][] argument = new String[2][2];            int x;            argument[0] = args;            x = argument[0].length;            for (int y = 0; y < x; y++)                 System.out.print(" " + argument[0][y]);                      }    }

Choices:
- 1 1
- 1 0
- 1 0 3
- 1 2 3


Question:
What will be the output of the following Java program?
    class c     {            public void main( String[] args )         {              System.out.println( "Hello" + args[0] );         }     }

Choices:
- Hello c
- Hello
- Hello world
- Runtime Error


Question:
What will be the output of the following Java code?
    int arr[] = new int [5];
    System.out.print(arr);

Choices:
- 0
- value stored in arr[0]
- 00000
- Class [email protected] hashcode in hexadecimal form


Question:
What will be the output of the following Java code?
    class array_output     {        public static void main(String args[])         {            int array_variable [] = new int[10];	    for (int i = 0; i < 10; ++i)             {                array_variable[i] = i;                System.out.print(array_variable[i] + " ");                i++;            }        }     }

Choices:
- 0 2 4 6 8
- 1 3 5 7 9
- 0 1 2 3 4 5 6 7 8 9
- 1 2 3 4 5 6 7 8 9 10


Question:
What will be the output of the following Java code?
    class multidimention_array     {        public static void main(String args[])        {            int arr[][] = new int[3][];            arr[0] = new int[1];            arr[1] = new int[2];            arr[2] = new int[3];               	    int sum = 0;	    for (int i = 0; i < 3; ++i) 	        for (int j = 0; j < i + 1; ++j)                    arr[i][j] = j + 1;	    for (int i = 0; i < 3; ++i) 	        for (int j = 0; j < i + 1; ++j)                    sum + = arr[i][j];	    System.out.print(sum); 	        }     }

Choices:
- 11
- 10
- 13
- 14


Question:
What will be the output of the following Java code?
    class evaluate     {        public static void main(String args[])             {	        int arr[] = new int[] {0 , 1, 2, 3, 4, 5, 6, 7, 8, 9};	        int n = 6;                n = arr[arr[n] / 2];	        System.out.println(arr[n] / 2);            }     }

Choices:
- 3
- 0
- 6
- 1


Question:
What will be the output of the following Java code?
    class array_output     {        public static void main(String args[])         {            char array_variable [] = new char[10];	    for (int i = 0; i < 10; ++i)             {                array_variable[i] = 'i';                System.out.print(array_variable[i] + "");            }        }     }

Choices:
- 1 2 3 4 5 6 7 8 9 10
- 0 1 2 3 4 5 6 7 8 9 10
- i j k l m n o p q r
- i i i i i i i i i i


Question:
What will be the output of the following Java code?
    class array_output     {        public static void main(String args[])         {            int array_variable[][] = {{ 1, 2, 3}, { 4 , 5, 6}, { 7, 8, 9}};            int sum = 0;            for (int i = 0; i < 3; ++i)                for (int j = 0; j <  3 ; ++j)                    sum = sum + array_variable[i][j];            System.out.print(sum / 5);        }     }

Choices:
- 8
- 9
- 10
- 11


Question:
With x = 0, which of the following are legal lines of Java code for changing the value of x to 1?
   1. x++;
   2. x = x + 1;
   3. x += 1;
   4. x =+ 1;

Choices:
- 1, 2 & 3
- 1 & 4
- 1, 2, 3 & 4
- 3 & 2


Question:
What will be the output of the following Java program?
    class increment     {        public static void main(String args[])        {            double var1 = 1 + 5;             double var2 = var1 / 4;            int var3 = 1 + 5;            int var4 = var3 / 4;            System.out.print(var2 + " " + var4);         }     }

Choices:
- 1 1
- 0 1
- 1.5 1
- 1.5 1.0


Question:
What will be the output of the following Java program?
    class Modulus     {        public static void main(String args[])         {                 double a = 25.64;             int  b = 25;             a = a % 10;             b = b % 10;             System.out.println(a + " "  + b);        }     }

Choices:
- 5.640000000000001 5
- 5.640000000000001 5.0
- 5 5
- 5 5.640000000000001


Question:
What will be the output of the following Java program?
    class increment     {        public static void main(String args[])         {                     int g = 3;             System.out.print(++g * 8);        }     }

Choices:
- 25
- 24
- 32
- 33


Question:
What will be the output of the following Java program?
    class Output     {        public static void main(String args[])         {                 int a = 1;             int b = 2;             int c;             int d;             c = ++b;             d = a++;             c++;             b++;             ++a;             System.out.println(a + " " + b + " " + c);        }     }

Choices:
- 3 2 4
- 3 2 3
- 2 3 4
- 3 4 4


Question:
What will be the output of the following Java program?
    class bitwise_operator     {        public static void main(String args[])        {            int var1 = 42;            int var2 = ~var1;            System.out.print(var1 + " " + var2);     	        }     }

Choices:
- 42 42
- 43 43
- 42 -43
- 42 43


Question:
What will be the output of the following Java program?
    class bitwise_operator     {        public static void main(String args[])         {                 int a = 3;             int b = 6; 	     int c = a | b;             int d = a & b;                          System.out.println(c + " "  + d);        }     }

Choices:
- 7 2
- 7 7
- 7 5
- 5 2


Question:
What will be the output of the following Java program?
    class leftshift_operator     {        public static void main(String args[])         {                     byte x = 64;             int i;             byte y;              i = x << 2;             y = (byte) (x << 2)             System.out.print(i + " " + y);        }     }

Choices:
- 0 64
- 64 0
- 0 256
- 256 0


Question:
What will be the output of the following Java program?
    class rightshift_operator     {        public static void main(String args[])         {                 int x;              x = 10;             x = x >> 1;             System.out.println(x);        }     }

Choices:
- 10
- 5
- 2
- 20


Question:
What will be the output of the following Java program?
    class Output     {        public static void main(String args[])         {                 int a = 1;             int b = 2;             int c = 3;             a |= 4;             b >>= 1;             c <<= 1;             a ^= c;             System.out.println(a + " " + b + " " + c);        }     }

Choices:
- 3 1 6
- 2 2 3
- 2 3 4
- 3 3 6


Question:
Which of the following operators can operate on a boolean variable?
   1. &&
   2. ==
   3. ?:
   4. +=

Choices:
- 3 & 2
- 1 & 4
- 1, 2 & 4
- 1, 2 & 3


Question:
What will be the output of the following Java code?
    class Relational_operator     {        public static void main(String args[])        {            int var1 = 5;             int var2 = 6;            System.out.print(var1 > var2);        }     }

Choices:
- 1
- 0
- true
- false


Question:
What will be the output of the following Java code?
    class bool_operator     {        public static void main(String args[])         {                 boolean a = true;             boolean b = !true;             boolean c = a | b; 	     boolean d = a & b;             boolean e = d ? b : c;             System.out.println(d + " " + e);        }     }

Choices:
- false false
- true ture
- true false
- false true


Question:
What will be the output of the following Java code?
    class ternary_operator     {        public static void main(String args[])         {                     int x = 3;             int y = ~ x;             int z;             z = x > y ? x : y;             System.out.print(z);        }     }

Choices:
- 0
- 1
- 3
- -4


Question:
What will be the output of the following Java code?
    class Output     {        public static void main(String args[])         {                 int x , y = 1;             x = 10;             if (x != 10 && x / 0 == 0)                 System.out.println(y);             else                 System.out.println(++y);        }     }

Choices:
- 1
- 2
- Runtime error owing to division by zero in if condition
- Unpredictable behavior of program


Question:
What will be the output of the following Java code?
    class Output     {        public static void main(String args[])         {                 boolean a = true;             boolean b = false;             boolean c = a ^ b;             System.out.println(!c);        }     }

Choices:
- 0
- 1
- false
- true


Question:
What should be expression1 evaluate to in using ternary operator as in this line?
 expression1 ?  expression2  :  expression3

Choices:
- Integer
- Floating – point numbers
- Boolean
- None of the mentioned


Question:
What is the value stored in x in the following lines of Java code?
   int x, y, z;
    x = 0;
    y = 1;
    x = y = z = 8;

Choices:
- 0
- 1
- 9
- 8


Question:
What is the order of precedence (highest to lowest) of following operators?
    1. &
    2. ^
    3. ?:

Choices:
- 1 -> 2 -> 3
- 2 -> 1 -> 3
- 3 -> 2 -> 1
- 2 -> 3 -> 1


Question:
What will be the output of the following Java code?
    class operators     {        public static void main(String args[])        {            int var1 = 5;             int var2 = 6;            int var3;            var3 = ++ var2 * var1 / var2 + var2;            System.out.print(var3);        }     }

Choices:
- 10
- 11
- 12
- 56


Question:
What will be the output of the following Java code?
    class operators     {        public static void main(String args[])         {                 int x = 8;             System.out.println(++x * 3 + " " + x);        }     }

Choices:
- 24 8
- 24 9
- 27 8
- 27 9


Question:
What will be the output of the following Java code?
class Output {        public static void main(String args[])         {                 int x=y=z=20;         } }

Choices:
- compile and runs fine
- 20
- run time error
- compile time error


Question:
Which of these lines of Java code will give better performance?
   1. a | 4 + c >> b & 7;
   2. (a | ((( 4 * c ) >> b ) & 7 ))

Choices:
- 1 will give better performance as it has no parentheses
- 2 will give better performance as it has parentheses
- Both 1 & 2 will give equal performance
- Dependent on the computer system


Question:
What will be the output of the following Java program?
class Output {        public static void main(String args[])         {                 int a,b,c,d;             a=b=c=d=20            a+=b-=c*=d/=20           System.out.println(a+" "+b+" "+c+" "+d);         } }

Choices:
- compile time error
- runtime error
- a=20 b=0 c=20 d=1
- none of the mentioned


Question:
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);        }     }

Choices:
- 1
- 2
- 3
- 4


Question:
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);        }     }

Choices:
- 5
- 6
- 14
- compilation error


Question:
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 + " ");             }        }     }

Choices:
- 1 3 5 7
- 2 4 6 8
- 1 3 5 7 9
- 1 2 3 4 5 6 7 8 9


Question:
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<b)          {           System.out.println("Hello");          }          System.out.println("World");         } }

Choices:
- Hello
- run time error
- Hello world
- compile time error


Question:
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);             }        }     }

Choices:
- 5 10
- 10 5
- 5
- 10


Question:
What would be the output of the following code snippet if variable a=10?
if(a<=0){   if(a==0)   {     System.out.println("1 ");   }   else    {       System.out.println("2 ");   }}System.out.println("3 ");

Choices:
- 1 2
- 2 3
- 1 3
- 3


Question:
What is the valid data type for variable “a” to print “Hello World”?
switch(a){   System.out.println("Hello World");}

Choices:
- int and float
- byte and short
- char and long
- byte and char


Question:
What is the stored in the object obj in following lines of Java code?
   box obj;

Choices:
- Memory address of allocated memory of object
- NULL
- Any arbitrary pointer
- Garbage


Question:
What will be the output of the following Java program?
    class main_class     {        public static void main(String args[])        {            int x = 9;            if (x == 9)             {                 int x = 8;                System.out.println(x);            }        }     }

Choices:
- 9
- 8
- Compilation error
- Runtime error


Question:
What will be the output of the following Java program?
    class box     {        int width;        int height;        int length;    }     class mainclass     {        public static void main(String args[])         {                     box obj = new box();             obj.width = 10;             obj.height = 2;             obj.length = 10;             int y = obj.width * obj.height * obj.length;              System.out.print(y);        }     }

Choices:
- 12
- 200
- 400
- 100


Question:
What will be the output of the following Java program?
    class box     {        int width;        int height;        int length;    }     class mainclass     {        public static void main(String args[])         {                    box obj1 = new box();            box obj2 = new box();            obj1.height = 1;            obj1.length = 2;            obj1.width = 1;            obj2 = obj1;            System.out.println(obj2.height);        }     }

Choices:
- 1
- 2
- Runtime error
- Garbage value


Question:
What will be the output of the following Java program?
   class box    {        int width;        int height;        int length;   }     class mainclass     {        public static void main(String args[])         {                    box obj = new box();            System.out.println(obj);        }     }

Choices:
- 0
- 1
- Runtime error
- [email protected] in hexadecimal form


Question:
What will be the output of the following Java program?
    class box     {        int width;        int height;        int length;        int volume;        void volume(int height, int length, int width)         {             volume = width*height*length;        }     }        class Prameterized_method    {        public static void main(String args[])        {            box obj = new box();            obj.height = 1;            obj.length = 5;            obj.width = 5;            obj.volume(3,2,1);            System.out.println(obj.volume);                }      }

Choices:
- 0
- 1
- 6
- 25


Question:
What will be the output of the following Java program?
    class equality     {        int x;        int y;        boolean isequal()        {            return(x == y);          }     }        class Output     {        public static void main(String args[])        {            equality obj = new equality();            obj.x = 5;            obj.y = 5;            System.out.println(obj.isequal());        }     }

Choices:
- false
- true
- 0
- 1


Question:
What will be the output of the following Java program?
    class box     {        int width;        int height;        int length;        int volume;        void volume()         {             volume = width*height*length;        }     }        class Output     {         public static void main(String args[])        {            box obj = new box();            obj.height = 1;            obj.length = 5;            obj.width = 5;            obj.volume();            System.out.println(obj.volume);                }     }

Choices:
- 0
- 1
- 25
- 26


Question:
In the following Java code, which call to sum() method is appropriate?
class Output {         public static int sum(int ...x)        {             return;         }        static void main(String args[])         {                 sum(10);             sum(10,20);             sum(10,20,30);             sum(10,20,30,40);        } }

Choices:
- only sum(10)
- only sum(10,20)
- only sum(10) & sum(10,20)
- all of the mentioned


Question:
What will be the output of the following Java program?
    class area     {        int width;        int length;        int volume;        area()         {           width=5;           length=6;        }        void volume()         {             volume = width*length*height;        }     }        class cons_method     {        public static void main(String args[])        {            area obj = new area();            obj.volume();            System.out.println(obj.volume);                }     }

Choices:
- 0
- 1
- 30
- error


Question:
What will be the output of the following Java code?
    class box     {        int width;        int height;        int length;        int volume;        box()         {            width = 5;            height = 5;            length = 6;        }        void volume()         {             volume = width*height*length;        }     }        class constructor_output     {        public static void main(String args[])        {            box obj = new box();            obj.volume();            System.out.println(obj.volume);        }   }

Choices:
- 100
- 150
- 200
- 250


Question:
What will be the output of the following Java code?
class San{     San()throws IOException     {      }  }class Foundry extends San{     Foundry()     {      }     public static void main(String[]args)     {      }}

Choices:
- compile time error
- run time error
- compile and runs fine
- unreported exception java.io.IOException in default constructor


Question:
What will be the output of the following Java code?
    class box     {        int width;        int height;        int length;        int volume;        void finalize()         {            volume = width*height*length;            System.out.println(volume);        }        protected void volume()        {            volume = width*height*length;            System.out.println(volume);       }     }        class Output     {         public static void main(String args[])        {            box obj = new box();            obj.width=5;            obj.height=5;            obj.length=6;            obj.volume();        }     }

Choices:
- 150
- 200
- Run time error
- Compilation error


Question:
What will be the output of the following Java code?
    class area     {        int width;        int length;        int area;        void area(int width, int length)         {            this.width = width;            this.length = length;        }     }        class Output     {        public static void main(String args[])        {            area obj = new area();            obj.area(5 , 6);            System.out.println(obj.length + " " + obj.width);                }     }

Choices:
- 0 0
- 5 6
- 6 5
- 5 5


Question:
What will be the output of the following Java code?
class San{ public void m1 (int i,float f) {  System.out.println(" int float method"); }  public void m1(float f,int i);  {  System.out.println("float int method");  }   public static void main(String[]args)  {    San s=new San();        s.m1(20,20);  }}

Choices:
- int float method
- float int method
- compile time error
- run time error


Question:
What will be the output of the following Java code?
    class overload     {        int x; 	int y;        void add(int a)         {            x =  a + 1;        }        void add(int a, int b)        {            x =  a + 2;        }            }        class Overload_methods     {        public static void main(String args[])        {            overload obj = new overload();               int a = 0;            obj.add(6);            System.out.println(obj.x);             }   }

Choices:
- 5
- 6
- 7
- 8


Question:
What will be the output of the following Java code?
    class overload     {        int x; 	int y;        void add(int a)        {            x =  a + 1;        }        void add(int a , int b)        {            x =  a + 2;        }            }        class Overload_methods     {        public static void main(String args[])        {            overload obj = new overload();               int a = 0;            obj.add(6, 7);            System.out.println(obj.x);             }    }

Choices:
- 6
- 7
- 8
- 9


Question:
What will be the output of the following Java code?
   class overload    {        int x; 	double y;        void add(int a , int b)         {            x = a + b;        }        void add(double c , double d)        {            y = c + d;        }        overload()         {            this.x = 0;            this.y = 0;        }            }        class Overload_methods     {        public static void main(String args[])        {            overload obj = new overload();               int a = 2;            double b = 3.2;            obj.add(a, a);            obj.add(b, b);            System.out.println(obj.x + " " + obj.y);             }   }

Choices:
- 6 6
- 6.4 6.4
- 6.4 6
- 4 6.4


Question:
What will be the output of the following Java code?
    class test     {        int a;        int b;        void meth(int i , int j)         {            i *= 2;            j /= 2;        }              }        class Output     {        public static void main(String args[])        {            test obj = new test();	    int a = 10;            int b = 20;                         obj.meth(a , b);            System.out.println(a + " " + b);                }     }

Choices:
- 10 20
- 20 10
- 20 40
- 40 20


Question:
What will be the output of the following Java code?
    class test     {        int a;        int b;        test(int i, int j)         {            a = i;            b = j;        }        void meth(test o)         {            o.a *= 2;            O.b /= 2;        }              }        class Output     {        public static void main(String args[])        {            test obj = new test(10 , 20);            obj.meth(obj);            System.out.println(obj.a + " " + obj.b);                }     }

Choices:
- 10 20
- 20 10
- 20 40
- 40 20


Question:
What will be the output of the following Java code?
    class access    {        public int x; 	private int y;        void cal(int a, int b)        {            x =  a + 1;            y =  b;        }            }        public class access_specifier     {        public static void main(String args[])        {            access obj = new access();               obj.cal(2, 3);            System.out.println(obj.x + " " + obj.y);             }   }

Choices:
- 3 3
- 2 3
- Runtime Error
- Compilation Error


Question:
What will be the output of the following Java code?
    class access    {        public int x; 	private int y;        void cal(int a, int b)        {            x =  a + 1;            y =  b;        }           void print()         {            System.out.println(" " + y);             }     }       public class access_specifier     {        public static void main(String args[])        {            access obj = new access();               obj.cal(2, 3);            System.out.println(obj.x);            obj.print();             }   }

Choices:
- 2 3
- 3 3
- Runtime Error
- Compilation Error


Question:
What will be the output of the following Java code?
    class static_out     {        static int x; 	static int y;        void add(int a, int b)        {            x = a + b;            y = x + b;        }    }        public class static_use     {        public static void main(String args[])        {            static_out obj1 = new static_out();            static_out obj2 = new static_out();               int a = 2;            obj1.add(a, a + 1);            obj2.add(5, a);            System.out.println(obj1.x + " " + obj2.y);             }   }

Choices:
- 7 7.4
- 6 6.4
- 7 9
- 9 7


Question:
What will be the output of the following Java program?
    class access    {        public int x; 	static int y;        void cal(int a, int b)        {            x +=  a ;            y +=  b;        }            }        class static_specifier     {        public static void main(String args[])        {            access obj1 = new access();            access obj2 = new access();               obj1.x = 0;            obj1.y = 0;            obj1.cal(1, 2);            obj2.x = 0;            obj2.cal(2, 3);            System.out.println(obj1.x + " " + obj2.y);             }   }

Choices:
- 1 2
- 2 3
- 3 2
- 1 5


Question:
What will be the output of the following Java program?
    class access    {       static int x;       void increment()       {           x++;       }        }       class static_use     {        public static void main(String args[])        {            access obj1 = new access();            access obj2 = new access();            obj1.x = 0;               obj1.increment();            obj2.increment();            System.out.println(obj1.x + " " + obj2.x);         }   }

Choices:
- 1 2
- 1 1
- 2 2
- Compilation Error


Question:
What will be the output of the following Java program?
    class static_out     {        static int x; 	static int y;        void add(int a , int b)        {            x = a + b;            y = x + b;        }    }        class static_use     {        public static void main(String args[])        {            static_out obj1 = new static_out();            static_out obj2 = new static_out();               int a = 2;            obj1.add(a, a + 1);            obj2.add(5, a);            System.out.println(obj1.x + " " + obj2.y);             }   }

Choices:
- 7 7
- 6 6
- 7 9
- 9 7


Question:
What will be the output of the following Java program?
    class Output     {        public static void main(String args[])        {            int arr[] = {1, 2, 3, 4, 5};            for ( int i = 0; i < arr.length - 2; ++i)                System.out.println(arr[i] + " ");        }     }

Choices:
- 1 2
- 1 2 3
- 1 2 3 4
- 1 2 3 4 5


Question:
What will be the output of the following Java program?
    class Output     {        public static void main(String args[])        {            int a1[] = new int[10];            int a2[] = {1, 2, 3, 4, 5};            System.out.println(a1.length + " " + a2.length);        }     }

Choices:
- 10 5
- 5 10
- 0 10
- 0 5


Question:
What will be the output of the following Java program?
    class string_demo     {        public static void main(String args[])        {            String obj = "I" + "like" + "Java";               System.out.println(obj);             }   }

Choices:
- I
- like
- Java
- IlikeJava


Question:
What will be the output of the following Java program?
    class string_class     {        public static void main(String args[])        {            String obj = "I LIKE JAVA";               System.out.println(obj.charAt(3));        }     }

Choices:
- I
- L
- K
- E


Question:
What will be the output of the following Java program?
    class string_class     {        public static void main(String args[])        {            String obj = "I LIKE JAVA";               System.out.println(obj.length());        }    }

Choices:
- 9
- 10
- 11
- 12


Question:
What will be the output of the following Java program?
    class string_class     {        public static void main(String args[])        {            String obj = "hello";            String obj1 = "world";               String obj2 = obj;            obj2 = " world";            System.out.println(obj + " " + obj2);        }    }

Choices:
- hello hello
- world world
- hello world
- world hello


Question:
What will be the output of the following Java program?
    class string_class     {        public static void main(String args[])        {            String obj = "hello";            String obj1 = "world";               String obj2 = "hello";            System.out.println(obj.equals(obj1) + " " + obj.equals(obj2));        }    }

Choices:
- false false
- true true
- true false
- false true


Question:
What will be the output of the following Java program?
    class box     {        int width;        int height;        int length;        int volume;        void volume(int height, int length, int width)         {             volume = width * height * length;        }     }        class Prameterized_method{        public static void main(String args[])         {            box obj = new box();            obj.height = 1;            obj.length = 5;            obj.width = 5;            obj.volume(3, 2, 1);            System.out.println(obj.volume);                }     }

Choices:
- 0
- 1
- 6
- 25


Question:
What will be the output of the following Java program?
    class equality     {        int x;        int y;        boolean isequal()        {            return(x == y);          }     }        class Output     {        public static void main(String args[])         {            equality obj = new equality();            obj.x = 5;            obj.y = 5;            System.out.println(obj.isequal);        }     }

Choices:
- false
- true
- 0
- 1


Question:
What will be the output of the following Java program?
    class box     {        int width;        int height;        int length;        int volume;        void volume()         {            volume = width * height * length;        }         void volume(int x)         {            volume = x;        }    }        class Output     {         public static void main(String args[])         {            box obj = new box();            obj.height = 1;            obj.length = 5;            obj.width = 5;            obj.volume(5);            System.out.println(obj.volume);                }     }

Choices:
- 0
- 5
- 25
- 26


Question:
What will be the output of the following Java program?
    class Output     {        static void main(String args[])         {                 int x , y = 1;             x = 10;             if(x != 10 && x / 0 == 0)                 System.out.println(y);             else                 System.out.println(++y);        }     }

Choices:
- 1
- 2
- Runtime Error
- Compilation Error


Question:
What will be the output of the following Java program?
    class area     {        int width;        int length;        int height;        area()         {        width = 5;        length = 6;        height = 1;        }        void volume()         {             volume = width * height * length;        }     }        class cons_method     {        public static void main(String args[])         {            area obj = new area();            obj.volume();            System.out.println(obj.volume);        }     }

Choices:
- 0
- 1
- 25
- 30


Question:
Which of these is a correct statement about args in the following line of code?
public static void main(String args[])

Choices:
- args is a String
- args is a Character
- args is an array of String
- args in an array of Character


Question:
What will be the output of the following Java program, Command line execution is done as – “java Output This is a command Line”?
    class Output     {        public static void main(String args[])         {            System.out.print("args[0]");        }    }

Choices:
- java
- Output
- This
- is


Question:
What will be the output of the following Java program, Command line exceution is done as – “java Output This is a command Line”?
    class Output     {        public static void main(String args[])         {            System.out.print("args[3]");        }    }

Choices:
- java
- is
- This
- command


Question:
What will be the output of the following Java program, Command line execution is done as – “java Output This is a command Line”?
    class Output     {        public static void main(String args[])         {            System.out.print("args");        }    }

Choices:
- This
- java Output This is a command Line
- This is a command Line
- Compilation Error


Question:
What will be the output of the following Java program, Command line execution is done as – “java Output command Line 10 A b 4 N”?
    class Output     {        public static void main(String args[])         {            System.out.print("(int)args[2] * 2");        }    }

Choices:
- java
- 10
- 20
- b


Question:
What will be the output of the following Java program, Command line execution is done as – “java Output command Line 10 A b 4 N”?
    class Output     {        public static void main(String args[])         {            System.out.print("args[6]");        }    }

Choices:
- java
- 10
- b
- N


Question:
What will be the output of the following Java snippet, if attempted to compile and run this code with command line argument “java abc Rakesh Sharma”?
public class abc{	int a=2000;        public static void main(String argv[])        {	    System.out.println(argv[1]+" :-Please pay Rs."+a);        }}

Choices:
- Compile time error
- Compilation but runtime error
- Compilation and output Rakesh :-Please pay Rs.2000
- Compilation and output Sharma :-Please pay Rs.2000


Question:
What will be the output of the following Java snippet, if attempted to compile and execute?
class abc{    public static void main(String args[])    {        if(args.length>0)        System.out.println(args.length);    }}

Choices:
- The snippet compiles, runs and prints 0
- The snippet compiles, runs and prints 1
- The snippet does not compile
- The snippet compiles and runs but does not print anything


Question:
What will be the output of the following Java snippet, if compiled and executed with command line argument “java abc 1 2 3”?
public class abc{   static public void main(String [] xyz)   {       for(int n=1;n<xyz.length; n++)       {          System.out.println(xyz[n]+"");       }   }}

Choices:
- 1 2
- 2 3
- 1 2 3
- Compilation error


Question:
What will be the output of the following Java code snippet running with “java demo I write java code”?
public class demo{   public static void main(String args[])   {        System.out.println(args[0]+""+args[args.length-1]);   }}

Choices:
- The snippet compiles, runs and prints “java demo”
- The snippet compiles, runs and prints “java code”
- The snippet compiles, runs and prints “demo code”
- The snippet compiles, runs and prints “I code”


Question:
What will be the output of the following Java snippet, if compiled and executed with command line “hello there”?
public class abc{    String[] xyz;     public static void main(String argv[])    {        xyz=argv;    }     public void runMethod()    {        System.out.println(argv[1]);    }}

Choices:
- Compile time error
- Output would be “hello”
- Output would be “there”
- Output would be “hello there”


Question:
What will be the output of the following Java code snippet run as $ java Demo –length 512 –breadth 2 -h 3?
class Demo {    @Parameter(names={"--length"})    int length;     @Parameter(names={"--breadth"})    int breadth;     @Parameter(names={"--height","-h"})    int height;     public static void main(String args[])     {        Demo demo = new Demo();        new JCommander(demo, args);        demo.run();    }     public void run()     {        System.out.println(length+" "+ breadth+" "+height);    }}

Choices:
- 2 512 3
- 2 2 3
- 512 2 3
- 512 512 3


Question:
What will be the output of the following Java program?
    class recursion     {        int func (int n)         {            int result;            result = func (n - 1);            return result;        }    }     class Output     {        public static void main(String args[])         {            recursion obj = new recursion() ;            System.out.print(obj.func(12));        }    }

Choices:
- 0
- 1
- Compilation Error
- Runtime Error


Question:
What will be the output of the following Java program?
    class recursion     {        int func (int n)         {            int result;            if (n == 1)                return 1;            result = func (n - 1);            return result;        }    }     class Output     {        public static void main(String args[])         {            recursion obj = new recursion() ;            System.out.print(obj.func(5));        }    }

Choices:
- 0
- 1
- 120
- None of the mentioned


Question:
What will be the output of the following Java program?
    class recursion     {        int fact(int n)         {            int result;            if (n == 1)                return 1;            result = fact(n - 1) * n;            return result;        }    }     class Output     {        public static void main(String args[])         {            recursion obj = new recursion() ;            System.out.print(obj.fact(5));        }    }

Choices:
- 24
- 30
- 120
- 720


Question:
What will be the output of the following Java program?
    class recursion     {        int fact(int n)         {            int result;            if (n == 1)                return 1;            result = fact(n - 1) * n;            return result;        }    }     class Output     {        public static void main(String args[])         {            recursion obj = new recursion() ;            System.out.print(obj.fact(1));        }    }

Choices:
- 1
- 30
- 120
- Runtime Error


Question:
What will be the output of the following Java program?
    class recursion     {        int fact(int n)         {            int result;            if (n == 1)                return 1;            result = fact(n - 1) * n;            return result;        }    }     class Output     {        public static void main(String args[])         {            recursion obj = new recursion() ;            System.out.print(obj.fact(6));        }    }

Choices:
- 1
- 30
- 120
- 720


Question:
At line number 2 in the following code, choose 3 valid data-type attributes/qualifiers among “final, static, native, public, private, abstract, protected”
public interface Status   {        /* insert qualifier here */ int MY_VALUE = 10;   }

Choices:
- final, native, private
- final, static, protected
- final, private, abstract
- final, static, public


Question:
What will be the output of the following Java program?
 class Alligator  {  public static void main(String[] args)    {   int []x[] = {{1,2}, {3,4,5}, {6,7,8,9}};   int [][]y = x;   System.out.println(y[2][1]);   } }

Choices:
- 2
- 3
- 7
- Compilation Error


Question:
What will be the output of the following Java program?
   final class A     {         int i;    }        class B extends A     {        int j;        System.out.println(j + " " + i);      }        class inheritance     {        public static void main(String args[])        {            B obj = new B();            obj.display();             }   }

Choices:
- 2 2
- 3 3
- Runtime Error
- Compilation Error


Question:
What will be the output of the following Java program?
  class Abc  {      public static void main(String[]args)      {          String[] elements = { "for", "tea", "too" };          String first = (elements.length > 0) ? elements[0]: null;      }  }

Choices:
- Compilation error
- An exception is thrown at run time
- The variable first is set to null
- The variable first is set to elements[0]


Question:
What will be the output of the following Java program?
    class A     {        int i;        public void display()         {            System.out.println(i);        }        }        class B extends A    {        int j;        public void display()         {            System.out.println(j);        }     }        class Dynamic_dispatch    {        public static void main(String args[])        {            B obj2 = new B();            obj2.i = 1;            obj2.j = 2;            A r;            r = obj2;            r.display();             }   }

Choices:
- 1
- 2
- 3
- 4


Question:
What will be the output of the following Java program?
    abstract class A     {        int i;        abstract void display();    }        class B extends A     {        int j;        void display()         {            System.out.println(j);        }    }        class Abstract_demo     {        public static void main(String args[])        {            B obj = new B();            obj.j=2;            obj.display();            }    }

Choices:
- 0
- 2
- Runtime Error
- Compilation Error


Question:
What will be the output of the following Java program?
   class A    {	int i;	int j;        A()         {            i = 1;            j = 2;        }   }   class Output    {        public static void main(String args[])        {             A obj1 = new A();             A obj2 = new A();	     System.out.print(obj1.equals(obj2));        }   }

Choices:
- false
- true
- 1
- Compilation Error


Question:
What will be the output of the following Java code?
    class Output     {        public static void main(String args[])        {             Object obj = new Object();	     System.out.print(obj.getclass());        }    }

Choices:
- Object
- class Object
- class java.lang.Object
- Compilation Error


Question:
What will be the output of the following Java code?
   class A    {        int i;	int j;        A()         {            i = 1;            j = 2;        }   }   class Output    {        public static void main(String args[])        {             A obj1 = new A();	     System.out.print(obj1.toString());        }   }

Choices:
- true
- false
- String associated with obj1
- Compilation Error


Question:
What will be the output of the following Java code?
    class A     {        public int i;        private int j;    }        class B extends A     {        void display()         {            super.j = super.i + 1;            System.out.println(super.i + " " + super.j);        }    }        class inheritance    {        public static void main(String args[])        {            B obj = new B();            obj.i=1;            obj.j=2;               obj.display();             }   }

Choices:
- 2 2
- 3 3
- Runtime Error
- Compilation Error


Question:
What will be the output of the following Java code?
    class A     {        public int i;        public int j;        A()        {            i = 1;            j = 2;	}    }        class B extends A     {        int a;	B()         {            super();        }     }        class super_use     {        public static void main(String args[])        {            B obj = new B();            System.out.println(obj.i + " " + obj.j)             }   }

Choices:
- 1 2
- 2 1
- Runtime Error
- Compilation Error


Question:
What will be the output of the following Java code?
    class A     {        int i;        void display()         {            System.out.println(i);        }    }        class B extends A     {        int j;        void display()         {            System.out.println(j);        }    }        class method_overriding     {        public static void main(String args[])        {            B obj = new B();            obj.i=1;            obj.j=2;               obj.display();             }   }

Choices:
- 0
- 1
- 2
- Compilation Error


Question:
What will be the output of the following Java code?
    class A     {        public int i;        protected int j;    }        class B extends A     {        int j;        void display()         {            super.j = 3;            System.out.println(i + " " + j);        }    }        class Output     {        public static void main(String args[])        {            B obj = new B();            obj.i=1;            obj.j=2;               obj.display();             }   }

Choices:
- 1 2
- 2 1
- 1 3
- 3 1


Question:
Which two classes use the Shape class correctly?
A. public class Circle implements Shape
   {
    private int radius;
   }
B. public abstract class Circle extends Shape
   {
    private int radius;
   }
C. public class Circle extends Shape
   {
   private int radius;
   public void draw();
   }
D. public abstract class Circle implements Shape
   {
    private int radius;
    public void draw();
   }
E. public class Circle extends Shape
   {
    private int radius;
    public void draw()
    {
     /* code here */
    }
   }
F. public abstract class Circle implements Shape
   {
     private int radius;
     public void draw()
     {
      /* code here */
     }
   }

Choices:
- B,E
- A,C
- C,E
- T,H


Question:
What will be the output of the following Java program?
    class A     {        int i;        void display()         {            System.out.println(i);        }    }        class B extends A     {        int j;        void display()         {            System.out.println(j);        }    }        class inheritance_demo     {        public static void main(String args[])        {            B obj = new B();            obj.i=1;            obj.j=2;               obj.display();             }   }

Choices:
- 0
- 1
- 2
- Compilation Error


Question:
What will be the output of the following Java program?
    class A     {        int i;    }        class B extends A     {        int j;        void display()         {            super.i = j + 1;            System.out.println(j + " " + i);        }    }        class inheritance     {        public static void main(String args[])        {            B obj = new B();            obj.i=1;            obj.j=2;               obj.display();             }   }

Choices:
- 2 2
- 3 3
- 2 3
- 3 2


Question:
What will be the output of the following Java program?
    class A     {        public int i;        public int j;        A()         {            i = 1;            j = 2;	}    }        class B extends A     {        int a;        B()         {            super();        }     }        class super_use     {        public static void main(String args[])        {            B obj = new B();            System.out.println(obj.i + " " + obj.j)             }   }

Choices:
- 1 2
- 2 1
- Runtime Error
- Compilation Error


Question:
What will be the output of the following Java program?
    class String_demo     {        public static void main(String args[])        {            char chars[] = {'a', 'b', 'c'};            String s = new String(chars);            System.out.println(s);        }   }

Choices:
- a
- b
- c
- abc


Question:
What will be the output of the following Java program?
    class String_demo     {        public static void main(String args[])        {            int ascii[] = { 65, 66, 67, 68};            String s = new String(ascii, 1, 3);            System.out.println(s);        }   }

Choices:
- ABC
- BCD
- CDA
- ABCD


Question:
What will be the output of the following Java program?
    class String_demo     {        public static void main(String args[])        {            char chars[] = {'a', 'b', 'c'};            String s = new String(chars);            String s1 = "abcd";            int len1 = s1.length();            int len2 = s.length();            System.out.println(len1 + " " + len2);        }   }

Choices:
- 3 0
- 0 3
- 3 4
- 4 3


Question:
In the following Java code, what can directly access and change the value of the variable name?
 package test; class Target  {  public String name = "hello"; }

Choices:
- any class
- only the Target class
- any class in the test package
- any class that extends Target


Question:
What will be the output of the following Java code?
public class Boxer1 {    Integer i;    int x;   public Boxer1(int y)    {        x = i+y;        System.out.println(x);   }   public static void main(String[] args)    {       new Boxer1 (new Integer(4));   }}

Choices:
- The value “4” is printed at the command line
- Compilation fails because of an error in line
- A NullPointerException occurs at runtime
- An IllegalStateException occurs at runtime


Question:
What will be the output of the following Java code?
    class output     {        public static void main(String args[])        {            String c = "Hello i love java";           int start = 2;           int end = 9;           char s[]=new char[end-start];           c.getChars(start,end,s,0);           System.out.println(s);        }    }

Choices:
- Hello, i love java
- i love ja
- lo i lo
- llo i l


Question:
What will be the output of the following Java code?
    class output     {        public static void main(String args[])        {            String a = "hello i love java";            System.out.println(a.indexOf('i')+" "+a.indexOf('o') +" "+a.lastIndexOf('i')+" "+a.lastIndexOf('o'));        }    }

Choices:
- 6 4 6 9
- 5 4 5 9
- 7 8 8 9
- 4 3 6 9


Question:
What will be the output of the following Java code?
    class output     {        public static void main(String args[])        {            char ch;            ch = "hello".charAt(1);            System.out.println(ch);        }   }

Choices:
- h
- e
- l
- o


Question:
What will be the output of the following Java code?
    class output     {        public static void main(String args[])        {            String c = "Hello i love java";           boolean var;           var = c.startsWith("hello");           System.out.println(var);        }    }

Choices:
- true
- false
- 0
- 1


Question:
What will be the output of the following Java code?
    class output     {        public static void main(String args[])        {            String s1 = "Hello i love java";           String s2 = new String(s1);           System.out.println((s1 == s2) + " " + s1.equals(s2));        }    }

Choices:
- true true
- false false
- true false
- false true


Question:
What will be the output of the following Java code?
    class output     {        public static void main(String args[])        {            String s1 = "Hello";           String s2 = new String(s1);           String s3 = "HELLO";           System.out.println(s1.equals(s2) + " " + s2.equals(s3));        }    }

Choices:
- true true
- false false
- true false
- false true


Question:
In the following Java code, which code fragment should be inserted at line 3 so that the output will be: “123abc 123abc”?
 1. StringBuilder sb1 = new StringBuilder("123");
 2. String s1 = "123";
 3.  // insert code here
 4. System.out.println(sb1 + " " + s1);

Choices:
- sb1.append(“abc”); s1.append(“abc”);
- sb1.append(“abc”); s1.concat(“abc”);
- sb1.concat(“abc”); s1.append(“abc”);
- sb1.append(“abc”); s1 = s1.concat(“abc”);


Question:
What will be the output of the following Java code?
    class output     {        public static void main(String args[])        {             String chars[] = {"a", "b", "c", "a", "c"};             for (int i = 0; i < chars.length; ++i)                 for (int j = i + 1; j < chars.length; ++j)                     if(chars[i].compareTo(chars[j]) == 0)                         System.out.print(chars[j]);         }   }

Choices:
- ab
- bc
- ca
- ac


Question:
What will s2 contain after following lines of Java code?
 String s1 = "one";
String s2 = s1.concat("two")

Choices:
- one
- two
- onetwo
- twoone


Question:
What will be the output of the following Java program?
    class output     {        public static void main(String args[])        {            String c = "  Hello World  ";           String s = c.trim();           System.out.println("\""+s+"\"");        }    }

Choices:
- “”Hello World””
- “”Hello World”
- “Hello World”
- Hello world


Question:
What will be the output of the following Java program?
    class output     {        public static void main(String args[])        {            String s1 = "one";           String s2 = s1 + " two";           System.out.println(s2);        }    }

Choices:
- one
- two
- one two
- compilation error


Question:
What will be the output of the following Java program?
    class output     {        public static void main(String args[])        {            String s1 = "Hello";           String s2 = s1.replace('l','w');           System.out.println(s2);        }    }

Choices:
- hello
- helwo
- hewlo
- hewwo


Question:
What will be the output of the following Java program?
    class output     {        public static void main(String args[])        {           String s1 = "Hello World";           String s2 = s1.substring(0 , 4);           System.out.println(s2);        }   }

Choices:
- Hell
- Hello
- Worl
- World


Question:
What will be the output of the following Java program?
    class output     {        public static void main(String args[])        {             String s = "Hello World";             int i = s.indexOf('o');             int j = s.lastIndexOf('l');             System.out.print(i + " " + j);         }   }

Choices:
- 4 8
- 5 9
- 4 9
- 5 8


Question:
What is the string contained in s after following lines of Java code?
StringBuffer s new StringBuffer("Hello");
s.deleteCharAt(0);

Choices:
- Hell
- ello
- Hel
- llo


Question:
What will be the output of the following Java program?
    class output     {        public static void main(String args[])        {            String a = "hello i love java";            System.out.println(a.indexOf('e')+" "+a.indexOf('a')+" "+a.lastIndexOf('l')+" "+a.lastIndexOf('v'));        }    }

Choices:
- 6 4 6 9
- 5 4 5 9
- 7 8 8 9
- 1 14 8 15


Question:
What will be the output of the following Java program?
    class output     {        public static void main(String args[])        {              StringBuffer c = new StringBuffer("Hello");             c.delete(0,2);             System.out.println(c);        }    }

Choices:
- He
- Hel
- lo
- llo


Question:
What will be the output of the following Java program?
    class output     {        public static void main(String args[])        {              StringBuffer c = new StringBuffer("Hello");             StringBuffer c1 = new StringBuffer(" World");             c.append(c1);             System.out.println(c);        }    }

Choices:
- Hello
- World
- Helloworld
- Hello World


Question:
What will be the output of the following Java program?
    class output     {        public static void main(String args[])        {            StringBuffer s1 = new StringBuffer("Hello");           StringBuffer s2 = s1.reverse();           System.out.println(s2);        }    }

Choices:
- Hello
- olleH
- HelloolleH
- olleHHello


Question:
What will s2 contain after following lines of Java code?
 StringBuffer s1 = "one";
StringBuffer s2 = s1.append("two")

Choices:
- one
- two
- onetwo
- twoone


Question:
What will be the output of the following Java code?
    class output     {        public static void main(String args[])        {              StringBuffer c = new StringBuffer("Hello");             System.out.println(c.length());        }    }

Choices:
- 4
- 5
- 6
- 7


Question:
What will be the output of the following Java code?
  class output   {        public static void main(String args[])       {            StringBuffer sb=new StringBuffer("Hello");            sb.replace(1,3,"Java");            System.out.println(sb);      }    }

Choices:
- Hello java
- Hellojava
- HJavalo
- Hjava


Question:
What will be the output of the following Java code?
    class output     {        public static void main(String args[])        {            StringBuffer s1 = new StringBuffer("Hello");           s1.setCharAt(1,'x');           System.out.println(s1);        }    }

Choices:
- xello
- xxxxx
- Hxllo
- Hexlo


Question:
What will be the output of the following Java code?
    class output     {        public static void main(String args[])        {           StringBuffer s1 = new StringBuffer("Hello World");           s1.insert(6 , "Good ");           System.out.println(s1);        }   }

Choices:
- HelloGoodWorld
- HellGoodoWorld
- HellGood oWorld
- Hello Good World


Question:
What will be the output of the following Java code?
    class output     {        public static void main(String args[])        {            StringBuffer s1 = new StringBuffer("Hello");           s1.insert(1,"Java");           System.out.println(s1);        }    }

Choices:
- hello
- java
- Hello Java
- HJavaello


Question:
What will be the output of the following Java code?
    class isinfinite_output     {        public static void main(String args[])         {            Double d = new Double(1 / 0.);              boolean x = d.isInfinite();            System.out.print(x);        }    }

Choices:
- 0
- 1
- true
- false


Question:
What will be the output of the following Java code?
    class isNaN_output     {        public static void main(String args[])         {            Double d = new Double(1 / 0.);              boolean x = d.isNaN();            System.out.print(x);        }    }

Choices:
- 0
- 1
- true
- false


Question:
What will be the output of the following Java code?
    class binary     {         public static void main(String args[])          {             int num = 17;             System.out.print(Integer.toBinaryString(num));         }    }

Choices:
- 1001
- 10011
- 11011
- 10001


Question:
What will be the output of the following Java program?
    class Output     {        public static void main(String args[])         {            char a[] = {'a', '5', 'A', ' '};               System.out.print(Character.isDigit(a[0]) + " ");            System.out.print(Character.isWhitespace(a[3]) + " ");            System.out.print(Character.isUpperCase(a[2]));        }    }

Choices:
- true false true
- false true true
- true true false
- false false false


Question:
What will be the output of the following Java program?
    class Output     {        public static void main(String args[])         {            Integer i = new Integer(257);              byte x = i.byteValue();            System.out.print(x);        }    }

Choices:
- 0
- 1
- 256
- 257


Question:
What will be the output of the following Java program?
    class Output     {        public static void main(String args[])         {            Integer i = new Integer(257);              float x = i.floatValue();            System.out.print(x);        }    }

Choices:
- 0
- 1
- 257
- 257.0


Question:
What will be the output of the following Java program?
    class Output     {        public static void main(String args[])         {            Long i = new Long(256);              System.out.print(i.hashCode());        }    }

Choices:
- 256
- 256.0
- 256.00
- 257.00


Question:
What will be the output of the following Java code?
    class Output     {        public static void main(String args[])         {            long start, end;               start = System.currentTimeMillis();            for (int i = 0; i < 10000000; i++);            end = System.currentTimeMillis();            System.out.print(end - start);        }    }

Choices:
- 0
- 1
- 1000
- System Dependent


Question:
What will be the output of the following Java code?
    class Output     {        public static void main(String args[])         {            byte a[] = { 65, 66, 67, 68, 69, 70 };            byte b[] = { 71, 72, 73, 74, 75, 76 };              System.arraycopy(a , 0, b, 0, a.length);            System.out.print(new String(a) + " " + new String(b));        }    }

Choices:
- ABCDEF ABCDEF
- ABCDEF GHIJKL
- GHIJKL ABCDEF
- GHIJKL GHIJKL


Question:
What will be the output of the following Java code?
    class Output     {        public static void main(String args[])         {            byte a[] = { 65, 66, 67, 68, 69, 70 };            byte b[] = { 71, 72, 73, 74, 75, 76 };              System.arraycopy(a, 2, b, 1, a.length-2);            System.out.print(new String(a) + " " + new String(b));        }    }

Choices:
- ABCDEF GHIJKL
- ABCDEF GCDEFL
- GHIJKL ABCDEF
- GCDEFL GHIJKL


Question:
What will be the output of the following Java code?
    class Output     {        public static void main(String args[])         {            byte a[] = { 65, 66, 67, 68, 69, 70 };            byte b[] = { 71, 72, 73, 74, 75, 76 };              System.arraycopy(a, 1, b, 3, 0);            System.out.print(new String(a) + " " + new String(b));        }    }

Choices:
- ABCDEF GHIJKL
- ABCDEF GCDEFL
- GHIJKL ABCDEF
- GCDEFL GHIJKL


Question:
What is the value of “d” in the following Java code snippet?
   double d = Math.round ( 2.5 + Math.random() );

Choices:
- 2
- 3
- 4
- 2.5


Question:
What will be the output of the following Java program?
    class Output     {         public static void main(String args[])          {             int x = 3.14;               int y = (int) Math.abs(x);             System.out.print(y);         }    }

Choices:
- 0
- 3
- 3.0
- 3.1


Question:
What will be the output of the following Java program?
    class Output     {         public static void main(String args[])         {            double x = 3.1;              double y = 4.5;            double z = Math.max( x, y );            System.out.print(z);        }    }

Choices:
- true
- flase
- 3.1
- 4.5


Question:
What will be the output of the following Java program?
    class Output     {         public static void main(String args[])         {            double x = 2.0;              double y = 3.0;            double z = Math.pow( x, y );            System.out.print(z);        }    }

Choices:
- 2.0
- 4.0
- 8.0
- 9.0


Question:
What will be the output of the following Java program?
    import java.lang.System;    class Output    {         public static void main(String args[])         {             long start, end;                start = System.currentTimeMillis();             for (int i = 0; i < 10000000; i++);             end = System.currentTimeMillis();             System.out.print(end - start);         }    }

Choices:
- 0
- 1
- 1000
- System Dependent


Question:
What will be the output of the following Java program?
    import java.lang.System;    class Output     {        public static void main(String args[])        {            byte a[] = { 65, 66, 67, 68, 69, 70 };            byte b[] = { 71, 72, 73, 74, 75, 76 };              System.arraycopy(a, 0, b, 0, a.length);            System.out.print(new String(a) + " " + new String(b));        }    }

Choices:
- ABCDEF ABCDEF
- ABCDEF GHIJKL
- GHIJKL ABCDEF
- GHIJKL GHIJKL


Question:
What will be the output of the following Java program?
    import java.lang.System;    class Output     {        public static void main(String args[])        {            byte a[] = { 65, 66, 67, 68, 69, 70 };            byte b[] = { 71, 72, 73, 74, 75, 76 };              System.arraycopy(a, 0, b, 3, a.length - 3);            System.out.print(new String(a) + " " + new String(b));        }    }

Choices:
- ABCDEF ABCDEF
- ABCDEF GHIJKL
- ABCDEF GHIABC
- GHIJKL GHIJKL


Question:
What will be the output of the following Java program?
    import java.lang.System;    class Output    {        public static void main(String args[])        {            byte a[] = { 65, 66, 67, 68, 69, 70 };            byte b[] = { 71, 72, 73, 74, 75, 76 };              System.arraycopy(a, 2, b, 3, a.length - 4);            System.out.print(new String(a) + " " + new String(b));        }    }

Choices:
- ABCDEF ABCDEF
- ABCDEF GHIJKL
- ABCDEF GHIABC
- ABCDEF GHICDL


Question:
What will be the output of the following Java program?
    import java.lang.System;    class Output     {        public static void main(String args[])        {            System.exit(5);        }    }

Choices:
- 0
- 1
- 4
- 5


Question:
What will be the output of the following Java code?
    class Output     {        public static void main(String args[])        {            Double i = new Double(257.5);              boolean x = i.isNaN();            System.out.print(x);        }    }

Choices:
- true
- false
- 0
- 1


Question:
What will be the output of the following Java code?
    class Output    {        public static void main(String args[])        {            Double i = new Double(257.578);              int x = i.intValue();            System.out.print(x);        }    }

Choices:
- 0
- 1
- 256
- 257


Question:
What will be the output of the following Java code?
    class Output    {        public static void main(String args[])        {	    Double i = new Double(257.578123456789);              float x = i.floatValue();            System.out.print(x);        }    }

Choices:
- 0
- 257.0
- 257.57812
- 257.578123456789


Question:
What will be the output of the following Java code?
    class Output    {        public static void main(String args[])        {            Double y = new Double(257.57812);	    Double i = new Double(257.578123456789);              try            {	        int x = i.compareTo(y);                System.out.print(x);            }            catch(ClassCastException e)            {                System.out.print("Exception");            }	}    }

Choices:
- 0
- 1
- Exception
- None of the mentioned


Question:
What will be the output of the following Java code?
    import java.io.*;    class files     {        public static void main(String args[])         {            File obj = new File("/java/system");            System.out.print(obj.getName());        }    }

Choices:
- java
- system
- java/system


Question:
What will be the output of the following Java program? (Note: file is made in c drive.)
    import java.io.*;    class files     {        public static void main(String args[])         {            File obj = new File("/java/system");            System.out.print(obj.getAbsolutePath());        }    }

Choices:
- java
- system
- java/system
- \java\system


Question:
What will be the output of the following Java program? (Note: file is made in c drive.)
    import java.io.*;    class files     {        public static void main(String args[])         {            File obj = new File("/java/system");            System.out.print(obj.canWrite());            System.out.print(" " + obj.canRead());        }    }

Choices:
- true false
- false true
- true true
- false false


Question:
What will be the output of the following Java program? (Note: file is made in c drive.)
    import java.io.*;    class files     {        public static void main(String args[])         {            File obj = new File("/java/system");            System.out.print(obj.getParent());            System.out.print(" " + obj.isFile());        }    }

Choices:
- java true
- java false
- \java false
- \java true


Question:
What will be the output of the following Java program? (Note: inputoutput.java is stored in the disk.)
    import java.io.*;    class filesinputoutput     {        public static void main(String args[])         {            InputStream obj = new FileInputStream("inputoutput.java");            System.out.print(obj.available());        }    }

Choices:
- true
- false
- prints number of bytes in file
- prints number of characters in the file


Question:
What will be the output of the following Java program?
    import java.io.*;    public class filesinputoutput     {    	public static void main(String[] args)         { 	   String obj  = "abc";           byte b[] = obj.getBytes();           ByteArrayInputStream obj1 = new ByteArrayInputStream(b);           for (int i = 0; i < 2; ++ i)            {               int c;               while ((c = obj1.read()) != -1)                {            	   if(i == 0)                    {            	       System.out.print((char)c);             	   }               }           }        }    }

Choices:
- abc
- ABC
- ab
- AB


Question:
What will be the output of the following Java program?
    import java.io.*;    public class filesinputoutput     {    	public static void main(String[] args)         { 	   String obj  = "abc";           byte b[] = obj.getBytes();           ByteArrayInputStream obj1 = new ByteArrayInputStream(b);           for (int i = 0; i < 2; ++ i)            {               int c;               while ((c = obj1.read()) != -1)                {            	   if (i == 0)                    {                       System.out.print(Character.toUpperCase((char)c));             	   }               }           }        }    }

Choices:
- abc
- ABC
- ab
- AB


Question:
What will be the output of the following Java program?
    import java.io.*;    public class filesinputoutput     {    	public static void main(String[] args)         { 	   String obj  = "abc";           byte b[] = obj.getBytes();           ByteArrayInputStream obj1 = new ByteArrayInputStream(b);           for (int i = 0; i < 2; ++ i)            {               int c;               while ((c = obj1.read()) != -1)                {            	   if (i == 0)                    {                       System.out.print(Character.toUpperCase((char)c));                       obj2.write(1);             	   }               }               System.out.print(obj2);           }        }    }

Choices:
- AaBaCa
- ABCaaa
- AaaBaaCaa
- AaBaaCaaa


Question:
What will be the output of the following Java program?
    import java.io.*;    class Chararrayinput     {        public static void main(String[] args)         {	    String obj  = "abcdef";            int length = obj.length();            char c[] = new char[length];            obj.getChars(0,length,c,0);            CharArrayReader input1 = new CharArrayReader(c);            CharArrayReader input2 = new CharArrayReader(c, 0, 3);            int i;            try             {		while ((i = input1.read()) != -1)                 {                    System.out.print((char)i);                }       	    }             catch (IOException e)             {	        // TODO Auto-generated catch block                e.printStackTrace();	    }	}    }

Choices:
- abc
- abcd
- abcde
- abcdef


Question:
What will be the output of the following Java program?
    import java.io.*;    class Chararrayinput     {        public static void main(String[] args)         {	    String obj  = "abcdef";            int length = obj.length();            char c[] = new char[length];            obj.getChars(0, length, c, 0);            CharArrayReader input1 = new CharArrayReader(c);            CharArrayReader input2 = new CharArrayReader(c, 0, 3);            int i;            try             {		while ((i = input2.read()) != -1)                 {                    System.out.print((char)i);                }       	    }             catch (IOException e)             {	        // TODO Auto-generated catch block                e.printStackTrace();	    }	}    }

Choices:
- abc
- abcd
- abcde
- abcdef


Question:
What will be the output of the following Java program?
    import java.io.*;    class Chararrayinput     {        public static void main(String[] args)         {	    String obj  = "abcdefgh";            int length = obj.length();            char c[] = new char[length];            obj.getChars(0, length, c, 0);            CharArrayReader input1 = new CharArrayReader(c);            CharArrayReader input2 = new CharArrayReader(c, 1, 4);            int i;            int j;            try             {		while ((i = input1.read()) == (j = input2.read()))                 {                    System.out.print((char)i);                }       	    }             catch (IOException e)             {	        // TODO Auto-generated catch block                e.printStackTrace();	    }	}    }

Choices:
- abc
- abcd
- abcde
- none of the mentioned


Question:
What will be the output of the following Java program?
    class exception_handling     {        public static void main(String args[])         {            try             {                int a[] = {1, 2,3 , 4, 5};                for (int i = 0; i < 7; ++i)                     System.out.print(a[i]);            }            catch(ArrayIndexOutOfBoundsException e)             {        	System.out.print("0");        	            }        }    }

Choices:
- 12345
- 123450
- 1234500
- Compilation Error


Question:
What will be the output of the following Java program?
    class exception_handling     {        public static void main(String args[])         {            try             {                int a[] = {1, 2,3 , 4, 5};                for (int i = 0; i < 5; ++i)                     System.out.print(a[i]);                int x = 1/0;            }            catch(ArrayIndexOutOfBoundsException e)             {        	System.out.print("A");        	            }            catch(ArithmeticException e)             {     	                System.out.print("B");            }        }    }

Choices:
- 12345
- 12345A
- 12345B
- Compilation Error


Question:
What will be the output of the following Java program?
    class exception_handling     {            static void throwexception() throws ArithmeticException             {                        System.out.print("0");                throw new ArithmeticException ("Exception");            }            public static void main(String args[])             {            try             {                throwexception();            }            catch (ArithmeticException e)             {                    System.out.println("A");            }        }    }

Choices:
- A
- 0
- 0A
- Exception


Question:
What will be the output of the following Java program?
    class exception_handling     {        public static void main(String args[])         {            try              {                int a = 1;                int b = 10 / a;                try                 {                     if (a == 1)                         a = a / a - a;                     if (a == 2)                      {                         int c[] = {1};                         c[8] = 9;                     }                finally                 {                    System.out.print("A");                }             }            catch (NullPointerException e)             {                    System.out.println("B");            }        }    }

Choices:
- A
- B
- AB
- BA


Question:
What will be the output of the following Java code?
    class A     {         int x;         int y;         void display()          {              System.out.print(x + " " + y);         }    }    class Output     {         public static void main(String args[])          {             A obj1 = new A();             A obj2 = new A();             obj1.x = 1;             obj1.y = 2;             obj2 = obj1.clone();             obj1.display();             obj2.display();         }    }

Choices:
- 1 2 0 0
- 1 2 1 2
- 0 0 0 0
- System Dependent


Question:
What will be the output of the following Java code?
    class Output     {         public static void main(String args[])          {             double x = 3.14;               int y = (int) Math.abs(x);             System.out.print(y);         }    }

Choices:
- 0
- 3
- 3.0
- 3.1


Question:
What will be the output of the following Java code?
    class Output     {         public static void main(String args[])          {             double x = 3.14;               int y = (int) Math.ceil(x);             System.out.print(y);         }    }

Choices:
- 0
- 3
- 3.0
- 4


Question:
What will be the output of the following Java code?
    class Output     {         public static void main(String args[])          {             double x = 3.14;               int y = (int) Math.floor(x);             System.out.print(y);         }    }

Choices:
- 0
- 3
- 3.0
- 4


Question:
What will be the output of the following Java code?
    class Output     {        public static void main(String args[])        {            Double i = new Double(257.5);              Double x = i.MAX_VALUE;            System.out.print(x);        }    }

Choices:
- 0
- 1.7976931348623157E30
- None of the mentioned


Question:
What will be the output of the following Java program?
    class Output    {        public static void main(String args[])        {            Double i = new Double(257.5);              Double x = i.MIN_VALUE;            System.out.print(x);        }    }

Choices:
- 0
- 4.9E-324
- None of the mentioned


Question:
What will be the output of the following Java program?
    class Output     {        public static void main(String args[])        {	    Double i = new Double(257.578123456789);              float x = i.floatValue();            System.out.print(x);        }    }

Choices:
- 0
- 257.0
- 257.57812
- 257.578123456789


Question:
What will be the output of the following Java program?
    class Output     {        public static void main(String args[])         {            int a = Character.MAX_VALUE;            System.out.print((char)a);        }    }


Question:
What will be the output of the following Java program?
    class Output    {        public static void main(String args[])        {            int a = Character.MIN_VALUE;            System.out.print((char)a);        }    }

Choices:
- Space


Question:
What will be the output of the following Java program?
    class Output     {         public static void main(String args[])         {             char a[] = {'a', '5', 'A', ' '};                System.out.print(Character.isDigit(a[0])+ " ");             System.out.print(Character.isWhitespace(a[3])+ " ");             System.out.print(Character.isUpperCase(a[2]));        }    }

Choices:
- true false true
- false true true
- true true false
- false false false


Question:
What will be the output of the following Java program?
    class Output    {        public static void main(String args[])        {	    char a = (char) 98;            a = Character.toUpperCase(a);            System.out.print(a);        }    }

Choices:
- b
- c
- B
- C


Question:
What will be the output of the following Java program?
    class Output    {        public static void main(String args[])        {	    char a = '@';            boolean x = Character.isLetter(a);            System.out.print(x);        }    }

Choices:
- true
- false
- B


Question:
What will be the output of the following Java program?
    class Output    {        public static void main(String args[])        {            String str = "true";            boolean x = Boolean.valueOf(str);            System.out.print(x);        }    }

Choices:
- True
- False
- Compilation Error
- Runtime Error


Question:
What will be the output of the following Java program?
    class Output    {        public static void main(String args[])        {            String str = "true false true";            boolean x = Boolean.valueOf(str);            System.out.print(x);        }    }

Choices:
- True
- False
- Compilation Error
- Runtime Error


Question:
What will be the output of the following Java program?
    class Output    {        public static void main(String args[])        {            String str = "TRUE";            boolean x = Boolean.valueOf(str);            System.out.print(x);        }    }

Choices:
- True
- False
- Compilation Error
- Runtime Error


Question:
What will be the output of the following Java program?
    class Output     {        public static void main(String args[])        {	    String str = "true false";            boolean x = Boolean.parseBoolean(str);            System.out.print(x);        }    }

Choices:
- True
- False
- System Dependent
- Compilation Error


Question:
What will be the output of the following Java program?
    class Output    {        public static void main(String args[])         {	   String x = Boolean.toString(false);        }    }

Choices:
- True
- False
- System Dependent
- Compilation Error


Question:
What will be the output of the following Java program?
    class Output     {        public static void main(String args[])         {            double x = 3.14;              int y = (int) Math.toDegrees(x);            System.out.print(y);        }    }

Choices:
- 0
- 179
- 180
- 360


Question:
What will be the output of the following Java program?
    class Output     {        public static void main(String args[])         {            double x = 3.14;              int y = (int) Math.toRadians(x);            System.out.print(y);        }    }

Choices:
- 0
- 3
- 3.0
- 3.1


Question:
What will be the output of the following Java program?
    class Output     {        public static void main(String args[])         {            double x = 102;            double y = 5;            double z = Math.IEEEremainder(x, y);            System.out.print(z);}         }    }

Choices:
- 0
- 1
- 2
- 3


Question:
Will this Java program generate same output is executed again?
    class Output     {        public static void main(String args[])         {            int y = double z = Math.random();            System.out.print(y);        }    }

Choices:
- Yes
- No
- Compiler Dependent
- Operating System Dependent


Question:
What will be the output of the following Java program?
    class X     {        int a;        double b;    }    class Y extends X     {	int c;    }    class Output     {        public static void main(String args[])         {            X a = new X();            Y b = new Y();            Class obj;            obj = b.getClass();            System.out.print(obj.getSuperclass());        }    }

Choices:
- X
- Y
- class X
- class Y


Question:
What will be the output of the following Java program?
    class X     {        int a;        double b;    }    class Y extends X     {	int c;    }    class Output     {        public static void main(String args[])         {            X a = new X();            Y b = new Y();            Class obj;            obj = b.getClass();            System.out.print(b.equals(a));        }    }

Choices:
- 0
- 1
- true
- false


Question:
What will be the output of the following Java program?
    class X     {        int a;        double b;    }    class Y extends X     {	int c;    }    class Output     {        public static void main(String args[])         {            X a = new X();            Y b = new Y();            Class obj;            obj = b.getClass();            System.out.print(obj.isInstance(a));        }    }

Choices:
- 0
- 1
- true
- false


Question:
What will be the output of the following Java program?
    class X     {        int a;        double b;    }    class Y extends X     {	int c;    }    class Output     {        public static void main(String args[])         {            X a = new X();            Y b = new Y();            Class obj;            obj = a.getClass();            System.out.print(obj.getName());        }    }

Choices:
- X
- Y
- a
- b


Question:
What will be the output of the following Java program?
    class X    {        int a;        double b;    }    class Y extends X     {	int c;    }    class Output     {        public static void main(String args[])         {            X a = new X();            Y b = new Y();            Class obj;            obj = b.getClass();            System.out.print(obj.getSuperclass());        }    }

Choices:
- X
- Y
- class X
- class Y


Question:
What will be the output of the following Java program?
    class X     {        int a;        double b;    }    class Y extends X     {	int c;    }    class Output     {        public static void main(String args[])         {            X a = new X();            Y b = new Y();            Class obj;            obj = b.getClass();            System.out.print(obj.isLocalClass());        }    }

Choices:
- 0
- 1
- true
- false


Question:
What will be the output of the following Java program?
    class newthread implements Runnable     {	Thread t1,t2;        newthread()         {            t1 = new Thread(this,"Thread_1");            t2 = new Thread(this,"Thread_2");            t1.start();            t2.start();	}	public void run()         {            t2.setPriority(Thread.MAX_PRIORITY);		    System.out.print(t1.equals(t2));        }        }    class multithreaded_programing     {        public static void main(String args[])         {            new newthread();                }    }

Choices:
- true
- false
- truetrue
- falsefalse


Question:
What will be the output of the following Java program?
    class newthread implements Runnable     {	Thread t;        newthread()         {            t = new Thread(this,"New Thread");            t.start();	}	public void run()        {            t.setPriority(Thread.MAX_PRIORITY);	            System.out.println(t);	}    }    class multithreaded_programing     {        public static void main(String args[])         {            new newthread();                }    }

Choices:
- Thread[New Thread,0,main]
- Thread[New Thread,1,main]
- Thread[New Thread,5,main]
- Thread[New Thread,10,main]


Question:
What will be the output of the following Java program?
    class newthread implements Runnable     {	Thread t;        newthread()         {            t = new Thread(this,"My Thread");            t.start();	}    }    class multithreaded_programing     {        public static void main(String args[])         {            new newthread();                }    }

Choices:
- My Thread
- Thread[My Thread,5,main]
- Compilation Error
- Runtime Error


Question:
What will be the output of the following Java program?
    class newthread implements Runnable     {	Thread t;        newthread()         {            t = new Thread(this,"My Thread");            t.start();	}	public void run()         {	    System.out.println(t.getName());	}    }    class multithreaded_programing     {        public static void main(String args[])         {            new newthread();                }    }

Choices:
- My Thread
- Thread[My Thread,5,main]
- Compilation Error
- Runtime Error


Question:
What will be the output of the following Java program?
    class newthread implements Runnable     {	Thread t;        newthread()         {            t = new Thread(this,"My Thread");            t.start();	}	public void run()         {	    System.out.println(t);	}    }    class multithreaded_programing     {        public static void main(String args[])         {            new newthread();                }    }

Choices:
- My Thread
- Thread[My Thread,5,main]
- Compilation Error
- Runtime Error


Question:
What will be the output of the following Java program?
    import java.io.*;    class serialization     {        public static void main(String[] args)         {            try             {                Myclass object1 = new Myclass("Hello", -7, 2.1e10);	        FileOutputStream fos = new FileOutputStream("serial");	        ObjectOutputStream oos = new ObjectOutputStream(fos);                oos.writeObject(object1);                oos.flush();                oos.close();	    }	    catch(Exception e)             {	        System.out.println("Serialization" + e);                System.exit(0);            }	    try              {                Myclass object2;	        FileInputStream fis = new FileInputStream("serial");	        ObjectInputStream ois = new ObjectInputStream(fis);                object2 = (Myclass)ois.readObject();                ois.close();	        System.out.println(object2);		    		    }	    catch (Exception e)             {                System.out.print("deserialization" + e);	        System.exit(0);	    }        }    }    class Myclass implements Serializable     {	String s;	int i;	double d;        Myclass (String s, int i, double d)        {	    this.d = d;	    this.i = i;	    this.s = s;	}    }

Choices:
- s=Hello; i=-7; d=2.1E10
- Hello; -7; 2.1E10
- s; i; 2.1E10
- Serialization


Question:
What will be the output of the following Java program?
    import java.io.*;    class serialization     {        public static void main(String[] args)         {            try             {                Myclass object1 = new Myclass("Hello", -7, 2.1e10);	        FileOutputStream fos = new FileOutputStream("serial");	        ObjectOutputStream oos = new ObjectOutputStream(fos);                oos.writeObject(object1);                oos.flush();                oos.close();	    }	    catch(Exception e)             {	        System.out.println("Serialization" + e);                System.exit(0);            }	    try            {	        int x;	        FileInputStream fis = new FileInputStream("serial");	        ObjectInputStream ois = new ObjectInputStream(fis);                x = ois.readInt();                ois.close();	        System.out.println(x);		    		    }	    catch (Exception e)            {                System.out.print("deserialization");	        System.exit(0);	    }        }    }    class Myclass implements Serializable    {	String s;	int i;	double d;        Myclass(String s, int i, double d)        {	    this.d = d;	    this.i = i;	    this.s = s;	}    }

Choices:
- -7
- Hello
- 2.1E10
- deserialization


Question:
What will be the output of the following Java program?
    import java.io.*;    class Chararrayinput    {        public static void main(String[] args)         {	    String obj  = "abcdefgh";            int length = obj.length();            char c[] = new char[length];            obj.getChars(0, length, c, 0);            CharArrayReader input1 = new CharArrayReader(c);            CharArrayReader input2 = new CharArrayReader(c, 1, 4);            int i;            int j;            try             {		while ((i = input1.read()) == (j = input2.read()))                {                    System.out.print((char)i);                }       	    }             catch (IOException e)             {                e.printStackTrace();	    }	}    }

Choices:
- abc
- abcd
- abcde
- None of the mentioned


Question:
What will be the output of the following Java program?
    import java.io.*;    class streams    {        public static void main(String[] args)         {            try            {	        FileOutputStream fos = new FileOutputStream("serial");	        ObjectOutputStream oos = new ObjectOutputStream(fos);                oos.writeFloat(3.5);                oos.flush();                oos.close();	    }	    catch(Exception e)            {	        System.out.println("Serialization" + e);                System.exit(0);            }	    try             {	        float x;	        FileInputStream fis = new FileInputStream("serial");	        ObjectInputStream ois = new ObjectInputStream(fis);                x = ois.readInt();                ois.close();	        System.out.println(x);		    		    }	    catch (Exception e)            {                System.out.print("deserialization");	        System.exit(0);	    }        }    }

Choices:
- 3
- 3.5
- serialization
- deserialization


Question:
What will be the output of the following Java code?
    import java.io.*;    class streams     {        public static void main(String[] args)        {            try             {	        FileOutputStream fos = new FileOutputStream("serial");	        ObjectOutputStream oos = new ObjectOutputStream(fos);	        oos.writeInt(5);	        oos.flush();	        oos.close();	    }	    catch(Exception e)            {	        System.out.println("Serialization" + e);                System.exit(0);            }	    try            {	        int z;	        FileInputStream fis = new FileInputStream("serial");	        ObjectInputStream ois = new ObjectInputStream(fis);	        z = ois.readInt();	        ois.close();	        System.out.println(x);		    		    }	    catch (Exception e)             {                System.out.print("deserialization");	        System.exit(0);	    }        }    }

Choices:
- 5
- void
- serialization
- deserialization


Question:
What will be the output of the following Java code?
    import java.io.*;    class serialization    {        public static void main(String[] args)        {            try            {	        Myclass object1 = new Myclass("Hello", -7, 2.1e10);	        FileOutputStream fos = new FileOutputStream("serial");	        ObjectOutputStream oos = new ObjectOutputStream(fos);	        oos.writeObject(object1);	        oos.flush();	        oos.close();	    }	    catch(Exception e)            {	        System.out.println("Serialization" + e);                System.exit(0);            }	    try            {	        int x;	        FileInputStream fis = new FileInputStream("serial");	        ObjectInputStream ois = new ObjectInputStream(fis);	        x = ois.readInt();	        ois.close();	        System.out.println(x);		    		    }	    catch (Exception e)            {                System.out.print("deserialization");	        System.exit(0);	    }        }    }    class Myclass implements Serializable    {	String s;	int i;	double d;	Myclass(String s, int i, double d)        {	    this.d = d;	    this.i = i;	    this.s = s;	}    }

Choices:
- -7
- Hello
- 2.1E10
- deserialization


Question:
What will be the output of the following Java program?
    import java.io.*;    class streams    {        public static void main(String[] args)        {            try            {	        FileOutputStream fos = new FileOutputStream("serial");	        ObjectOutputStream oos = new ObjectOutputStream(fos);	        oos.writeFloat(3.5);	        oos.flush();	        oos.close();	    }	    catch(Exception e)            {	        System.out.println("Serialization" + e);                System.exit(0);            }	    try            {	        FileInputStream fis = new FileInputStream("serial");	        ObjectInputStream ois = new ObjectInputStream(fis);	        ois.close();	        System.out.println(ois.available());		    		    }	    catch (Exception e)            {                System.out.print("deserialization");	        System.exit(0);	    }        }    }

Choices:
- 1
- 2
- 3
- 0


Question:
What will be the output of the following Java program?
    import java.io.*;    class streams    {        public static void main(String[] args)        {            try            {	        FileOutputStream fos = new FileOutputStream("serial");	        ObjectOutputStream oos = new ObjectOutputStream(fos);	        oos.writeFloat(3.5);	        oos.flush();	        oos.close();	    }	    catch(Exception e)            {	        System.out.println("Serialization" + e);                System.exit(0);            }	    try            {	        FileInputStream fis = new FileInputStream("serial");	        ObjectInputStream ois = new ObjectInputStream(fis);	        System.out.println(ois.available());		    		    }	    catch (Exception e)             {                System.out.print("deserialization");	        System.exit(0);	    }        }    }

Choices:
- 1
- 2
- 3
- 4


Question:
What will be the output of the following Java program?
import java.io.FileOutputStream;  public class FileOutputStreamExample{      public static void main(String args[])    {               try           {                 FileOutputStream fout=new FileOutputStream("D:\\sanfoundry.txt");                 String s="Welcome to Sanfoundry.";                 byte b[]=s.getBytes();//converting string into byte array                 fout.write(b);                 fout.close();                 System.out.println("Success");                }  catch(Exception e){System.out.println(e);}          }    }

Choices:
- “Success” to the output and “Welcome to Sanfoundry” to the file
- only “Welcome to Sanfoundry” to the file
- compile time error
- No Output


Question:
What will be the output of the following Java program?
    import java.net.*;    class networking     {        public static void main(String[] args) throws UnknownHostException         {            InetAddress obj1 = InetAddress.getByName("sanfoundry.com");            InetAddress obj2 = InetAddress.getByName("sanfoundry.com");            boolean x = obj1.equals(obj2);             System.out.print(x);        }    }

Choices:
- 0
- 1
- true
- false


Question:
What will be the output of the following Java program?
    import java.net.*;    public class networking     {        public static void main(String[] args) throws UnknownHostException         {            InetAddress obj1 = InetAddress.getByName("cisco.com");            InetAddress obj2 = InetAddress.getByName("sanfoundry.com");            boolean x = obj1.equals(obj2);             System.out.print(x);        }    }

Choices:
- 0
- 1
- true
- false


Question:
What will be the output of the following Java program?
import java.io.*;  import java.net.*;  public class URLDemo {      public static void main(String[] args)     {          try         {              URL url=new URL("https://www.sanfoundry.com/java-mcq");              System.out.println("Protocol: "+url.getProtocol());              System.out.println("Host Name: "+url.getHost());              System.out.println("Port Number: "+url.getPort());           } catch(Exception e){System.out.println(e);}      }  }

Choices:
- Protocol: http
- Host Name: www.sanfoundry.com
- Port Number: -1
- All of the mentioned