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 

16. Which two statements are true about the hashCode method? (Choose two.)

  • The hashCode method for a given class can be used to test for object equality and object inequality for that class.
  • The hashCode method is used by the java.util.SortedSet collection class to order the elements within that set.
  • The hashCode method for a given class can be used to test for object inequality, but NOT object equality for that class.
  • The only important characteristic of the values returned by a hashCode method is that the distribution of valus must follow a Gaussian distribution.
  • The hashCode method is used by the java.util.HashSet collection class to group the elements within that set into hash buckets for swift retrieval.

17. Which class does NOT override the equals() and hashCode() methods, inheriting them directly from class Object?

  • java.lang.String
  • java.lang.Double
  • java.lang.StringBuffer
  • java.lang.Character

18. Which collection class allows you to grow or shrink its size and provides indexed access to its elements, but whose methods are not synchronized?

  • java.util.HashSet
  • java.util.LinkedHashSet
  • java.util.List
  • java.util.ArrayList

19. You need to store elements in a collection that guarantees that no duplicates are stored and all elements can be accessed in natural order. Which interface provides that capability?

  • java.util.Map
  • java.util.Set
  • java.util.List
  • java.util.Collection

20. Lambdas introduced in Java 8 allow us to treat -

  • Data as code
  • Code as data
  • none
  • all