0% found this document useful (0 votes)
4 views16 pages

Core Java & Spring Boot Interview Q&A

The document provides a comprehensive list of interview questions and answers related to Core Java, Spring Boot, HTML, CSS, and SQL, aimed at preparing candidates for IT job interviews. It covers fundamental concepts, differences between key terms, and practical applications in programming and web development. Each section includes essential definitions and explanations to enhance understanding of the respective topics.

Uploaded by

Yogesh Mungase
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views16 pages

Core Java & Spring Boot Interview Q&A

The document provides a comprehensive list of interview questions and answers related to Core Java, Spring Boot, HTML, CSS, and SQL, aimed at preparing candidates for IT job interviews. It covers fundamental concepts, differences between key terms, and practical applications in programming and web development. Each section includes essential definitions and explanations to enhance understanding of the respective topics.

Uploaded by

Yogesh Mungase
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Skillio, Pune’s Best IT Training and Placement Institute

Core Java Interview Questions with Detailed Answers

1. What is JVM?

JVM (Java Virtual Machine) is the core engine responsible for executing Java bytecode. It
provides the runtime environment where Java programs run, managing memory, garbage
collection, and platform abstraction. It converts platform-independent bytecode into
machine-specific instructions, making Java portable across devices.

2. What is JDK and JRE?

JDK (Java Development Kit) is used by developers to create Java applications and includes
the compiler (javac), debugger, and JRE. JRE (Java Runtime Environment) provides libraries
and the JVM needed to run Java programs. In short, JDK = JRE + development tools.

3. Difference between abstract class and interface?

An abstract class can contain both abstract and concrete methods, constructors, and
member variables. Interfaces can only declare abstract methods (before Java 8) but cannot
maintain state. Abstract classes are used for shared base implementations, while interfaces
define a contract for behavior.

4. Why Java is platform independent?

Java achieves platform independence through its bytecode system. When a program is
compiled, it generates .class files containing bytecode, which can run on any operating
system having a JVM. This mechanism allows 'write once, run anywhere' capability.

5. What is constructor overloading?

Constructor overloading is defining multiple constructors with different parameter lists in


the same class. It allows object creation in multiple ways depending on initialization needs.
Java distinguishes constructors by their parameter count and types.

6. Can we overload main() method?

Yes, main() method can be overloaded in Java. However, the JVM only invokes the signature
`public static void main(String[] args)` at runtime. Other overloaded versions must be called
explicitly within the standard main method.

7. Difference between == and equals()?

The `==` operator compares reference equality (memory addresses), while `equals()`
compares object content. For example, two String objects may have the same value but
reside in different memory locations, making `==` false but `equals()` true.

Skillio, Pune +91-9130502135 | +91-8484831616


Skillio, Pune’s Best IT Training and Placement Institute

8. What is String immutability?

A String in Java is immutable, meaning its content cannot be modified after creation. Any
operation that appears to modify a String actually creates a new one. This property ensures
thread safety and efficient memory management via the String pool.

9. Why Java is not 100% Object-Oriented?

Java is not fully object-oriented because it supports primitive data types (int, char, float,
etc.) that are not objects. However, it provides wrapper classes (Integer, Character, etc.) to
convert primitives into objects when needed.

10. What is static keyword used for?

The static keyword defines members that belong to the class rather than any object
instance. Static methods and variables can be accessed directly using the class name. It’s
commonly used for utility functions and constants.

11. What are access modifiers?

Access modifiers define the visibility of classes, methods, and variables. Java provides four
types: public (accessible everywhere), protected (within package and subclasses), default
(within same package), and private (within same class).

12. What is final keyword?

The final keyword in Java is used to restrict modification. When applied to a variable, it
becomes a constant; when used on a method, it prevents overriding; and when applied to a
class, it prevents inheritance.

13. Difference between throw and throws?

The throw keyword is used to explicitly throw an exception from a method or block, while
throws is used in method declarations to specify which exceptions can be propagated by
that method. throw generates an exception object, while throws indicates possible
exceptions.

14. What is checked and unchecked exception?

Checked exceptions are compile-time exceptions that must be handled using try-catch or
declared using throws. Unchecked exceptions occur at runtime, such as
ArithmeticException or NullPointerException, and do not require explicit handling.

15. What is the purpose of finally block?

The finally block executes after try and catch blocks, regardless of whether an exception
occurs. It is primarily used for cleanup operations like closing files or database connections
to ensure resource deallocation.

Skillio, Pune +91-9130502135 | +91-8484831616


Skillio, Pune’s Best IT Training and Placement Institute

16. What is Collection Framework?

The Java Collection Framework provides a set of interfaces and classes to store and
manipulate groups of objects efficiently. It includes data structures like List, Set, and Map,
and classes such as ArrayList, HashSet, and HashMap.

17. Difference between ArrayList and LinkedList?

ArrayList uses a dynamic array to store elements and provides fast random access but slow
insertions/deletions. LinkedList uses nodes connected by pointers, making
insertions/deletions faster but random access slower.

18. Difference between HashMap and Hashtable?

HashMap is not synchronized, allowing better performance in single-threaded


environments, while Hashtable is synchronized and thread-safe. Also, HashMap allows null
keys and values, while Hashtable does not.

19. What is transient keyword?

The transient keyword prevents variables from being serialized when an object is
converted into a byte stream. It is used for fields that are sensitive or not relevant to the
serialized state, such as passwords or temporary data.

20. Explain garbage collection in Java.

Garbage collection is the process by which the JVM automatically identifies and removes
unused objects from memory, freeing space and preventing memory leaks. It helps manage
memory efficiently without manual intervention.

Skillio, Pune +91-9130502135 | +91-8484831616


Skillio, Pune’s Best IT Training and Placement Institute

Spring Boot Interview Questions with Detailed Answers

21. What is Spring Boot?

Spring Boot is an opinionated framework built on top of the Spring ecosystem that
simplifies application development by providing auto-configuration, embedded servers, and
production-ready features. It reduces boilerplate configuration and lets developers
bootstrap standalone applications quickly using starter dependencies.

22. Difference between Spring and Spring Boot?

Spring is a comprehensive framework that requires explicit configuration for many


concerns, while Spring Boot adds conventions and auto-configuration to minimize manual
setup. Spring Boot packages embedded servers and starters to accelerate development and
deployment of Spring-based applications.

23. What is @SpringBootApplication?

@SpringBootApplication is a meta-annotation that combines @Configuration,


@EnableAutoConfiguration, and @ComponentScan. It marks the main class of a Spring Boot
application and triggers component scanning and auto-configuration when the application
starts.

24. How does auto-configuration work?

Auto-configuration uses conditional configuration classes and property values to create and
configure beans automatically. Spring Boot inspects the classpath and available beans, then
applies sensible defaults unless overridden by explicit user configuration.

25. What are starter dependencies?

Starters are curated dependency descriptors that bundle common libraries for a particular
capability, such as web, data JPA, or security. Using starters simplifies dependency
management by avoiding manual selection of many individual libraries.

26. What is [Link] or [Link]?

These files hold externalized configuration for a Spring Boot application. Properties defined
here control server settings, datasource connections, logging levels, and custom application
values. YAML ([Link]) supports hierarchical configuration, while properties use
key-value pairs.

27. Explain dependency injection in Spring Boot.

Dependency injection in Spring Boot is the same as in Spring core: the framework manages
object creation and wiring. Beans are declared via annotations or configuration and injected
using constructor, setter, or field injection to promote loose coupling and testability.

Skillio, Pune +91-9130502135 | +91-8484831616


Skillio, Pune’s Best IT Training and Placement Institute

28. What is @RestController?

@RestController is a convenience annotation that combines @Controller and


@ResponseBody. It designates a class as a RESTful controller whose handler methods
return domain objects that are serialized to JSON or XML directly in the HTTP response.

29. How to handle exceptions globally in Spring Boot?

Global exception handling can be implemented using @ControllerAdvice combined with


@ExceptionHandler methods. This approach centralizes error handling and allows
consistent HTTP responses for different exception types across controllers.

30. What is Spring Boot Actuator?

Actuator provides production-ready endpoints and metrics to monitor and manage the
running application. It exposes health checks, metrics, environment, thread dumps, and
custom endpoints that help observe application behavior in production.

31. How to change default port in Spring Boot?

You can change the default server port by setting [Link] in [Link] or
[Link]. For example, [Link]=9090 will start the embedded server on port
9090 instead of 8080.

32. What is @ConfigurationProperties?

@ConfigurationProperties binds external configuration properties (from


[Link] or YAML) to strongly-typed POJOs. It simplifies managing groups of
related settings and supports validation annotations for sanity checks.

33. How to connect Spring Boot with a database using JPA?

Add spring-boot-starter-data-jpa and the database driver to dependencies, configure


