Logo

Java Questions Set 122:

Quiz Mode

Garbage collection is the process of freeing unused memory in the

1
2
3
4

Solution:

 Which of these return type of hasNext() method of an iterator 

1
2
3
4

Solution:

Which part of the code gets executed whether an exception is caught or not?

1
2
3
4

Solution:

Which of the following cannot be type parameterized?

1
2
3
4

Solution:

Select the correct option for a valid string declaration in Java.

1
2
3
4

Solution:

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

}

}

1
2
3
4

Solution:

How can a protected modifier be accessed?

1
2
3
4

Solution:

What will be the output of the following Java program?

class Abekus {
   int i;
}

class Main {
   public static void main(String args[]) {
   Abekus a = new Abekus();
   System.out.println(a.i);
   }
}

1
2
3
4

Solution:

public class abekus{

public static void main(String[] args){

 int a = 0;

 a +=5;

 int b=5;

 switch(a+b){

  case 5: System.out.print("five"); break;

  case 10: 

  if(a%2==0) System.out.print("even");

  else System.out.print("odd");

  break;

  default: System.out.print("0-2");

 }

}

}

1
2
3
4

Solution:

import java.util.*;

   public class outputs 

   {

       public static void main(String args[]) 

       {

           LinkedList list = new LinkedList();

           list.add(new Integer(3));

           list.add(new Integer(9));

           list.add(new Integer(5));

           list.add(new Integer(1));

   list.addFirst(new Integer(6));

   list.addLast(new Integer(9));

           Iterator i = list.iterator();

       Collections.sort(list);

System.out.println(list.peekFirst());

       }

   }

1
2
3
4

Solution: