1What is the main purpose of operating system task scheduling?
Describing operating system task scheduling
Easy
A.To compile Java source code
B.To translate user interfaces
C.To decide which task runs next
D.To store application resources
Correct Answer: To decide which task runs next
Explanation:
Task scheduling determines which process or thread receives processor time.
Incorrect! Try again.
2What does a scheduler commonly use to manage processor time among tasks?
Describing operating system task scheduling
Easy
A.Locale objects
B.Scheduling policies
C.Java packages
D.Resource bundles
Correct Answer: Scheduling policies
Explanation:
Scheduling policies define how the operating system selects and manages tasks.
Incorrect! Try again.
3Which interface represents a task that can be executed by a thread but does not return a result?
Creating worker threads using Runnable and Callable
Easy
A.Callable
B.Runnable
C.Executor
D.Future
Correct Answer: Runnable
Explanation:
Runnable represents a task whose run() method does not return a value.
Incorrect! Try again.
4Which interface is used when a task can return a result?
Creating worker threads using Runnable and Callable
Easy
A.Runnable
B.Comparator
C.ThreadGroup
D.Callable
Correct Answer: Callable
Explanation:
Callable represents a task that can return a value through its call() method.
Incorrect! Try again.
5Which method contains the code executed by a class implementing Runnable?
Creating worker threads using Runnable and Callable
Easy
A.run()
B.call()
C.start()
D.execute()
Correct Answer: run()
Explanation:
A Runnable task places its work inside the run() method.
Incorrect! Try again.
6What is the primary role of an ExecutorService?
Using an ExecutorService to concurrently execute tasks
Easy
A.Formatting currency values
B.Creating resource files
C.Managing task execution
D.Changing thread priorities
Correct Answer: Managing task execution
Explanation:
ExecutorService manages threads and schedules submitted tasks for execution.
Incorrect! Try again.
7Which method submits a task to an ExecutorService and can return a Future?
Using an ExecutorService to concurrently execute tasks
Easy
A.start()
B.submit()
C.scheduleNow()
D.launch()
Correct Answer: submit()
Explanation:
The submit() method accepts Runnable or Callable tasks and may return a Future.
Incorrect! Try again.
8Which method should be called when an ExecutorService is no longer needed?
Using an ExecutorService to concurrently execute tasks
Easy
A.closeThreads()
B.shutdown()
C.stopAll()
D.terminateNow()
Correct Answer: shutdown()
Explanation:
Calling shutdown() stops the service from accepting new tasks and allows existing tasks to finish.
Incorrect! Try again.
9What is the main purpose of a RecursiveTask?
RecursiveTask
Easy
A.Returning a result from divided work
B.Changing the current locale
C.Starting a single thread
D.Formatting localized messages
Correct Answer: Returning a result from divided work
Explanation:
RecursiveTask supports tasks that split work recursively and produce a result.
Incorrect! Try again.
10Which method must a RecursiveTask commonly implement?
RecursiveTask
Easy
A.process()
B.compute()
C.main()
D.run()
Correct Answer: compute()
Explanation:
The recursive computation is defined in the compute() method.
Incorrect! Try again.
11What is a major advantage of localizing an application?
Describing the advantages of localizing an application
Easy
A.Removing all application logic
B.Reducing every file to one line
C.Supporting different regions
D.Preventing concurrent execution
Correct Answer: Supporting different regions
Explanation:
Localization allows an application to adapt text and formats for different languages and regions.
Incorrect! Try again.
12Which item can localization adapt for users in different countries?
Describing the advantages of localizing an application
Easy
A.Java class inheritance
B.Date and number formats
C.Thread stack size
D.Bytecode instructions
Correct Answer: Date and number formats
Explanation:
Localization can adapt dates, numbers, currencies, messages, and other regional conventions.
Incorrect! Try again.
13Which Java class represents a language and regional setting?
Reading and setting the locale using the Locale object
Easy
A.Locale
B.Language
C.Location
D.Region
Correct Answer: Locale
Explanation:
The Locale class represents language, country, and related regional preferences.
Incorrect! Try again.
14Which method returns the default locale of the Java runtime?
Reading and setting the locale using the Locale object
Easy
A.Locale.getDefault()
B.Locale.current()
C.Locale.defaultValue()
D.Locale.readDefault()
Correct Answer: Locale.getDefault()
Explanation:
The static getDefault() method returns the runtime's default Locale.
Incorrect! Try again.
15What is a resource bundle primarily used to store?
Building a resource bundle for each locale
Easy
A.Localized messages
B.Database connections
C.Operating system processes
D.Compiled thread objects
Correct Answer: Localized messages
Explanation:
Resource bundles store locale-specific text and other user-facing resources.
Incorrect! Try again.
16Which file type is commonly used to create a properties-based resource bundle?
Building a resource bundle for each locale
Easy
A..thread
B..properties
C..bundlecode
D..locale
Correct Answer: .properties
Explanation:
Java properties files commonly contain key-value pairs for resource bundles.
Incorrect! Try again.
17Which method is commonly used to load a resource bundle?
Calling a resource bundle from an application
Easy
A.ResourceBundle.loadText()
B.Bundle.openFile()
C.ResourceBundle.getBundle()
D.Locale.getBundle()
Correct Answer: ResourceBundle.getBundle()
Explanation:
The getBundle() method loads the resource bundle that matches a base name and locale.
Incorrect! Try again.
18Which method retrieves a value associated with a key from a ResourceBundle?
Calling a resource bundle from an application
Easy
A.lookupMessage()
B.readValue()
C.findText()
D.getString()
Correct Answer: getString()
Explanation:
The getString() method returns the text associated with a specified resource key.
Incorrect! Try again.
19What is multithreading?
Overview of multithreading
Easy
A.Using multiple locales
B.Storing multiple bundles
C.Compiling multiple packages
D.Running multiple threads
Correct Answer: Running multiple threads
Explanation:
Multithreading allows multiple threads to execute within a program.
Incorrect! Try again.
20Which state describes a thread that has been created but has not yet started running?
Thread life cycle
Easy
A.Terminated
B.Running
C.Blocked
D.New
Correct Answer: New
Explanation:
A newly created Thread object is in the New state before start() is called.
Incorrect! Try again.
21A system uses a fixed-size thread pool, but one submitted task performs a long computation while several short tasks wait. Which scheduling issue is most likely to occur?
Describing operating system task scheduling
Medium
A.The short tasks may experience increased waiting time
B.The operating system permanently cancels the long task
C.The waiting tasks execute inside the long task's stack
D.The pool automatically changes every task to a daemon thread
Correct Answer: The short tasks may experience increased waiting time
Explanation:
A long-running task can occupy a worker thread, leaving fewer workers available for other tasks and increasing their waiting time.
Incorrect! Try again.
22Two runnable threads have different priorities, but both are ready to execute. What should a Java programmer conclude about the higher-priority thread?
Describing operating system task scheduling
Medium
A.It is guaranteed to receive twice as much CPU time
B.It may receive scheduling preference from the operating system
C.It is guaranteed to run before the other thread
D.It can execute concurrently only when the other thread terminates
Correct Answer: It may receive scheduling preference from the operating system
Explanation:
Thread priorities are scheduling hints. They do not guarantee execution order or a fixed share of CPU time.
Incorrect! Try again.
23A task must calculate and return a value when submitted to an executor. Which design is most appropriate?
Creating worker threads using Runnable and Callable
Medium
A.Implement Runnable and return the value from sleep()
B.Implement Runnable and return the value from run()
C.Implement Callable and return the value from call()
D.Extend Thread and return the value from start()
Correct Answer: Implement Callable and return the value from call()
Explanation:
Callable is designed for tasks that produce a result and may throw checked exceptions. Its result is obtained through a Future.
Incorrect! Try again.
24A program submits a Callable<Integer> to an ExecutorService and receives a Future<Integer>. When is the result normally obtained?
Creating worker threads using Runnable and Callable
Medium
A.By calling start() on the Future
B.By calling run() on the Future
C.By calling get() on the Future
D.By calling join() on the Future
Correct Answer: By calling get() on the Future
Explanation:
Future.get() returns the Callable result, waiting for completion if necessary. It may also throw execution or interruption-related exceptions.
Incorrect! Try again.
25An application creates a fixed thread pool with three threads and submits eight independent tasks. How many tasks can execute at the same time under normal conditions?
Using an ExecutorService to concurrently execute tasks
Medium
A.Only one task
B.Exactly three tasks
C.Exactly eight tasks
D.At least eight tasks
Correct Answer: Exactly three tasks
Explanation:
A fixed pool with three worker threads can actively execute up to three tasks concurrently; the remaining tasks wait in the work queue.
Incorrect! Try again.
26A server finishes submitting work to an ExecutorService and must release its resources. Which action is appropriate after submissions are complete?
Using an ExecutorService to concurrently execute tasks
Medium
A.Call execute() with a null task
B.Call shutdownNow() in every normal completion path
C.Call shutdown() and allow submitted tasks to finish
D.Call start() and wait for new tasks
Correct Answer: Call shutdown() and allow submitted tasks to finish
Explanation:
shutdown() stops accepting new tasks while allowing already submitted tasks to complete. shutdownNow() attempts to interrupt active tasks.
Incorrect! Try again.
27A RecursiveTask<Long> computes the sum of a large array. Which implementation pattern best supports fork/join parallelism?
RecursiveTask
Medium
A.Use Thread.sleep() before returning the complete array sum
B.Create one operating-system process for every array element
C.Split the range, fork one subtask, compute the other, then join
D.Call compute() repeatedly without dividing the input range
Correct Answer: Split the range, fork one subtask, compute the other, then join
Explanation:
RecursiveTask works by dividing a problem into smaller subtasks, forking work that can run asynchronously, and joining to combine results.
Incorrect! Try again.
28A RecursiveTask repeatedly divides its input but never reaches a condition that directly computes a small subproblem. What is the likely result?
RecursiveTask
Medium
A.The ForkJoinPool automatically supplies the missing result
B.The task may recurse indefinitely or exhaust the stack
C.The task becomes a Callable without further changes
D.The task always completes with a zero result
Correct Answer: The task may recurse indefinitely or exhaust the stack
Explanation:
A recursive task requires a correct base case. Without one, recursive splitting does not terminate and can cause stack or resource exhaustion.
Incorrect! Try again.
29A Java application is localized using resource bundles instead of hard-coded messages. What is the main maintenance benefit?
Describing the advantages of localizing an application
Medium
A.The application no longer needs character encoding
B.Database transactions automatically become faster
C.Text changes can be made without changing program logic
D.All users are forced to use the same language
Correct Answer: Text changes can be made without changing program logic
Explanation:
Separating locale-specific resources from code allows translators or maintainers to update messages without modifying application behavior.
Incorrect! Try again.
30An application is deployed in several countries and displays dates, numbers, and currency values. Why is localization important in this situation?
Describing the advantages of localizing an application
Medium
A.It converts every value to a plain text identifier
B.It removes the need for user-specific settings
C.It guarantees identical date formats everywhere
D.It presents culturally appropriate formats for each audience
Correct Answer: It presents culturally appropriate formats for each audience
Explanation:
Localization supports language and regional conventions, including date order, decimal separators, currency symbols, and translated messages.
Incorrect! Try again.
31Which statement creates a Locale representing French as used in Canada?
Reading and setting the locale using the Locale object
Medium
A.new Locale("fr", "CA")
B.Locale.of("Canada", "French")
C.new Locale("French-Canada")
D.new Locale("CA", "fr")
Correct Answer: new Locale("fr", "CA")
Explanation:
The Locale constructor conventionally receives the lowercase language code first and the uppercase country code second.
Incorrect! Try again.
32A program calls Locale.setDefault(Locale.US) before creating a NumberFormat instance without specifying a locale. What is the expected effect?
Reading and setting the locale using the Locale object
Medium
A.The formatter uses the US locale by default
B.The formatter ignores all locale information
C.The formatter always uses the user's original locale
D.The formatter uses the JVM's language-neutral locale
Correct Answer: The formatter uses the US locale by default
Explanation:
Locale-sensitive classes use the current default locale when no explicit locale is supplied.
Incorrect! Try again.
33For base name Messages and locales English and French, which resource bundle naming scheme is valid?
Building a resource bundle for each locale
Medium
A.en.Messages and fr.Messages
B.Messages.en.properties and Messages.fr.properties only
C.Messages-English.java and Messages-French.java
D.Messages.properties and Messages_fr.properties
Correct Answer: Messages.properties and Messages_fr.properties
Explanation:
A base bundle can use the default properties file, while locale-specific bundles append an underscore and locale component such as _fr.
Incorrect! Try again.
34A French resource bundle is missing a key that exists in the base bundle. What commonly happens during lookup?
Building a resource bundle for each locale
Medium
A.The lookup can fall back to the base bundle
B.The JVM creates a translated value automatically
C.The application always returns an empty string
D.The key is permanently removed from all bundles
Correct Answer: The lookup can fall back to the base bundle
Explanation:
ResourceBundle lookup searches candidate bundles and can use the base bundle for keys unavailable in a more specific locale bundle.
Incorrect! Try again.
35Which code correctly retrieves the value associated with the key "welcome" for a specified locale?
Calling a resource bundle from an application
Medium
getBundle() selects the bundle using its base name and locale, and getString() retrieves the value for the requested key.
Incorrect! Try again.
36A call to bundle.getString("title") throws MissingResourceException. Which cause is most likely?
Calling a resource bundle from an application
Medium
A.The executor has more than one worker thread
B.The current thread has entered the waiting state
C.The Locale object contains a country code
D.The requested key is absent from the available bundles
Correct Answer: The requested key is absent from the available bundles
Explanation:
MissingResourceException commonly indicates that the requested resource key cannot be found in the selected bundle or its fallback bundles.
Incorrect! Try again.
37Two threads update the same counter using counter++ without synchronization. Why might the final count be lower than expected?
Overview of multithreading
Medium
A.The operating system converts increments into decrements
B.Java permits only one thread to access integer fields
C.The counter is automatically reset when a thread starts
D.The increment is a non-atomic read-modify-write operation
Correct Answer: The increment is a non-atomic read-modify-write operation
Explanation:
Both threads can read the same value before either writes the incremented value, causing one update to overwrite the other.
Incorrect! Try again.
38A thread is blocked while waiting for a monitor lock held by another thread. Which state best describes it?
Thread life cycle
Medium
A.TERMINATED
B.NEW
C.BLOCKED
D.RUNNABLE
Correct Answer: BLOCKED
Explanation:
A thread waiting to acquire a monitor lock is in the BLOCKED state. This differs from WAITING, which usually results from methods such as wait() or join().
Incorrect! Try again.
39A developer writes a task's logic in run() and wants the task to execute on a new thread. Which call is required?
Creating tasks and threads
Medium
A.thread.run()
B.thread.execute()
C.thread.begin()
D.thread.start()
Correct Answer: thread.start()
Explanation:
start() schedules a new thread and eventually invokes run(). Calling run() directly executes the method on the current thread.
Incorrect! Try again.
40A class must extend an existing application superclass but also define work for a thread. Which approach avoids Java's single-inheritance limitation?
Thread class and Runnable interface
Medium
A.Declare run() as static in the application superclass
B.Implement Runnable and pass the object to a Thread
C.Create a second superclass only for the thread
D.Extend both Thread and the application superclass
Correct Answer: Implement Runnable and pass the object to a Thread
Explanation:
Implementing Runnable separates the task from the Thread object and allows the class to retain its existing superclass.
Incorrect! Try again.
41A Java application has eight runnable threads on a four-core processor. The operating system uses preemptive scheduling, but the JVM does not guarantee any ordering for equal-priority threads. Which conclusion is most accurate?
Describing operating system task scheduling
Hard
A.At most four threads execute at one instant, while runnable threads may be time-sliced
B.Exactly four threads execute continuously until completion
C.All eight threads execute simultaneously on four cores
D.Thread priority determines the exact execution order on every operating system
Correct Answer: At most four threads execute at one instant, while runnable threads may be time-sliced
Explanation:
Four cores can execute at most four threads simultaneously. The remaining runnable threads may be scheduled later through preemption and time slicing, and Java priority does not define a portable exact order.
Incorrect! Try again.
42A task must return a computed value and may throw a checked exception. Which design directly models both requirements when submitted to an executor?
Creating worker threads using Runnable and Callable
Hard
A.Implement Callable<V> and throw the checked exception from call()
B.Extend Thread and return the value from run()
C.Implement Runnable and store the result in a shared field
D.Implement Runnable and declare the checked exception on run()
Correct Answer: Implement Callable<V> and throw the checked exception from call()
Explanation:
Callable<V> returns a value from call() and permits checked exceptions. Runnable.run() returns void and cannot declare checked exceptions.
Incorrect! Try again.
43A Callable<Integer> is submitted to an executor, and its computation throws IOException. What does future.get() report to the calling thread?
Creating worker threads using Runnable and Callable
Hard
A.CancellationException because the task failed
B.ExecutionException whose cause is IOException
C.CompletionException whose cause is IOException
D.IOException directly without any wrapper
Correct Answer: ExecutionException whose cause is IOException
Explanation:
For a task submitted through an ExecutorService, Future.get() wraps an exception thrown by the task in ExecutionException. The original exception is available through getCause().
Incorrect! Try again.
44A fixed thread pool contains two threads. Three tasks are submitted, and the first two block indefinitely while the third is queued. What happens when the caller invokes future3.get()?
Using an ExecutorService to concurrently execute tasks
Hard
A.The call blocks until a worker becomes available for the third task
B.The executor cancels one blocked task to maintain progress
C.The third task starts immediately because queue capacity is unlimited
D.The third task runs on the caller thread automatically
Correct Answer: The call blocks until a worker becomes available for the third task
Explanation:
A fixed pool creates at most two worker threads. The third task remains queued until a worker completes or becomes available; get() waits for that task's completion.
Incorrect! Try again.
45After submitting tasks to an ExecutorService, the application calls shutdown(). Which statement describes the contract correctly?
Using an ExecutorService to concurrently execute tasks
Hard
A.The executor terminates immediately regardless of task state
B.Queued tasks are discarded immediately
C.Running tasks are interrupted before shutdown returns
D.New tasks are rejected, but previously submitted tasks may complete
Correct Answer: New tasks are rejected, but previously submitted tasks may complete
Explanation:
shutdown() initiates an orderly shutdown. New submissions are rejected, while active and queued tasks are allowed to finish unless another shutdown policy is used.
Incorrect! Try again.
46Two tasks submitted to a single-thread executor each wait for the other's Future.get() result. What is the most likely outcome if neither task completes independently?
Using an ExecutorService to concurrently execute tasks
Hard
A.The executor detects the cycle and reorders the tasks
B.The tasks deadlock because one worker cannot execute both blocked tasks
C.Both tasks complete because futures release the worker
D.The second task is always rejected by a single-thread executor
Correct Answer: The tasks deadlock because one worker cannot execute both blocked tasks
Explanation:
The only worker can run one task at a time. If that task waits for another queued task, the queued task cannot start, producing a dependency deadlock.
Incorrect! Try again.
47A RecursiveTask<Long> recursively forks both child subtasks and then calls join() on the left child before joining the right child. Why can this still perform well in a ForkJoinPool?
RecursiveTask
Hard
A.ForkJoinPool executes all recursive calls on one kernel thread
B.Calling join() converts the task into a nonblocking callback
C.RecursiveTask automatically creates one operating-system process per child
D.Workers can steal available tasks from other workers' deques
Correct Answer: Workers can steal available tasks from other workers' deques
Explanation:
Fork/join workers use work stealing. While one worker waits or assists with joins, another worker can process a stolen task, improving parallel utilization.
Incorrect! Try again.
48A RecursiveTask computes a sum over an array. Its base case is if (length <= threshold), but the recursive branch calls fork() on the left task and immediately computes the right task before joining the left. What is the primary reason for this pattern?
RecursiveTask
Hard
A.It reduces scheduling overhead while leaving one branch available for parallel work
B.It prevents the left task from ever running concurrently
C.It makes the result independent of the threshold value
D.It guarantees that array elements are processed in source order
Correct Answer: It reduces scheduling overhead while leaving one branch available for parallel work
Explanation:
Computing one branch directly avoids unnecessarily queuing both branches. The forked branch can still execute concurrently or be stolen by another worker.
Incorrect! Try again.
49A RecursiveTask invokes fork() on a child but never invokes join() or otherwise retrieves that child's result. Which defect is present?
RecursiveTask
Hard
A.The child is guaranteed to execute twice
B.ForkJoinPool automatically joins all children at pool termination
C.The parent result cannot depend safely on the child's completion
D.The child runs synchronously before fork() returns
Correct Answer: The parent result cannot depend safely on the child's completion
Explanation:
fork() schedules asynchronous execution but does not wait for completion. The parent must join or otherwise coordinate with the child before relying on its result.
Incorrect! Try again.
50An application separates translatable text, locale-specific number formats, and date formats from business logic. Which architectural advantage follows most directly?
Describing the advantages of localizing an application
Hard
A.Translation eliminates the need for input validation
C.New locales can often be added without changing core application logic
D.All locales use identical parsing and display rules
Correct Answer: New locales can often be added without changing core application logic
Explanation:
Localization externalizes locale-dependent resources and formatting rules. This reduces code changes when supporting additional languages or regional conventions.
Incorrect! Try again.
51A program calls Locale.setDefault(Locale.FRANCE) after creating a NumberFormat instance without an explicit locale. What should be expected of that existing formatter?
Reading and setting the locale using the Locale object
Hard
A.It must switch to France immediately
B.It throws an exception because the default locale changed
C.It remains configured according to the locale used when it was created
D.It becomes locale-neutral until recreated
Correct Answer: It remains configured according to the locale used when it was created
Explanation:
Changing the default locale affects later locale-sensitive factory calls. Existing formatter instances retain their previously selected locale.
Incorrect! Try again.
52A service must format output for each request independently in a multithreaded server. Which approach avoids unintended cross-request effects?
Reading and setting the locale using the Locale object
Hard
A.Use explicit locale arguments when creating formatters
B.Assume the operating system locale changes per request
C.Set the JVM-wide default locale for every request
D.Mutate one shared formatter before each response
Correct Answer: Use explicit locale arguments when creating formatters
Explanation:
The JVM default locale is global process state and shared formatter mutation is unsafe. Passing an explicit locale keeps request formatting isolated and predictable.
Incorrect! Try again.
53An application requests Messages for locale fr_CA. Which class-based resource bundle lookup is most specific before fallback occurs?
Building a resource bundle for each locale
Hard
A.fr_CA.Messages
B.Messages_frCanada
C.Messages_fr_CA
D.Messages_CA_fr
Correct Answer: Messages_fr_CA
Explanation:
The standard class-based bundle naming convention appends language and country as baseName_language_country, so Messages_fr_CA is the locale-specific candidate.
Incorrect! Try again.
54A properties resource bundle contains welcome=Bienvenue encoded as UTF-8, but the runtime interprets the file using an incompatible encoding. What is the most appropriate remedy in a modern Java application?
Building a resource bundle for each locale
Hard
A.Rename the key to include the encoding
B.Set the default time zone before loading the bundle
C.Use a UTF-8-compatible resource-bundle loading strategy
D.Replace every accented character with a locale code
Correct Answer: Use a UTF-8-compatible resource-bundle loading strategy
Explanation:
Resource data must be decoded using the encoding in which it was stored. A UTF-8-compatible bundle loading strategy preserves characters such as é correctly.
Incorrect! Try again.
55A call to ResourceBundle.getBundle("Messages", requestedLocale) cannot find a bundle for the exact locale but finds the base bundle. What is the normal result?
Calling a resource bundle from an application
Hard
A.The base bundle is used after locale fallback
B.The requested locale is permanently changed to the base locale
C.The call always returns null
D.The JVM creates an empty bundle dynamically
Correct Answer: The base bundle is used after locale fallback
Explanation:
ResourceBundle performs a candidate-locale lookup and fallback process. If no more-specific bundle is available, a suitable parent or base bundle can provide the values.
Incorrect! Try again.
56A bundle is loaded once and reused across threads for read-only calls to getString(). Which statement is most accurate?
Calling a resource bundle from an application
Hard
A.Resource bundles are generally safe for concurrent read access after construction
B.Concurrent reads always reload the underlying file
C.Every read requires external synchronization
D.The bundle becomes invalid after the first thread reads it
Correct Answer: Resource bundles are generally safe for concurrent read access after construction
Explanation:
Resource bundles are designed for shared access, and read-only retrieval does not require callers to synchronize in normal usage. Mutable values returned by custom bundles may need separate care.
Incorrect! Try again.
57Two threads increment a shared integer using counter++ one million times each without synchronization. Which outcome is valid under the Java Memory Model?
Overview of multithreading
Hard
A.The final value must be exactly two million
B.The final value may be less than two million because increments can be lost
C.The final value must be zero because integers are immutable
D.The program cannot compile because shared fields require locks
Correct Answer: The final value may be less than two million because increments can be lost
Explanation:
counter++ is a read-modify-write sequence, not an atomic operation. Interleaved updates can overwrite one another, producing a result below the expected total.
Incorrect! Try again.
58A thread has been started and is currently waiting inside Object.wait() while owning no monitor. Which Thread.State best describes it?
Thread life cycle
Hard
A.TERMINATED
B.TIMED_WAITING
C.BLOCKED
D.WAITING
Correct Answer: WAITING
Explanation:
Object.wait() without a timeout places a thread in the WAITING state. BLOCKED means waiting to acquire a monitor, while timed waits use TIMED_WAITING.
Incorrect! Try again.
59A thread's run() method completes normally. Another part of the program later calls start() on the same Thread object to repeat the task. What occurs?
Creating tasks and threads
Hard
A.The thread transitions from TERMINATED back to RUNNABLE
B.The call is ignored because the thread is terminated
C.The call throws IllegalThreadStateException
D.The task runs again on a new worker automatically
Correct Answer: The call throws IllegalThreadStateException
Explanation:
A Java Thread instance can be started only once. After termination, calling start() again throws IllegalThreadStateException.
Incorrect! Try again.
60A class must inherit behavior from BaseWorker and also define concurrent work. Which design preserves the required inheritance while remaining compatible with Thread construction?
Thread class and Runnable interface
Hard
A.Extend Thread and ignore BaseWorker
B.Implement Runnable and pass the object to a Thread
C.Implement Thread because interfaces can provide scheduling
D.Declare two superclass clauses for the class
Correct Answer: Implement Runnable and pass the object to a Thread
Explanation:
Java permits one superclass but multiple interfaces. Implementing Runnable separates the task from the thread mechanism and allows the class to extend BaseWorker.
Incorrect! Try again.
Did this save you a night before the exam?
LPU Notes is free, and it stays free. Ads cover part of the server bill.
The rest comes out of a student's own pocket: the domain, the storage,
and keeping the site up through the weeks everyone needs it at once.
The payment button didn't load. An ad blocker or a filtered network is the usual reason.
to try again.
Nothing here is ever locked, and nothing unlocks. Chip in only if it was worth it.
What it pays for →