Reviewed by Editorial Team
The ProProfs editorial team is comprised of experienced subject matter experts. They've collectively created over 10,000 quizzes and lessons, serving over 100 million users. Our team includes in-house content moderators and subject matter experts, as well as a global network of rigorously trained contributors. All adhere to our comprehensive editorial guidelines, ensuring the delivery of high-quality content.
Learn about Our Editorial Process
| By Stefstoilov
S
Stefstoilov
Community Contributor
Quizzes Created: 1 | Total Attempts: 86
| Attempts: 86 | Questions: 10
Please wait...
Question 1 / 10
0 %
0/100
Score 0/100
1. Which interface provides the capability to store objects using a key-value pair?

Explanation

The correct answer is java.util.Map. This interface provides the capability to store objects using a key-value pair. It allows you to associate a value with a unique key, and then retrieve that value later using the same key. This is useful for scenarios where you need to store and access data in a way that is efficient and allows for quick retrieval based on a specific key.

Submit
Please wait...
About This Quiz
Java Quest Online Quiz - Quiz

Java Quest Online Quiz assesses understanding in Java programming, covering topics like exception handling, class structures, and API usage. It evaluates key skills in Java, ideal for learners aiming to enhance their proficiency in object-oriented programming.

Personalize your quiz and earn a certificate with your name on it!
2. 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.)

Explanation

The java.util.ArrayList class allows you to grow or shrink its size and provides indexed access to its elements. Its methods are not synchronized, meaning that it is not thread-safe. This class is a part of the Java Collections Framework and is commonly used when you need a dynamic array-like data structure.

Submit
3. Which are methods of the Object class? (Choose all that apply.)

Explanation

The methods of the Object class are used for synchronization and inter-thread communication in Java. The methods notify() and notifyAll() are used to wake up threads that are waiting on the object's monitor. The method wait(long msecs) is used to make a thread wait for a specified amount of time or until it is notified. The other methods mentioned, isInterrupted(), synchronized(), and interrupt(), are not methods of the Object class.

Submit
4. 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.)

Explanation

If the equals() method returns false, the hashCode() comparison == might return true: This statement is true because even if two instances of the same class are not equal, it is still possible for their hash codes to be the same. The hashCode() method is used to generate a hash code for an object, and it is possible for different objects to have the same hash code.

If the hashCode() comparison == returns true, the equals() method might return true: This statement is also true because while it is generally expected that if two objects have the same hash code, they should also be equal, it is not a strict requirement. It is possible for two objects with the same hash code to have different values and therefore not be equal.

Submit
5. 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.)

Explanation

These exceptions are typically thrown by an API developer or an application developer because they are related to invalid or illegal arguments or states in the code. ClassCastException and ExceptionInInitializerError, on the other hand, are more likely to be thrown by the JVM itself when there are issues with class casting or initializing static variables.

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

Explanation

All three classes have a length() method because the length() method is a common method in the String, StringBuilder, and StringBuffer classes that returns the length of the string.

Objects of type StringBuffer are thread-safe because StringBuffer is designed to be thread-safe, meaning that multiple threads can safely access and modify a StringBuffer object without causing any data corruption or inconsistencies.

The other statements are not true. The "+" operator is only overloaded for the String class, not for StringBuilder or StringBuffer. According to the API, StringBuilder is generally faster than StringBuffer because it is not synchronized, while StringBuffer is synchronized, making it slower in multi-threaded environments. Finally, all three classes provide methods to modify the value of an instance, such as append(), delete(), and replace().

Submit
7. Which are true? (Choose all that apply.) 

Explanation

The notifyAll() method must be called from a synchronized context because it is used to wake up all threads that are waiting on the same object's monitor. To ensure thread safety and avoid race conditions, it is necessary to call notifyAll() within a synchronized block or method.

When a thread is waiting as a result of wait(), it releases its lock. This is because the wait() method causes the thread to temporarily give up its lock and enter a waiting state until it is notified or interrupted. This allows other threads to acquire the lock and continue executing their code.

Submit
8. Which statement is true? (Choose all that apply)

Explanation

Some reference variables live on the stack, and some live on the heap. In Java, primitive types and local variables are stored on the stack, while objects and reference variables are stored on the heap. It’s possible to request the GC via methods in either java.lang.Runtime or java.lang.System classes. These classes provide methods like System.gc() and Runtime.getRuntime().gc() to request garbage collection, although the actual garbage collection process is controlled by the JVM.

Submit
9. Which are true? (Choose all that apply.)

Explanation

Both DateFormat and NumberFormat objects can be constructed to be Locale specific. This means that the formatting of dates and numbers can be customized based on the language and cultural conventions of a specific locale.

Both Currency and NumberFormat objects must be constructed using static methods. This is because these classes provide a set of predefined formats that are commonly used for currencies and numbers, and the static methods allow for easy instantiation of these formats.

If a NumberFormat instance's Locale is to be different than the current Locale, it must be specified at creation time. This means that if you want to format numbers according to a specific locale, you need to explicitly specify the desired locale when creating the NumberFormat instance.

A single instance of NumberFormat can be used to create Number objects from Strings and to create formatted numbers from numbers. This means that you can use the same NumberFormat object to parse a string representation of a number into a Number object, as well as to format a number into a desired format.

Submit
10. Which are true about a method-local inner class? (Choose all that apply.)

Explanation

A method-local inner class can be marked abstract because it can be subclassed and overridden by other classes. It can access private members of the enclosing class because it has access to all members of its enclosing class, including private members. However, it does not need to be marked final, public, or static, as these modifiers are not applicable to method-local inner classes.

Submit
View My Results

Quiz Review Timeline (Updated): Oct 19, 2023 +

Our quizzes are rigorously reviewed, monitored and continuously updated by our expert board to maintain accuracy, relevance, and timeliness.

  • Current Version
  • Oct 19, 2023
    Quiz Edited by
    ProProfs Editorial Team
  • Oct 04, 2013
    Quiz Created by
    Stefstoilov
Cancel
  • All
    All (10)
  • Unanswered
    Unanswered ()
  • Answered
    Answered ()
Which interface provides the capability to store objects using a...
Which collection class(es) allows you to grow or shrink its size and...
Which are methods of the Object class? (Choose all that apply.)
Which statements are true about comparing two instances of the same...
Which are most typically thrown by an API developer or an application...
Which about the three java.lang classes String, StringBuilder, and...
Which are true? (Choose all that apply.) 
Which statement is true? (Choose all that apply)
Which are true? (Choose all that apply.)
Which are true about a method-local inner class? (Choose all that...
Alert!

Advertisement