Desktop Application Ultimate Desktop Application 2 — Questions and Answers
Question 1: Which Windows API function is used to create a new process on the desktop?
- CreateProcess (Correct answer)
- SpawnProcess
- StartProcess
- LaunchProcess
Correct answer: CreateProcess
CreateProcess is the Windows API function that creates a new process and its primary thread.
Question 2: In a Model-View-ViewModel (MVVM) pattern, what is the primary role of the ViewModel?
- Render UI components directly
- Expose data streams and commands for the View to bind to (Correct answer)
- Store persistent application data
- Handle network requests
Correct answer: Expose data streams and commands for the View to bind to
The ViewModel exposes data and commands that the View binds to, acting as an intermediary between Model and View.
Question 3: What does DPI awareness mean in the context of desktop applications?
- The app monitors CPU usage
- The app correctly scales UI elements for different screen pixel densities (Correct answer)
- The app supports dark mode
- The app tracks mouse movement speed
Correct answer: The app correctly scales UI elements for different screen pixel densities
DPI awareness means the application scales its UI correctly when displayed on high-density (HiDPI/Retina) screens to avoid blurry or incorrectly sized elements.
Question 4: Which mechanism allows a desktop application to communicate with another application through a shared memory segment?
- TCP socket
- Named pipe
- Shared memory IPC (Correct answer)
- REST API
Correct answer: Shared memory IPC
Shared memory IPC allows multiple processes to access the same memory region, enabling fast inter-process communication.
Question 5: In Electron.js desktop applications, which process has direct access to Node.js APIs and the file system?
- Renderer process
- Worker process
- Main process (Correct answer)
- Sandbox process
Correct answer: Main process
The Main process in Electron has full Node.js access and controls the application lifecycle, while Renderer processes handle UI.
Question 6: What is the purpose of a mutex in a desktop application?
- To render graphics faster
- To ensure only one instance of a resource is accessed at a time (Correct answer)
- To compress application assets
- To manage window z-order
Correct answer: To ensure only one instance of a resource is accessed at a time
A mutex (mutual exclusion object) prevents multiple threads or processes from accessing a shared resource simultaneously, avoiding race conditions.
Question 7: Which technique allows a desktop app to update its UI without blocking the main thread?
- Synchronous rendering
- Busy waiting
- Asynchronous programming with async/await or background threads (Correct answer)
- Polling in a tight loop
Correct answer: Asynchronous programming with async/await or background threads
Asynchronous programming offloads long-running tasks to background threads, keeping the UI thread free to respond to user input.
Which Windows API function is used to create a new process on the desktop?