HCL Interview Questions
Practice with real HCL interview questions
01
A Software Engineer was asked
Asked in 2024
Q. Can you explain SQL JOINs and provide examples of INNER JOIN and LEFT JOIN?
Ans. SQL JOINs are used to combine rows from two or more tables based on a related column between them. There are several types of JOINs, but two common ones are INNER JOIN and LEFT JOIN.
1. INNER JOIN: This type of join returns only the rows that have matching values in both tables.
Example: Consider two tables,
employees and departments.
** employees table:**
| employee_id | name | department_id |
|-------------|--------|----------------|
| 1 | Alice | 1 |
| 2 | Bob | 2 |
| 3 | Charlie| NULL |
** departments table:**
| department_id | department_name |
|---------------|-----------------|
| 1 | HR |
| 2 | Engineering |
SQL Query for INNER JOIN:
Result:
| name | department_name |
|--------|-----------------|
| Alice | HR |
| Bob | Engineering |
2. LEFT JOIN: This type of join returns all the rows from the left table (employees) and the matched rows from the right table (departments). If there is no match, NULL values are returned for columns from the right table.
SQL Query for LEFT JOIN:
Result:
| name | department_name |
|---------|-----------------|
| Alice | HR |
| Bob | Engineering |
| Charlie | NULL |
In summary, INNER JOIN gives you only the matching records, while LEFT JOIN provides all records from the left table, along with matched records from the right table or NULL where there is no match.Software EngineerCore Concept
02
A Software Engineer was asked
Asked in 2024
Q. Can you explain the fundamental differences between HTTP and TCP/IP protocols in networking?
Ans. HTTP (Hypertext Transfer Protocol) and TCP/IP (Transmission Control Protocol/Internet Protocol) are foundational protocols in networking, but they serve different purposes.
Key Differences:
1. Layer of Operation:
- TCP/IP: Operates at the transport layer (TCP) and network layer (IP) of the OSI model. It is responsible for transporting data packets across networks.
- HTTP: Operates at the application layer and is used specifically for transmitting hypertext (web pages).
2. Functionality:
- TCP: Ensures reliable data transmission through error checking and acknowledgment of packets.
- HTTP: Defines how messages are formatted and transmitted, and how web servers and browsers respond to various commands.
3. Connection Orientation:
- TCP: Connection-oriented; establishes a connection before transmitting data.
- HTTP: Can be connectionless (HTTP/1.1) or keep connections open (HTTP/2).
Example Code:
TCP Socket Example (Python):
HTTP Request Example (cURL):
Conclusion:
Understanding the differences between HTTP and TCP/IP is crucial for building and troubleshooting networked applications. HTTP relies on TCP for reliable transmission while defining rules for web communication.
Software EngineerCore Concept
