Unit 6: Concurrency, Localization, and Multithreading - Subjective Questions

CSE406 — Advanced Java Programming • Practice Questions with Detailed Answers

20 questions

1

Explain how an operating system schedules tasks for execution. Discuss the role of processes, threads, CPU time slices, priorities, and context switching.

2

Give an overview of multithreading in Java. Explain its benefits, limitations, and typical applications.

3

Describe the life cycle of a Java thread and explain the significance of the NEW, RUNNABLE, BLOCKED, WAITING, TIMED_WAITING, and TERMINATED states.

4

Compare creating a task by extending the Thread class with creating a task by implementing the Runnable interface.

5

Explain the steps for creating and starting a thread using the Thread class and the Runnable interface. Include a suitable Java example.

6

Distinguish between a task and a thread in Java. Explain why separating task definition from task execution is useful.

7

Explain the differences between Runnable and Callable in Java. Discuss their method signatures, return values, exception handling, and use with ExecutorService.

8

Describe the purpose and working of an ExecutorService. Explain how it improves upon manually creating a new thread for every task.

9

Explain the difference between execute() and submit() in ExecutorService. Include the behavior of returned values and exception handling.

10

Discuss the different ways to shut down an ExecutorService. Explain shutdown(), shutdownNow(), awaitTermination(), and the importance of handling InterruptedException.

11

What is RecursiveTask in Java? Explain how the fork/join framework uses it to solve recursive problems.

12

Develop and explain a RecursiveTask implementation that calculates the sum of an integer array using divide-and-conquer parallelism.

13

Compare ExecutorService with the fork/join framework. State the type of problem for which each approach is most appropriate.

14

Explain the advantages of localizing an application. Discuss language, regional, cultural, and formatting considerations.

15

Describe the Locale class in Java. Explain how to read the default locale, create a specific locale, and set the default locale.

16

Explain the difference between a language, a country, and a locale. Why is a language-only locale sometimes insufficient for application formatting?

17

Explain how to build a resource bundle for multiple locales. Include the naming convention and the role of the base bundle.

18

Describe how an application loads and uses a resource bundle for a selected locale. Provide a Java example using ResourceBundle.

19

Explain resource-bundle fallback and discuss what happens when a requested locale or resource key is missing.

20

Design a localized Java application that displays a date, currency value, and message for a selected locale. Explain which Java classes should be used and why.