Logo

Java Questions Set 123:

Quiz Mode

What is the output of the following Java code?

1
2
3
4

Solution:

ArrayList is an ordered collection which grows dynamically

1
2

Solution:

Which type parameter is commonly used in a generic class to represent any type of object?

1
2
3
4

Solution:

What does JNDI stand for?

1
2
3
4

Solution:

What is polymorphism in object-oriented programming (OOP)?

1
2
3
4

Solution:

Which of the options describe the correct default values for array elements?

1
2
3
4

Solution:

class A {

       public static void main(String args[]) 

       {

           boolean var1 = true;

   boolean var2 = false;

   if (var1)

       System.out.println(var1);

   else

       System.out.println(var2);

      } 

   }

1
2
3
4

Solution:

What is the output of the following Java code?

class CommaOperator {

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);

}

}

1
2
3
4

Solution:

What is the output of the following program?

public class Test

{

  private static float temp()

  {

    public static float sum = 21;

    return(--(sum));

  }

  public static void main(String[] args)

  {

    Test test = new Test();

    System.out.println(test.temp());

  }

}  

1
2
3
4

Solution:

 

1. class square_root 

2.     {

3.         public static void main(String args[]) 

4.         {

5.             double a, b;

6.             a = 8.0;

7.             b = 6.0;

8.      double c = Math.sqrt(a * a + b * b);

9.      System.out.println(c);

10.         } 

11.     }

1
2
3
4

Solution: