How does the Decorator design pattern differ from inheritance?
- Decorator pattern allows adding functionality dynamically
- Decorator pattern promotes code reusability and flexibility
- Inheritance creates a static hierarchy of classes
- Inheritance is a compile-time relationship between classes
The Decorator design pattern allows behavior to be added to individual objects dynamically, while inheritance creates a static hierarchy of classes where subclasses inherit behavior from their parent class. The Decorator pattern promotes code reusability and flexibility.
Which mechanism is used to switch between processes in multitasking operating systems?
- Context switch
- Inter-process communication
- Interrupt handling
- Resource allocation
In multitasking operating systems, the mechanism used to switch between processes is known as a context switch. A context switch involves saving the state of a currently running process, including its registers, program counter, and other relevant information, and then loading the state of the next process to be executed. This allows the operating system to efficiently allocate CPU time among multiple processes, enabling concurrent execution and multitasking capabilities. Understanding context switching is crucial for system performance optimization and multitasking efficiency.
The ___________ property ensures that subproblems are independent and can be solved separately in dynamic programming.
- Divide and Conquer
- Greedy
- Optimal Substructure
- Overlapping
The "Optimal Substructure" property in dynamic programming states that the optimal solution to a problem can be constructed from optimal solutions to its subproblems. This property enables subproblems to be solved independently and then combined to solve the overall problem efficiently.
ARP stands for Address Resolution ________.
- Protocol
- Program
- Point
- Procedure
ARP stands for Address Resolution Protocol. ARP is a communication protocol used for discovering the link layer address (MAC address) of a network host. It translates an IP address into a MAC address and is essential for communication between devices on the same network. A protocol is a set of rules governing data transmission, making "Protocol" the correct option here.
The "I" in ACID properties ensures that database transactions maintain ___________.
- Atomicity
- Consistency
- Durability
- Isolation
The "I" in ACID stands for Isolation. This property ensures that each transaction is isolated from other transactions until it is completed, preventing interference and ensuring data integrity during concurrent transactions.
What is the difference between == and === in JavaScript?
- Checks for object equality based on memory references
- Checks for object equality based on property values
- Checks for value and type equality
- Checks for value equality without considering type differences
The == operator in JavaScript checks for value equality without considering the data type, whereas the === operator checks for both value and type equality. This distinction is crucial in ensuring accurate comparisons in JavaScript.
Which routing protocol is commonly used within an Autonomous System (AS)?
- BGP
- EIGRP
- OSPF
- RIP
OSPF (Open Shortest Path First) is commonly used within an Autonomous System (AS) due to its advanced features such as fast convergence, scalability, and support for variable-length subnet masking (VLSM).
In RESTful APIs, ___________ is used to represent the state of a resource.
- JSON
- XML
- HTML
- URI
The correct option is URI. In RESTful APIs, Uniform Resource Identifiers (URIs) are used to uniquely identify and represent resources. URIs play a crucial role in REST architecture by providing a way to interact with resources via HTTP methods such as GET, POST, PUT, and DELETE.
How does a breadth-first search (BFS) differ from a depth-first search (DFS) in terms of traversal order in graphs?
- BFS explores nodes level by level
- BFS uses a queue
- DFS explores nodes depth-wise
- DFS uses a stack
Breadth-first search (BFS) explores nodes level by level starting from the root node, using a queue to keep track of nodes to be visited. On the other hand, depth-first search (DFS) explores nodes depth-wise, going as far as possible along a branch before backtracking, typically using a stack to keep track of nodes. This fundamental difference in traversal order distinguishes BFS from DFS in graph traversal.
In a relational database, a _________ ensures that each row in a table is uniquely identifiable.
- Foreign Key
- Index
- Primary Key
- Unique Constraint
A primary key is a column or group of columns that uniquely identifies each row in a table. It must contain unique values and cannot have NULL values. This uniqueness ensures that each row can be uniquely identified and retrieved from the table.