Logo

Java Questions Set 188:

Quiz Mode

java.rmi package is used for invoking a method remotely  

1
2

Solution:

Which value is typically returned under normal termination of a program?

1
2
3
4

Solution:

Which method is used to verify the actual and expected results in JUnit?

1
2
3
4

Solution:

Which of the following lines give an error?

1
2
3
4

Solution:

Which method returns the remainder of dividend/divisor?

1
2
3
4

Solution:

Which of the following methods is used to copy data from one array to another?

1
2
3
4

Solution:

Which Java collection class allows you to associate its elements with key values, and retrieve objects in FIFO (first-in, first-out) order?

1
2
3
4

Solution:

What is the purpose of using wildcards in programming?

1
2
3
4

Solution:

What is the output of the following Java code?

import java.util.*;

import java.util.function.Predicate;

class Abekus {

public static void main(String args[]) {

List<String> L =

Arrays.asList("Amrit","Gautam","Abinash","Kajal","Anand");

Predicate<String> S = (s)->s.startsWith("A");

for (String i:L) {

if (S.test(i))

System.out.print(i + " ");

}

}

}

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.print(list.getLast() + " " +list.peekFirst() + " "+ list.peekLast());

        }

    }

1
2
3
4

Solution: