M.Sc Computer Science Exam Papers 2024
M.Sc Computer Science Exam Papers 2024
Multithreading involves multiple threads within a single process sharing resources but running independently, thus enabling parallel execution of tasks. It is advantageous in scenarios such as web browsers and servers, where multiple requests can be processed concurrently. Multiprogramming, in contrast, involves multiple programs running simultaneously, optimizing CPU utilization by overlapping I/O and computation. Multithreading is beneficial for tasks within the same program that can be executed concurrently, such as handling multiple client requests in a server application .
In Java's Abstract Window Toolkit (AWT), action event handling is a mechanism for handling user interactions with GUI components like buttons and menus. The ActionEvent class represents action events generated by such components. When a user interacts with a component, an ActionEvent is created and dispatched to any registered ActionListeners, which handle the event through the actionPerformed method, enabling response to user actions like button clicks .
Preemptive scheduling allows the operating system to interrupt a currently running task to allocate resources to another task, typically to ensure that high-priority tasks receive CPU time promptly. This can lead to better system responsiveness and resource utilization but introduces complexity in context switching. Non-preemptive scheduling, by contrast, allows a task to run to completion once commenced, reducing overhead from context switches but potentially leading to longer wait times for tasks and reduced system responsiveness .
Method overriding in Java occurs when a subclass has a method with the same name, return type, and parameters as a method in its superclass, allowing the subclass to provide a specific implementation. This is used for runtime polymorphism. For example, in a superclass Animal with a method sound(), a subclass Dog can override this method to provide its implementation such as barking .
Loadable Kernel Modules (LKMs) allow the extension of a running kernel's capabilities without restarting the system. They are particularly advantageous for adding hardware drivers or system features on-the-fly. LKMs facilitate modular system updates and reduce system downtime. They are useful in scenarios requiring the quick deployment of critical updates or device driver optimizations, allowing developers to test new code without recompiling the entire kernel .
String objects in Java are immutable, meaning their values cannot be changed once created, leading to the creation of new objects for modifications. StringBuffer, however, is mutable, allowing changes without generating new objects, making it more memory-efficient for repeated modifications. These differences imply that StringBuffer is better suited for scenarios involving frequent string concatenations or modifications, such as assembling dynamic query strings .
The Dining Philosophers Problem is a classic synchronization dilemma used to illustrate the challenges of avoiding deadlock and ensuring resource allocation without conflict. In this problem, philosophers alternately think and eat, requiring two shared forks to eat, leading to potential deadlock if each picks up one fork. The problem emphasizes deadlock prevention strategies, like resource hierarchy, and is significant for designing concurrent algorithms that require efficient resource management .
The post-increment operator (x++) increases the value of x by 1, but the previous value of x is used in the expression. For instance, in 'int y = x++', y will be assigned x's original value before x is incremented. Conversely, the pre-increment operator (++x) increments x by 1 before the current expression is evaluated, meaning in 'int y = ++x', y is assigned the incremented value of x .
JDBC configuration involves setting up a connection to a database using a JDBC URL, loading the JDBC driver, and managing the connection with Java code. ResultSet types, such as TYPE_FORWARD_ONLY, TYPE_SCROLL_INSENSITIVE, and TYPE_SCROLL_SENSITIVE, determine cursor movement and sensitivity to database changes. Transactions in JDBC can be handled by setting auto-commit to false and using commit() and rollback() methods to ensure atomicity of database operations. Rollback is used to revert transactions when errors occur, maintaining data integrity .
InputStream methods like read(), available(), and close() are used for reading data, checking available bytes, and freeing resources, respectively. OutputStream methods such as write(), flush(), and close() are used for writing data, pushing buffered output, and releasing resources. These methods are utilized effectively in file I/O operations, such as reading from a file to process data or writing results to a file, for example, transforming text content before saving it .