Logo

Java Questions Set 8:

Quiz Mode

Can a class be declared with a protected modifier in Java?

1
2

Solution:

How many types of collection mapping are possible in Hibernate?

1
2
3
4

Solution:

Which of the following is not an operator in Java?

1
2
3
4

Solution:

What is the return type of a method that does not return any value?

1
2
3
4

Solution:

Which of the following methods can convert an object to a list?

1
2
3
4

Solution:

All the classes in Java are derived from which class?

1
2
3
4

Solution:

What is the output of the following code?

class Test

{

public static void main(String args[])

{

int ascii[] = { 65, 66, 67, 68};

String s = new String(ascii, 1, 3);

System.out.println(s);

}

}

1
2
3
4

Solution:

class test{

public static void main (String[] args) {

   int x=10,y=15;

   if(++x<10 && ++y>15)

   {

       x++;

   }

   else

   {

       y++;    

   }

   System.out.println(x+" "+y);

}

}

1
2
3
4

Solution:

What is the output of this program?

 class Area

    {

        int breadth;

        int length;

    } 

    class mainclass 

    {

        public static void main(String args[]) 

        {        

             Area a = new Area();

             a.breadth = 10;

             a.length = 15;

             int area = a.breadth * a.length; 

             System.out.print(area);

        } 

    }

1
2
3
4

Solution:

 class method 

    {

        public int i;

     static int j;

        void add(int a , int b)

        {

            i =++j + ++b;

            j =++i + b++;

        }

    }    

    class output 

    {

        public static void main(String args[])

        {

            method obj1 = new method();

            method obj2 = new method();   

            int a = 5;

            obj1.add(++a, ++a + 1);

            obj2.add(6, a);

            System.out.println(obj1.i+" "+obj2.j);     

        }

   }

1
2
3
4

Solution: