The _________ command is used to add new records to a table in SQL.
- DELETE
- INSERT
- SELECT
- UPDATE
The INSERT command is used in SQL to add new records (rows) to a table. It allows you to specify the values for each column in the new row or provide values for a subset of columns if the table allows NULL values or has default values defined.
What is the purpose of a router in a computer network?
- Connecting devices within a network
- Directing network traffic
- Facilitating wireless connections
- Filtering data packets
A router's primary purpose is to direct network traffic between different networks. It uses routing tables to determine the best path for data packets to reach their destination. This includes directing data between devices on the same network and between different networks, such as a local network and the internet. Routers also provide network address translation (NAT) to allow multiple devices on a network to share a single public IP address.
In a doubly linked list, each node contains a reference to the ___________ and ___________ nodes.
- First, Last
- Last, First
- Next, Previous
- Previous, Next
In a doubly linked list, each node contains references to the next node and the previous node. This is because each node has two pointers, one pointing to the next node and one to the previous node.
Which design pattern is used to ensure a class has only one instance and provides a global point of access to it?
- Factory
- Observer
- Singleton
- Strategy
The design pattern used to ensure a class has only one instance and provides a global point of access to it is the Singleton pattern. This pattern restricts instantiation of a class to a single object and provides a way to access that instance globally. It is commonly used in scenarios such as database connections, logging mechanisms, and configuration settings where having multiple instances can lead to issues like resource wastage or inconsistent behavior.
What are the common security mechanisms used to secure RESTful APIs?
- IP Whitelisting
- JWT (JSON Web Tokens)
- OAuth 2.0
- SSL/TLS Encryption
Secure RESTful APIs employ various mechanisms to protect data and authenticate clients. SSL/TLS encryption ensures that data transmitted between clients and servers is encrypted, preventing unauthorized access and eavesdropping. OAuth 2.0 is a popular authorization framework that allows secure token-based authentication, enabling clients to access resources on behalf of users without exposing sensitive credentials. JWT (JSON Web Tokens) are used for securely transmitting information between parties as compact, URL-safe tokens, facilitating stateless authentication and authorization in RESTful architectures. IP whitelisting restricts access to API endpoints based on predefined IP addresses, enhancing security by allowing only trusted clients to interact with the API. Each of these mechanisms plays a vital role in safeguarding RESTful APIs against common security threats such as data breaches, unauthorized access, and man-in-the-middle attacks.
What are the key characteristics of the Iterative and Incremental SDLC model?
- Incremental model focuses on delivering
- Incremental model involves completing
- Iterative model emphasizes revisiting and
- Iterative model involves building a
The Iterative SDLC model involves revisiting and refining work in multiple cycles, allowing for feedback incorporation and continuous improvement. On the other hand, the Incremental SDLC model delivers functionality in increments, providing tangible value early and enabling progressive development.
Describe the difference between method overloading and method overriding in OOP.
- Overloading means having methods with the same name but different parameters.
- Overloading means replacing a method in a subclass.
- Overriding means having methods with the same name but different parameters.
- Overriding means replacing a method in a subclass.
Method overloading in OOP refers to defining multiple methods in the same class with the same name but different parameters. Method overriding, on the other hand, involves replacing a method in a subclass with a new implementation. This distinction is crucial for polymorphism and code reuse.
In a messaging application, how would you implement message delivery using a queue to ensure messages are delivered in the order they were sent?
- Circular buffer
- FIFO approach
- LIFO approach
- Priority-based approach
Implementing a FIFO (First-In-First-Out) approach using a queue is ideal for ensuring messages are delivered in the order they were sent. In this approach, messages are added to the end of the queue and processed in the same order they were received, maintaining chronological order. A LIFO (Last-In-First-Out) approach would reverse the message order, which is not suitable for messaging applications. Priority-based approaches may prioritize certain messages over others, potentially disrupting the order of delivery. Circular buffers are more suited for fixed-size data storage, not for maintaining message order in a dynamic messaging system.
In a queue, the ___________ operation adds an element to the rear.
- Enqueue
- Dequeue
- Push
- Pop
The correct option is 'Enqueue.' In a queue, the Enqueue operation adds an element to the rear, following the FIFO (First-In-First-Out) principle where the element added first is removed first.
How would you optimize a SQL query that is running slow on a large dataset?
- Add more data to the dataset
- Increase server RAM
- Rewrite the query using optimized SQL syntax
- Use proper indexing
Optimizing a slow SQL query on a large dataset involves using proper indexing techniques. Indexes help the database system locate and retrieve data more efficiently, leading to faster query execution. Rewriting the query using optimized SQL syntax can also improve performance. Increasing server RAM or adding more data won't directly optimize the query's speed.
In a priority queue, elements are dequeued based on their ___________.
- Position
- Priority
- Random
- Value
In a priority queue, elements are dequeued based on their priority level, where higher-priority elements are dequeued before lower-priority elements. Priority queues are often implemented using heaps to efficiently maintain the highest priority element at the front.
How does a database system ensure durability, one of the ACID properties, even in the event of system failures?
- Optimistic Concurrency Control
- Rollback Mechanism
- Two-Phase Commit
- Using Write-Ahead Logging
A database system ensures durability, one of the ACID properties, by using techniques like Write-Ahead Logging (WAL). In WAL, before modifying data in the database, the system first writes the changes to a log file on disk. This log file acts as a record of all transactions, and in the event of a system failure, the database can recover by replaying the logged transactions from the log file to restore the database to a consistent state. This ensures that even if the system crashes, committed transactions are not lost and the database remains durable. Other techniques such as checkpoints and transaction logs also contribute to ensuring durability in database systems, making them robust against failures.