datasource settings in [Link], and define @Entity classes and Spring Data
JPA repositories. Spring Boot auto-configures EntityManager and transaction management
for you.

34. What is Spring Profiles?

Spring Profiles allow separating configuration for different environments such as dev, test,
and prod. You can activate profiles via properties or command-line arguments and define
profile-specific beans or properties files like [Link].

35. What is the role of embedded servlet containers?

Embedded servlet containers like Tomcat or Jetty allow Spring Boot applications to run as
standalone JARs without deploying to an external application server. The container is
packaged with the application and started programmatically at runtime.

Skillio, Pune +91-9130502135 | +91-8484831616


Skillio, Pune’s Best IT Training and Placement Institute

36. How to secure Spring Boot applications?

Spring Security integrates with Spring Boot to provide authentication and authorization.
Add spring-boot-starter-security, configure security rules via
WebSecurityConfigurerAdapter or SecurityFilterChain, and protect endpoints using role-
based access control and token mechanisms like JWT.

37. How does Spring Boot support testing?

Spring Boot provides testing support via spring-boot-starter-test which bundles JUnit,
Mockito, Spring Test, and utilities like @SpringBootTest for integration tests. Test slices
such as @WebMvcTest and @DataJpaTest help load only part of the context for faster tests.

38. What is Actuator health check and how to customize it?

Actuator's health endpoint aggregates built-in and custom HealthIndicator beans to report
the application's health status. You can implement HealthIndicator to add custom checks
(e.g., disk space, third-party service) and configure exposure and security of endpoints.

39. How to implement configuration reload without restarting?

Spring Boot supports configuration reload using Spring Cloud Config or devtools for
development. Spring Cloud Config provides a centralized configuration server and refresh
endpoints; Spring Boot DevTools enables automatic restart on classpath changes during
development.

40. How to create custom starter?

A custom starter is a reusable dependency module that bundles common auto-configuration


and opinionated defaults. Create a Maven/Gradle module with META-INF/[Link]
or use spring-boot-autoconfigure, provide conditionally applied @Configuration classes,
and publish the starter for reuse across projects.

Skillio, Pune +91-9130502135 | +91-8484831616


Skillio, Pune’s Best IT Training and Placement Institute

HTML and CSS Interview Questions with Detailed Answers

41. What is HTML?

HTML (Hypertext Markup Language) is the standard markup language used to structure
and display content on the web. It uses tags to define elements like headings, paragraphs,
images, links, and forms. HTML acts as the skeleton of a webpage and works together with
CSS for styling and JavaScript for interactivity.

42. What is CSS and why is it used?

CSS (Cascading Style Sheets) is a stylesheet language used to control the presentation and
layout of HTML elements. It separates design from structure, allowing developers to apply
consistent styles like colors, fonts, and spacing across multiple pages, improving
maintainability and design flexibility.

43. What are semantic elements in HTML?

Semantic elements clearly describe their meaning and purpose both to the browser and
developers. Examples include <header>, <footer>, <article>, <section>, and <nav>. Using
semantic tags improves accessibility, SEO, and readability of code, helping search engines
and assistive tools understand page structure.

44. What is the difference between block-level and inline elements?

Block-level elements, such as <div>, <p>, and <h1>, occupy the full width available and start
on a new line. Inline elements, like <span>, <a>, and <strong>, only take as much width as
needed and do not break the flow of text. This distinction helps in layout and alignment
control.

45. What is the CSS Box Model?

The CSS Box Model defines how elements are rendered and how their dimensions are
calculated. It consists of four components: content, padding, border, and margin.
Understanding the box model is crucial for designing precise layouts, spacing, and
alignment in web pages.

46. What is Flexbox in CSS?

Flexbox (Flexible Box Layout) is a CSS layout module that provides an efficient way to align,
distribute, and space elements within a container. It simplifies creating responsive designs
by automatically adjusting the size and order of elements without using floats or positioning
hacks.

47. What are CSS selectors and their types?

Skillio, Pune +91-9130502135 | +91-8484831616


Skillio, Pune’s Best IT Training and Placement Institute

