Java Interview Q&A
Java Interview Q&A
3. What is the difference between INNER JOIN, LEFT JOIN, and RIGHT JOIN?
INNER JOIN returns matching rows from both tables.
LEFT JOIN returns all records from the left table and matched rows from the right.
RIGHT JOIN does the opposite—use based on what data you need to preserve.
SELECT MAX(salary) FROM employees WHERE salary < (SELECT MAX(salary) FROM
employees);
This avoids LIMIT or ROWNUM which can vary by RDBMS.
7. What is an index?
An index improves query performance by allowing faster lookups on columns.
However, too many indexes slow down write operations.
Use indexes wisely for columns in WHERE, JOIN, or ORDER BY.
===================================================================================
========================================
Rest & Microservices
-------------------------------
1. What is REST and how does it work?
REST (Representational State Transfer) is an architectural style that uses HTTP
methods to perform CRUD operations on resources.
It treats data as resources and uses URIs to access them.
It is stateless, cacheable, and supports layered architecture.
3. What is a Dockerfile?
A Dockerfile is a script that contains instructions to build a Docker image.
It defines base images, copies files, installs dependencies, and sets entry points.
It enables consistent and automated image creation.
18. What is a service mesh and when would you use it?
A service mesh like Istio or Linkerd manages microservice-to-microservice
communication.
It adds observability, traffic control, and security without changing application
code.
Used in complex microservices environments.