Complete Java and SQL Interview Notes
All Questions Covered (Technical + Interview
Oriented)
JAVA NOTES
What is Java?
Java is a high-level, object-oriented, platform-independent programming language. It uses JVM to
run the same code on different operating systems.
Features of Java
Java is secure, robust, platform-independent, and supports multithreading and garbage collection.
JVM, JRE, JDK
JVM runs bytecode, JRE provides runtime environment, and JDK provides development tools.
OOP Concepts
Java follows Encapsulation, Inheritance, Polymorphism, and Abstraction for better code structure.
Encapsulation
Encapsulation binds data and methods together and restricts direct access using private variables.
Inheritance
Inheritance allows one class to acquire properties of another using the extends keyword.
Polymorphism
Polymorphism allows methods to behave differently using overloading and overriding.
Interface
An interface provides abstraction and supports multiple inheritance in Java.
Functional Interface
An interface with only one abstract method, used with lambda expressions.
Marker Interface
An interface without methods used to provide metadata to JVM.
String and String Pool
String is immutable and string literals are stored in the string pool to save memory.
== vs equals()
== compares references, equals() compares actual content.
Exception Handling
Java uses try-catch-finally to handle runtime errors safely.
Multithreading
Multithreading allows concurrent execution of tasks for better performance.
Lambda Expression
Lambda expressions reduce code length and improve readability.
Stream API
Stream API processes collections using filter, map, and reduce operations.
SQL NOTES
What is SQL?
SQL is used to store, retrieve, update, and delete data from relational databases.
Types of SQL Commands
DDL, DML, DCL, TCL, and DQL are used for database operations.
Normalization
Normalization reduces data redundancy and improves consistency.
Primary Key and Foreign Key
Primary key uniquely identifies records, foreign key maintains table relationships.
Joins
Joins combine data from multiple tables using common columns.
Indexes
Indexes improve query performance by speeding up data search.
Views
Views are virtual tables created using SQL queries.
WHERE vs HAVING
WHERE filters rows before grouping, HAVING filters after grouping.
GROUP BY vs ORDER BY
GROUP BY groups records, ORDER BY sorts records.
Second Highest Salary Query
This query finds the second maximum salary using subqueries.
ACID Properties
Atomicity, Consistency, Isolation, and Durability ensure safe transactions.