Windows Programming Interview Online Test
Technical interview questions and answers are essential for a Windows Programming Interview because companies want to test your understanding of Windows API, event handling, message loops, memory management, threading, and GUI development. Windows programming is widely used in desktop applications and enterprise-level software, making it an important skill for developers applying for system-level programming roles. During technical rounds in companies like TCS, Wipro, Infosys, Cognizant, and Capgemini, candidates are often asked fundamental and practical questions about Windows architecture and coding techniques. This guide includes frequently asked Windows Programming interview questions with detailed explanations, making it easier for students and freshers to understand the concepts. These questions will help you improve your technical confidence and prepare better for placement tests and software development interviews.
1. What are types of kernel objects?
Answer: Several types of kernel objects, such as access token objects, event objects, file objects, file-mapping objects, I/O completion port objects, job objects, mailslot objects, mutex objects, pipe objects, process objects, semaphore objects, thread objects, and waitable timer objects.
Show Answer
Hide Answer
2. What is a kernel object?
Answer: Each kernel object is simply a memory block allocated by the kernel and is accessible only by the kernel. This memory block is a data structure whose members maintain information about the object. Some members (security descriptor, usage count, and so on) are the same across all object types, but most are specific to a particular object type. For example, a process object has a process ID, a base priority, and an exit code, whereas a file object has a byte offset, a sharing mode, and an open mod
Show Answer
Hide Answer
3. User can access these kernel objects structures?
Answer:
Kernel object data structures are accessible only by the kernel
Show Answer
Hide Answer
4. If we cannot alter these Kernel Object structures directly, how do our applications manipulate these kernel objects?
Answer: The answer is that Windows offers a set of functions that manipulate these structures in well-defined ways. These kernel objects are always accessible via these functions. When you call a function that creates a kernel object, the function returns a handle that identifies the object
Show Answer
Hide Answer
5. If we cannot alter these Kernel Object structures directly, how do our applications manipulate these kernel objects?
Answer: The answer is that Windows offers a set of functions that manipulate these structures in well-defined ways. These kernel objects are always accessible via these functions. When you call a function that creates a kernel object, the function returns a handle that identifies the object.
Show Answer
Hide Answer
6. How owns the Kernel Object?
Answer: Kernel objects are owned by the kernel, not by a process
Show Answer
Hide Answer
7. How does the kernel object outlive the process that created it?
Answer: If your process calls a function that creates a kernel object and then your process terminates, the kernel object is not necessarily destroyed. Under most circumstances, the object will be destroyed; but if another process is using the kernel object your process created, the kernel knows not to destroy the object until the other process has stopped using it
Show Answer
Hide Answer
8. Which is the data member common to all the kernel object and what is the use of it?
Answer: The usage count is one of the data members common to all kernel object types
Show Answer
Hide Answer
9. How to identify the difference between the kernel object and user object?
Answer: The easiest way to determine whether an object is a kernel object is to examine the function that creates the object. Almost all functions that create kernel objects have a parameter that allows you to specify security attribute information
Show Answer
Hide Answer
10. What is the purpose of Process Handle Table?
Answer: When a process is initialized, the system allocates a handle table for it. This handle table is used only for kernel objects, not for User objects or GDI objects. When a process first initializes, its handle table is empty. Then when a thread in the process calls a function that creates a kernel object, such as CreateFileMapping , the kernel allocates a block of memory for the object and initializes it; the kernel then scans the processs handle table for an empty entry
Show Answer
Hide Answer
11. Name few functions that create Kernel Objects?
Answer: HANDLE CreateThread(…),HANDLE CreateFile(..),HANDLE CreateFileMapping(..)HANDLE CreateSemaphore(..)etcAll functions that create kernel objects return process-relative handles that can be used successfully by any and all threads that are running in the same process
Show Answer
Hide Answer
12. What is handle?
Answer: Handle value is actually the index into the processs handle table that identifies where the kernel objects information is stored.
Show Answer
Hide Answer
13. How the handle helps in manipulating the kernel objects?
Answer: Whenever you call a function that accepts a kernel object handle as an argument, you pass the value returned by one of the Create* functions. Internally, the function looks in your processs handle table to get the address of the kernel object you want to manipulate and then manipulates the objects data structure in a well-defined fashion.
Show Answer
Hide Answer
14. What happens when the CloseHandle(handle) is called?
Answer: This function first checks the calling processs handle table to ensure that the index (handle) passed to it identifies an object that the process does in fact have access to. If the index is valid, the system gets the address of the kernel objects data structure and decrements the usage count member in the structure; if the count is zero, the kernel
Show Answer
Hide Answer
15. What happens when the CloseHandle(handle) is called?
Answer: This function first checks the calling processs handle table to ensure that the index (handle) passed to it identifies an object that the process does in fact have access to. If the index is valid, the system gets the address of the kernel objects data structure and decrements the usage count member in the structure; if the count is zero, the kernel destroys the kernel object from memory.
Show Answer
Hide Answer
16. You forget to call CloseHandle - will there be a memory leak?
Answer: Well, yes and no. It is possible for a process to leak resources (such as kernel objects) while the process runs. However, when the process terminates, the operating system ensures that any and all resources used by the process are freed—this is guaranteed. For kernel objects, the system performs the following actions: When your process terminates, the system automatically scans the processs handle table. If the table has any valid entries (objects that you didnt close before terminating), the
Show Answer
Hide Answer
17. What is the need of process relative handles?
Answer: The most important reason was robustness. If kernel object handles were system-wide values, one process could easily obtain the handle to an object that another process was using and wreak havoc on that process. Another reason for process-relative handles is security. Kernel objects are protected with security, and a process must request permission to manipulate an object before attempting to manipulate it. The creator of the object can prevent an unauthorized user from touching the object simpl
Show Answer
Hide Answer
18.
How the handles are handled in the child process?
Answer: The operating system creates the new child process but does not allow the child process to begin executing its code right away. Of course, the system creates a new, empty process handle table for the child process just as it would for any new process. But because you passed TRUE to CreateProcesss bInheritHandles parameter, the system does one more thing: it walks the parent processs handle table, and for each entry it finds that contains a valid inheritable handle, the system copies the entry
Show Answer
Hide Answer
19. Why the entries in the parent process table and child table are same?
Answer: It means that the handle value that identifies a kernel object is identical in both the parent and the child processes
Show Answer
Hide Answer
20. What about the usage count in the parent child process tables?
Answer: The system increments the usage count of the kernel object because two processes are now using the object. For the kernel object to be destroyed, both the parent process and the child process must either call CloseHandle on the object or terminate.
Show Answer
Hide Answer
21. What are Named Objects?
Answer: Method available for sharing kernel objects across process boundaries is to name the objects. Below are the kernel named objects:
1) mutex,
2) Events,
3) semaphore,
4) waitableTimers,
5)file mapping,
6)job object.
There are APIs to create these objects with last parameter as the object name
Show Answer
Hide Answer
22. What do you mean by unnamed object?
Answer: When you are creating the kernel objects with the help of APIs like CreateMutex(, , , ,pzname). And the Pzname parameter is NULL , you are indicating to the system that you want to create an unnamed (anonymous) kernel object. When you create an unnamed object, you can share the object across processes by using either inheritance or DuplicateHandle
Show Answer
Hide Answer
23. What is DuplicateHandle (API)?
Answer: Takes an entry in one processs handle table and makes a copy of the entry into another processs handle table
Show Answer
Hide Answer
24. What is a thread?
Answer: A thread describes a path of execution within a process. Every time a process is initialized, the system creates a primary thread. This thread begins executing with the C/C++ run-time librarys startup code, which in turn calls your entry-point function ( main , Wmain , WinMain , or WWinMain ) and continues executing until the entry-point function returns and the C/C++ run-time librarys startup code calls ExitProcess
Show Answer
Hide Answer
25. What is the limit on per process for creating a thread?
Answer: The number of threads a process can create is limited by the available virtual memory and depends on the default stack size
Show Answer
Hide Answer
26. What is Synchronization Objects?
Answer: Synchronization object s are use to co-ordinate the execution of multiple threads. Which kernel objects are use for Thread Synchronization on different processes? - Event, Mutex, Semaphore
Show Answer
Hide Answer
27. What is Event Object and why it is used?
Answer: Event is the thread synchronization object to set signaled state or non-signaled state.
Show Answer
Hide Answer
28. What is signaled and non signaled state?
Answer: An event is in signaled state means that it has the capacity to release the threads waiting for this event to be signaled. An event is in non signaled state means that it will not release any thread that is waiting for this particular event.example in our project: when user clicks the image application icon double simultaneously. Two image application windows were created. so PAIG created an event and set it to non-signaled state. Then the image application will reset the event to signaled state
Show Answer
Hide Answer
29. APIs for creating event and set and reset the events
Answer: CreateEvent- to create the event
OpenEvent - to open already created event
SetEvent - to set the event signaled state
RestEvent - To set the Event To non-Signaled State
Show Answer
Hide Answer
30. What is Mutex Object and why it is used?
Answer: A mutex object is a synchronization object whose state is set to signaled when it is not owned by any thread, and non-signaled when it is owned. For example, to prevent two threads from writing to shared memory at the same time, each thread waits for ownership of a mutex object before executing the code that accesses the memory. After writing to the shared memory, the thread releases the mutex object.
Show Answer
Hide Answer
31. How do I create a Mutex?
Answer: A thread uses the CreateMutex function to create a mutex object. The creating thread can request immediate ownership of the mutex object and can also specify a name for the mutex object
Show Answer
Hide Answer