What layer of the TCP/IP model is responsible for packet routing?

  • Application
  • Transport
  • Internet
  • Data Link
The correct option is "Internet." In the TCP/IP model, packet routing occurs at the Internet layer (Layer 3). This layer is responsible for addressing, routing, and delivering packets between different networks. The Internet Protocol (IP) operates at this layer, providing the necessary functions for packet routing across the Internet.

How does the Proxy design pattern differ from the Decorator design pattern?

  • Proxy adds new behavior; Decorator manages object's responsibilities
  • Proxy controls access to an object; Decorator adds functionality
  • Proxy does not modify object; Decorator modifies object's behavior
  • Proxy modifies existing behavior; Decorator adds new behavior
The Proxy design pattern acts as a surrogate or placeholder for another object and controls access to it. On the other hand, the Decorator pattern dynamically adds new functionality to an object without altering its structure. Proxy focuses on controlling access, while Decorator focuses on adding responsibilities. Understanding these distinctions is crucial when deciding which pattern to use in a given context.

Which sorting algorithm has the best time complexity in the worst-case scenario?

  • Bubble sort
  • Merge sort
  • Quick sort
  • Insertion sort
Merge sort has the best time complexity in the worst-case scenario among the given options. It has a time complexity of O(n log n) in all cases, making it efficient for large datasets. Quick sort can have a worst-case time complexity of O(n^2) in certain scenarios, making it less preferable for worst-case scenarios compared to merge sort.

In an e-commerce application, you're tasked with optimizing database queries to display product recommendations based on user preferences. How would you approach this problem using RDBMS concepts?

  • Implement indexing on product attributes and user preferences; Use query optimization techniques
  • Use NoSQL databases for faster retrieval; Implement caching mechanisms
  • Use complex SQL queries with subqueries for recommendations
  • Normalize database tables to reduce redundancy
Option 1 is correct. In an e-commerce application, optimizing queries for product recommendations involves indexing relevant attributes like product categories, user preferences, and purchase history. This speeds up retrieval by reducing search times. Query optimization techniques further enhance performance. NoSQL databases may offer scalability benefits but might not align with RDBMS concepts directly. Caching can improve performance but is secondary to optimizing queries. Complex SQL queries and normalization may not be optimal for recommendation systems due to performance overhead and complexity.

What are JSON Web Tokens (JWT) and how are they used for authentication in web applications?

  • Encoded JSON Objects for Secure Data Transmission
  • Serialized Tokens for Session Management
  • Signed Tokens for Stateful Authentication
  • Tokens Generated by OAuth for User Authentication
JSON Web Tokens (JWT) are compact, self-contained tokens used for authentication in web apps. They are signed to ensure integrity and can carry user identity and other claims securely. OAuth tokens are different from JWTs, used for access delegation, while JWTs are used for stateful authentication. JWTs are often employed for session management, allowing servers to verify user authenticity and authorize access to resources securely.

You're designing a RESTful API for a social media platform. How would you handle pagination for retrieving a large number of user posts efficiently?

  • Combine offset-based pagination with filtering options for more granular control over result sets.
  • Implement cursor-based pagination using a timestamp or unique identifier.
  • Use page-based pagination with a limit and offset parameters.
  • Utilize token-based pagination by returning a token for the next page of results.
Cursor-based pagination using a timestamp or unique identifier is efficient for handling large datasets as it ensures stable pagination results even if items are added or removed. It also reduces the chances of duplicate or missing data during pagination.

When should you typically start debugging a COBOL program?

  • After the program is fully coded
  • After the program is tested
  • Before coding begins
  • During program design
Debugging in COBOL typically starts after the program is coded. It involves identifying and fixing errors in the code to ensure that the program functions as intended during testing and execution.

In COBOL, what is the purpose of a level-number when defining group data items?

  • To control the scope of the data item
  • To identify the data item as a group or elementary item
  • To indicate the level of nesting in the group hierarchy
  • To specify the physical length of the data item
The level-number in COBOL is used to distinguish between group-level and elementary-level data items. A level-number of 01 indicates an elementary item, while higher-level numbers indicate a group item.

COBOL provides _______ verbs for VSAM and ISAM file handling to open, close, read, and write records.

  • FILE-CONTROL
  • I-O
  • SORT
  • STOP RUN
COBOL provides I-O (Input-Output) verbs for VSAM and ISAM file handling. These verbs, such as OPEN, CLOSE, READ, WRITE, and others, are used to perform various file operations.

In a COBOL program for a bank, you need to determine the account type and apply specific rules based on the account type (e.g., savings, checking, or credit card). Which conditional statement is best suited for this complex decision-making process?

  • CASE
  • EVALUATE
  • IF...ELSE
  • INSPECT
The EVALUATE statement in COBOL is ideal for handling complex decision-making with multiple conditions, making it suitable for determining account types and applying specific rules in a bank program.