GRT Technical Skills 3 — Questions and Answers
Question 1: Which HTTP status code indicates that a resource has been permanently moved to a new URL?
- 301 (Correct answer)
- 302
- 304
- 307
Correct answer: 301
HTTP 301 (Moved Permanently) tells clients and search engines to update their links to the new URL.
Question 2: What is the primary purpose of an index in a database?
- To enforce referential integrity between tables
- To speed up data retrieval at the cost of additional storage (Correct answer)
- To encrypt sensitive columns
- To partition large tables across multiple servers
Correct answer: To speed up data retrieval at the cost of additional storage
Database indexes allow the engine to locate rows quickly without scanning every row, trading storage space for faster query performance.
Question 3: In software testing, what is the difference between a stub and a mock?
- Stubs verify behavior; mocks provide canned responses
- Stubs provide canned responses; mocks verify behavior (Correct answer)
- Both are identical in function
- Stubs are used in unit tests; mocks are used in integration tests
Correct answer: Stubs provide canned responses; mocks verify behavior
Stubs return predefined responses to isolate the unit under test, while mocks additionally verify that specific calls were made.
Question 4: Which design pattern provides a single point of access to an instance of a class throughout an application?
- Factory Pattern
- Observer Pattern
- Singleton Pattern (Correct answer)
- Decorator Pattern
Correct answer: Singleton Pattern
The Singleton Pattern restricts a class to one instance and provides a global access point to that instance.
Question 5: What is the Big-O time complexity of searching for an element in a balanced binary search tree?
- O(1)
- O(n)
- O(log n) (Correct answer)
- O(n log n)
Correct answer: O(log n)
In a balanced BST, each comparison eliminates half the remaining nodes, resulting in O(log n) search time.
Question 6: A developer notices that their REST API endpoint is vulnerable to SQL injection. Which mitigation technique is most effective?
- Input length validation
- Parameterized queries (prepared statements) (Correct answer)
- Encoding output with Base64
- Rate limiting the API endpoint
Correct answer: Parameterized queries (prepared statements)
Parameterized queries separate SQL code from user input, preventing malicious SQL from being executed by the database engine.
Question 7: In TCP/IP networking, what is the purpose of the ARP protocol?
- Assigns dynamic IP addresses to hosts on a network
- Resolves IP addresses to MAC addresses on a local network (Correct answer)
- Routes packets between different networks
- Encrypts data in transit between two hosts
Correct answer: Resolves IP addresses to MAC addresses on a local network
Address Resolution Protocol (ARP) maps a known IPv4 address to the corresponding MAC address needed for Layer 2 frame delivery.
Which HTTP status code indicates that a resource has been permanently moved to a new URL?