Loading, please wait...

Core Java Multiple Choice Questions And Answers

Search here for MCQs

Are you preparing for the next job interviews? If yes, trust me this post will help you also we'll suggest you check out a big collection for Programming Full Forms that may help you in your interview:

List of Programming Full Forms 

11. Which statement is true for the class java.util.HashSet?

  • The elements in the collection are ordered.
  • The collection is guaranteed to be immutable.
  • The elements in the collection are guaranteed to be unique.
  • The elements in the collection are accessed using a unique key.
  • The elements in the collections are guaranteed to be synchronized.

12. What are the two acceptable types for the variable i? (Choose Two)

Given:

switch (i)
{
   default:
   System.out.printIn("Hello");
}
  • Char
  • Byte
  • Float
  • Double
  • Object

13. What is the result?

public class foo
{
public static void main (string[]args)
{
try
{
return;
}
finally
{
system.out.printIn("Finally");
}
}
}
  • The program runs and prints nothing.
  • The program runs and prints "Finally"
  • The code compiles, but an exception is thrown at runtime.
  • The code will not compile because the catch block is missing.

14. Which two statements are true? (Choose two)

  • An encapsulation, public class promotes re-use.
  • Classes that share the same interface are always tightly encapsulated.
  • An encapsulated class allows subclasses to overload methods, but does NOT allow overriding methods.
  • An encapsulated class allows programmer to change an implementation without affecting outside code.

15. A programmer has an algorithm that requires a java.util.List that provides an efficient implementation of add(0, object), but does NOT need to support quick random access. What supports these requirements?

  • java.util.Queue
  • java.util.ArrayList
  • java.util.LinkedList