JAVA & SQL REVISION NOTES (PRINTABLE)
PART 1: JAVA REVISION NOTES
1. Java Basics
What is Java?
• Java is a high-level, object-oriented, platform-independent programming language.
• Platform-independent because Java code is compiled into bytecode, which runs on the JVM.
JDK vs JRE vs JVM
• JDK: Java Development Kit (used to develop programs)
• JRE: Java Runtime Environment (used to run programs)
• JVM: Java Virtual Machine (executes bytecode)
2. Data Types
Primitive Data Types
• byte (1 byte)
• short (2 bytes)
• int (4 bytes)
• long (8 bytes)
• float (4 bytes)
• double (8 bytes)
• char (2 bytes)
• boolean (true/false)
Non-Primitive Data Types
• String
• Array
• Class
• Interface
1
3. Variables & Scope
• Local Variable: declared inside method
• Instance Variable: declared inside class, outside method
• Static Variable: shared across all objects
4. Control Statements
Conditional Statements
• if , if-else , switch
Looping Statements
• for
• while
• do-while
5. Object-Oriented Programming (OOPs)
Class & Object
• Class: blueprint
• Object: instance of class
Encapsulation
• Wrapping data and methods together
• Achieved using private variables + getters/setters
Inheritance
• One class acquires properties of another class
• Uses extends
• Promotes code reusability
Polymorphism
• Same method name, different behavior
• Compile-time: Method Overloading
• Runtime: Method Overriding
Abstraction
• Hiding implementation details
2
• Achieved using:
• Abstract class
• Interface
Abstract Class vs Interface
Abstract Class Interface
Can have methods with body Only abstract methods (Java 8+ default allowed)
Uses extends Uses implements
6. Constructors
• Used to initialize objects
• Same name as class
• No return type
7. Keywords
this
• Refers to current object
super
• Refers to parent class object
static
• Belongs to class, not object
final
• final variable → value cannot change
• final method → cannot override
• final class → cannot inherit
8. Access Modifiers
Modifier Scope
public Everywhere
3
Modifier Scope
private Same class
protected Same package + subclass
default Same package
9. Exception Handling
Types of Exceptions
• Checked: Compile-time (IOException)
• Unchecked: Runtime (NullPointerException)
Keywords
• try
• catch
• finally
• throw
• throws
10. Collections Framework
List
• Allows duplicates
• Maintains order
• Example: ArrayList
Set
• No duplicates
• Example: HashSet
Map
• Key-value pairs
• Keys are unique
• Example: HashMap
4
11. Java in Testing Context
• Used in TestNG automation
• Writing reusable methods
• Annotations: @Test , @BeforeMethod , @AfterMethod
• Used for UI and API validation
PART 2: SQL REVISION NOTES
1. SQL Basics
What is SQL?
• Structured Query Language
• Used to interact with databases
Database Components
• Database
• Table
• Row
• Column
2. SQL Data Types
• INT
• VARCHAR(n)
• CHAR(n)
• DATE
• TIMESTAMP
• BOOLEAN
3. Basic SQL Queries
SELECT
SELECT * FROM table_name;
5
WHERE
SELECT * FROM employees WHERE salary > 50000;
DISTINCT
SELECT DISTINCT department FROM employees;
ORDER BY
SELECT * FROM employees ORDER BY salary DESC;
4. Conditions & Operators
• AND , OR , NOT
• IN
• BETWEEN
• LIKE
5. Aggregate Functions
• COUNT()
• SUM()
• AVG()
• MAX()
• MIN()
Example:
SELECT COUNT(*) FROM employees;
6. JOINS
INNER JOIN
• Returns matching records
6
LEFT JOIN
• All records from left table + matched from right
RIGHT JOIN
• All records from right table + matched from left
7. NULL Handling
• IS NULL
• IS NOT NULL
• COALESCE()
Example:
SELECT COALESCE(bonus, 0) FROM employees;
8. Subqueries
• Query inside another query
Example:
SELECT * FROM orders
WHERE customer_id IN (
SELECT id FROM customers
);
FINAL INTERVIEW TIP
• Relate Java to automation and backend logic
• Relate SQL to data validation and reporting
• Focus on clarity, not memorization
END OF REVISION NOTES