Java Quest Online Quiz

10 Questions | Total Attempts: 41

SettingsSettingsSettings
Please wait...
Java Quizzes & Trivia

Questions and Answers
  • 1. 
    Which statement is true? (Choose all that apply)
    • A. 

      The invocation of an object’s finalized method is always the last thing that happens before an object is garbage collected.

    • B. 

      When a stack variable goes out of scope it is eligible for GC.

    • C. 

      Some reference variables live on the stack, and some live on the heap.

    • D. 

      Only objects that have no reference variables referring to them can be eligible for GC.

    • E. 

      It’s possible to request the GC via methods in either java.lang.Runtime or java.lang.System classes.

  • 2. 
    Which are most typically thrown by an API developer or an application developer as opposed to being thrown by the JVM? (Choose all that apply.)
    • A. 

      ClassCastException

    • B. 

      IllegalStateException

    • C. 

      NumberFormatException

    • D. 

      IllegalArgumentException

    • E. 

      ExceptionInInitializerError

  • 3. 
    Which about the three java.lang classes String, StringBuilder, and StringBuffer are true? (Choose all that apply.)
    • A. 

      All three classes have a length() method.

    • B. 

      Objects of type StringBuffer are thread-safe.

    • C. 

      All three classes have overloaded append() methods.

    • D. 

      The "+" is an overloaded operator for all three classes.

    • E. 

      According to the API, StringBuffer will be faster than StringBuilder under most implementations.

    • F. 

      The value of an instance of any of these three types can be modified through various methods in the API.

  • 4. 
    Which are true? (Choose all that apply.)
    • A. 

      The DateFormat.getDate() is used to convert a String to a Date instance.

    • B. 

      Both DateFormat and NumberFormat objects can be constructed to be Locale specific.

    • C. 

      Both Currency and NumberFormat objects must be constructed using static methods.

    • D. 

      If a NumberFormat instance's Locale is to be different than the current Locale, it must be specified at creation time.

    • E. 

      A single instance of NumberFormat can be used to create Number objects from Strings and to create formatted numbers from numbers.

  • 5. 
    Which collection class(es) allows you to grow or shrink its size and provides indexed access to its elements, but whose methods are not synchronized? (Choose all that apply.)
    • A. 

      Java.util.HashSet

    • B. 

      Java.util.LinkedHashSet

    • C. 

      Java.util.List

    • D. 

      Java.util.ArrayList

    • E. 

      Java.util.Vector

    • F. 

      Java.util.PriorityQueue

  • 6. 
    Which statements are true about comparing two instances of the same class, given that the equals() and hashCode() methods have been properly overridden? (Choose all that apply.)
    • A. 

      If the equals() method returns true, the hashCode() comparison == might return false.

    • B. 

      If the equals() method returns false, the hashCode() comparison == might return true.

    • C. 

      If the hashCode() comparison == returns true, the equals() method must return true.

    • D. 

      If the hashCode() comparison == returns true, the equals() method might return true.

    • E. 

      If the hashCode() comparison != returns true, the equals() method might return true.

  • 7. 
    Which are true about a method-local inner class? (Choose all that apply.)
    • A. 

      It must be marked final.

    • B. 

      It can be marked abstract.

    • C. 

      It can be marked public.

    • D. 

      It can be marked static.

    • E. 

      It can access private members of the enclosing class.

  • 8. 
    Which are true? (Choose all that apply.) 
    • A. 

      The notifyAll() method must be called from a synchronized context.

    • B. 

      To call wait(), an object must own the lock on the thread.

    • C. 

      The notify() method is defined in class java.lang.Thread.

    • D. 

      When a thread is waiting as a result of wait(), it release its lock.

    • E. 

      The notify() method causes a thread to immediately release its lock.

    • F. 

      The difference between notify() and notifyAll() is that notifyAll() notifies all waiting threads, regardless of the object they're waiting on.

  • 9. 
    Which are methods of the Object class? (Choose all that apply.)
    • A. 

      Notify();

    • B. 

      NotifyAll();

    • C. 

      IsInterrupted();

    • D. 

      Synchronized();

    • E. 

      Interrupt();

    • F. 

      Wait(long msecs);

    • G. 

      Sleep(long msecs);

  • 10. 
    Which interface provides the capability to store objects using a key-value pair?
    • A. 

      Java.util.Map

    • B. 

      Java.util.Set

    • C. 

      Java.util.List

    • D. 

      Java.util.Collection

Back to Top Back to top