JDK vs JRE vs JVM
JDK (Java Development Kit) is the Java Development Kit and includes tools for developing and compiling Java applications.
JDK = JRE + Development Tools
JRE (Java Runtime Environment) is the Java Runtime Environment and provides the necessary components for running Java applications.
JRE = JDK + Library Classes
JVM (Java Virtual Machine) is the Java Virtual Machine responsible for executing Java bytecode and managing runtime aspects.
Types of Operations Performed by JVM
Loading of code
Verification of code
Executing the code
Provides run-time environment to the users
Types of Memory Area Allocated by JVM
Class (method) Area
Heap
Stack
Program Counter Register
Native Method Stack
What is the static method?
A static method in programming refers to a method that belongs to a class rather than an instance of that class. This means you can call a static method on the class itself, without needing to create an object (instance) of the class.
DELETE vs TRUNCATE
DELETE (DML): The DELETE command is used to remove rows from a database table based on specified conditions. e.g.
DELETE FROM table_name WHERE condition;
TRUNCATE (DDL): The TRUNCATE command is used to remove all rows from a table, effectively resetting the table to its initial state. TRUNCATE is generally faster than DELETE, especially for large tables, because it doesn't log individual row deletions and doesn't generate as much transaction log data. e.g.
TRUNCATE TABLE table_name;
SQL query to get the third max salary of an employee from a table named employee_table. Assume necessary columns of employee table.
SELECT TOP 1 salary FROM (SELECT TOP 3 salary FROM employees ORDER BY salary DESC) AS emp ORDER BY salary ASC