CSS selectors are patterns used to select and style specific HTML elements. Common types
include element selectors (p), class selectors (.classname), id selectors (#idname), attribute
selectors, pseudo-classes (:hover), and pseudo-elements (::before). They determine which
elements a CSS rule applies to.

48. What are media queries and why are they important?

Media queries allow developers to apply different CSS rules based on device characteristics
such as screen width, height, or orientation. They are essential for responsive web design,
ensuring that websites adapt and look good on various devices like phones, tablets, and
desktops.

49. What is the difference between relative and absolute positioning in CSS?

Relative positioning adjusts an element relative to its normal position without affecting
other elements. Absolute positioning, on the other hand, removes the element from the
normal document flow and positions it relative to the nearest positioned ancestor, offering
more precise control.

50. What is z-index and how does it work?

The z-index property controls the stacking order of overlapping elements along the z-axis
(front-to-back order). Elements with higher z-index values appear above those with lower
values. It only works on elements with position values other than static (e.g., relative,
absolute, fixed).

Skillio, Pune +91-9130502135 | +91-8484831616


Skillio, Pune’s Best IT Training and Placement Institute

SQL Interview Questions with Detailed Answers

51. What is SQL?

SQL (Structured Query Language) is used to interact with relational databases. It allows
users to perform operations such as creating tables, inserting, updating, deleting, and
retrieving data. SQL ensures consistency and accuracy of data while supporting complex
queries for analytics and reporting.

52. What is the difference between DDL and DML commands?

DDL (Data Definition Language) includes commands like CREATE, ALTER, DROP, and
TRUNCATE used to define or modify database structures. DML (Data Manipulation
Language) includes commands like SELECT, INSERT, UPDATE, and DELETE used to
manipulate the data within tables.

53. What is a primary key?

A primary key uniquely identifies each record in a table and ensures that no duplicate or
NULL values exist in that column. Each table can have only one primary key, which can
consist of one or more columns (composite key).

54. What is a foreign key?

A foreign key in one table refers to the primary key in another table. It establishes a
relationship between the two tables and enforces referential integrity, ensuring that data
remains consistent across related tables.

55. What is normalization and its types?

Normalization is the process of organizing data to reduce redundancy and dependency. It


divides large tables into smaller ones linked by relationships. Common normal forms
include 1NF (atomic values), 2NF (no partial dependency), 3NF (no transitive dependency),
and BCNF (strict 3NF).

56. What is a JOIN in SQL?

A JOIN combines rows from two or more tables based on a related column. Types of joins
include INNER JOIN (matching records), LEFT JOIN (all from left table), RIGHT JOIN (all
from right table), and FULL JOIN (all records from both tables).

57. What is the difference between WHERE and HAVING clauses?

WHERE filters rows before grouping, while HAVING filters groups after aggregation.
WHERE cannot be used with aggregate functions, whereas HAVING is typically used with
GROUP BY to restrict results based on aggregated values.

Skillio, Pune +91-9130502135 | +91-8484831616


Skillio, Pune’s Best IT Training and Placement Institute

58. What is an index in SQL?

An index improves query performance by allowing faster data retrieval from a table. It
creates a data structure similar to a lookup table. However, indexes slow down write
operations because they must be updated whenever data changes.

59. What is a view in SQL?

A view is a virtual table created from the result of a SELECT query. It simplifies complex
queries, enhances security by restricting data access, and allows reusability of SQL logic
without storing additional data.

60. What is a subquery?

A subquery is a query nested within another query. It is used to perform operations like
filtering or comparison based on data retrieved from another table. Subqueries can be
correlated or non-correlated depending on dependency on the outer query.

61. What is the difference between DELETE, TRUNCATE, and DROP?

DELETE removes specific rows based on a condition and can be rolled back. TRUNCATE
removes all rows but keeps the table structure intact. DROP deletes the table entirely,
including structure and data, and cannot be rolled back.

62. What is a unique key?

A unique key ensures that all values in a column or combination of columns are distinct.
Unlike primary keys, a table can have multiple unique keys, and they allow one NULL value.

63. What are constraints in SQL?

Constraints are rules applied to table columns to enforce data integrity. Common
constraints include NOT NULL, UNIQUE, PRIMARY KEY, FOREIGN KEY, CHECK (condition-
based), and DEFAULT (auto-assign value).

64. What are aggregate functions in SQL?

Aggregate functions perform calculations on multiple rows and return a single result.
Common functions include COUNT(), SUM(), AVG(), MAX(), and MIN(). They are often used
with GROUP BY for data analysis.

65. What is the difference between IN and EXISTS?

IN compares a column’s value to a list or subquery result, while EXISTS checks if a subquery
returns any rows. EXISTS is generally faster when subquery results are large because it
stops processing after finding the first match.

66. What is a self join?

Skillio, Pune +91-9130502135 | +91-8484831616


Skillio, Pune’s Best IT Training and Placement Institute

A self join is a regular join where a table is joined with itself. It is used when data in the
same table must be compared, such as finding hierarchical relationships or duplicate
entries.

67. What is a stored procedure?

A stored procedure is a precompiled set of SQL statements stored in the database. It


improves performance, reusability, and security by encapsulating logic that can be executed
with a single call.

68. What is a trigger in SQL?

A trigger is a special stored procedure that executes automatically in response to specific


database events like INSERT, UPDATE, or DELETE. It helps enforce business rules and
maintain audit logs.

69. What is a transaction in SQL?

A transaction is a sequence of operations performed as a single logical unit of work. It


ensures data integrity through ACID properties: Atomicity, Consistency, Isolation, and
Durability. COMMIT saves changes, while ROLLBACK undoes them.

70. What is the difference between UNION and UNION ALL?

UNION combines the results of two or more queries and removes duplicates, while UNION
ALL includes duplicates as well. UNION is slower because it performs a distinct operation on
results before combining them.

Skillio, Pune +91-9130502135 | +91-8484831616


Skillio, Pune’s Best IT Training and Placement Institute

Microservices Interview Questions with Detailed Answers

71. What are Microservices?

Microservices are an architectural style that structures an application as a collection of


small, independent services, each focusing on a specific business capability. These services
communicate using lightweight protocols like HTTP or messaging queues. This design
promotes scalability, maintainability, and faster deployment cycles.

72. What is the difference between Monolithic and Microservices architecture?

A monolithic architecture combines all components of an application into a single unit,


making scaling and maintenance difficult. In contrast, microservices architecture
decomposes the application into smaller, independently deployable services, allowing for
easier updates, scalability, and technology flexibility.

73. What is an API Gateway in Microservices?

An API Gateway acts as the single entry point for client requests in a microservices system.
It routes requests to appropriate services, handles authentication, rate limiting, and load
balancing, and provides cross-cutting concerns like logging and security.

74. What is Service Discovery and why is it needed?

Service Discovery is the mechanism by which microservices locate each other dynamically.
As services scale or change their network locations, a service registry like Eureka or Consul
keeps track of available instances and enables clients to find them automatically.

75. What is Load Balancing in Microservices?

Load balancing distributes incoming network traffic across multiple service instances to
ensure no single instance becomes overloaded. This improves application availability, fault
tolerance, and response time. Tools like Nginx, Ribbon, or Kubernetes services handle this
automatically.

76. What is the Circuit Breaker Pattern?

The Circuit Breaker Pattern prevents cascading failures in distributed systems by stopping
requests to a failing service. When a service call repeatedly fails, the circuit opens,
redirecting traffic or returning fallback responses until the service recovers. Libraries like
Resilience4j and Hystrix implement this pattern.

77. What is Docker and how does it relate to Microservices?

Docker is a containerization platform that packages applications and their dependencies


into lightweight, portable containers. It ensures consistent environments across

Skillio, Pune +91-9130502135 | +91-8484831616


Skillio, Pune’s Best IT Training and Placement Institute

development, testing, and production. In microservices, Docker helps deploy each service
independently with its own environment and runtime.

78. What is RESTful Communication in Microservices?

REST (Representational State Transfer) is a communication protocol that uses standard


HTTP methods like GET, POST, PUT, and DELETE. Microservices often use REST APIs for
synchronous communication between services due to simplicity, scalability, and
statelessness.

79. What are challenges in Microservices architecture?

Common challenges include service coordination, distributed transactions, data


consistency, network latency, and monitoring. Handling inter-service communication and
maintaining observability through centralized logging and tracing are critical for stability
and debugging.

80. How do Microservices communicate with databases?

Each microservice typically manages its own database to ensure loose coupling and data
independence. This prevents shared schema issues and allows each service to use the
database technology best suited to its needs, an approach known as the 'Database per
Service' pattern.

Skillio, Pune +91-9130502135 | +91-8484831616


Skillio, Pune’s Best IT Training and Placement Institute

SQL Interview Questions with Detailed Answers

81. What is SQL?

SQL (Structured Query Language) is used to interact with relational databases. It allows
users to perform operations such as creating tables, inserting, updating, deleting, and
retrieving data. SQL ensures consistency and accuracy of data while supporting complex
queries for analytics and reporting.

82. What is the difference between DDL and DML commands?

DDL (Data Definition Language) includes commands like CREATE, ALTER, DROP, and
TRUNCATE used to define or modify database structures. DML (Data Manipulation
Language) includes commands like SELECT, INSERT, UPDATE, and DELETE used to
manipulate the data within tables.

83. What is a primary key?

A primary key uniquely identifies each record in a table and ensures that no duplicate or
NULL values exist in that column. Each table can have only one primary key, which can
consist of one or more columns (composite key).

84. What is a foreign key?

A foreign key in one table refers to the primary key in another table. It establishes a
relationship between the two tables and enforces referential integrity, ensuring that data
remains consistent across related tables.

85. What is normalization and its types?

Normalization is the process of organizing data to reduce redundancy and dependency. It


divides large tables into smaller ones linked by relationships. Common normal forms
include 1NF (atomic values), 2NF (no partial dependency), 3NF (no transitive dependency),
and BCNF (strict 3NF).

86. What is a JOIN in SQL?

A JOIN combines rows from two or more tables based on a related column. Types of joins
include INNER JOIN (matching records), LEFT JOIN (all from left table), RIGHT JOIN (all
from right table), and FULL JOIN (all records from both tables).

87. What is the difference between WHERE and HAVING clauses?

WHERE filters rows before grouping, while HAVING filters groups after aggregation.
WHERE cannot be used with aggregate functions, whereas HAVING is typically used with
GROUP BY to restrict results based on aggregated values.

Skillio, Pune +91-9130502135 | +91-8484831616


Skillio, Pune’s Best IT Training and Placement Institute

88. What is an index in SQL?

An index improves query performance by allowing faster data retrieval from a table. It
creates a data structure similar to a lookup table. However, indexes slow down write
operations because they must be updated whenever data changes.

89. What is a view in SQL?

A view is a virtual table created from the result of a SELECT query. It simplifies complex
queries, enhances security by restricting data access, and allows reusability of SQL logic
without storing additional data.

90. What is a subquery?

A subquery is a query nested within another query. It is used to perform operations like
filtering or comparison based on data retrieved from another table. Subqueries can be
correlated or non-correlated depending on dependency on the outer query.

91. What is the difference between DELETE, TRUNCATE, and DROP?

DELETE removes specific rows based on a condition and can be rolled back. TRUNCATE
removes all rows but keeps the table structure intact. DROP deletes the table entirely,
including structure and data, and cannot be rolled back.

92. What is a unique key?

A unique key ensures that all values in a column or combination of columns are distinct.
Unlike primary keys, a table can have multiple unique keys, and they allow one NULL value.

93. What are constraints in SQL?

Constraints are rules applied to table columns to enforce data integrity. Common
constraints include NOT NULL, UNIQUE, PRIMARY KEY, FOREIGN KEY, CHECK (condition-
based), and DEFAULT (auto-assign value).

94. What are aggregate functions in SQL?

Aggregate functions perform calculations on multiple rows and return a single result.
Common functions include COUNT(), SUM(), AVG(), MAX(), and MIN(). They are often used
with GROUP BY for data analysis.

95. What is the difference between IN and EXISTS?

IN compares a column’s value to a list or subquery result, while EXISTS checks if a subquery
returns any rows. EXISTS is generally faster when subquery results are large because it
stops processing after finding the first match.

96. What is a self join?

Skillio, Pune +91-9130502135 | +91-8484831616


Skillio, Pune’s Best IT Training and Placement Institute

A self join is a regular join where a table is joined with itself. It is used when data in the
same table must be compared, such as finding hierarchical relationships or duplicate
entries.

97. What is a stored procedure?

A stored procedure is a precompiled set of SQL statements stored in the database. It


improves performance, reusability, and security by encapsulating logic that can be executed
with a single call.

98. What is a trigger in SQL?

A trigger is a special stored procedure that executes automatically in response to specific


database events like INSERT, UPDATE, or DELETE. It helps enforce business rules and
maintain audit logs.

99. What is a transaction in SQL?

A transaction is a sequence of operations performed as a single logical unit of work. It


ensures data integrity through ACID properties: Atomicity, Consistency, Isolation, and
Durability. COMMIT saves changes, while ROLLBACK undoes them.

100. What is the difference between UNION and UNION ALL?

UNION combines the results of two or more queries and removes duplicates, while UNION
ALL includes duplicates as well. UNION is slower because it performs a distinct operation on
results before combining them.

Skillio, Pune +91-9130502135 | +91-8484831616

You might also like