easy to develop stand-alone production grade spring based application that you can just run.
FEATURES OF SPRINGBOOT
1.create standalone applications
2.embeded tomcat & jetty servers
3.provide opionated starter dependencies to simplify your build configuration
4.automatically configure spring & 3rd party libraries whenever possible (LAMBOC)
5.provide production ready features such as metrics , healthchecks & externalised configuration
6.no XML file needed only annotations
7.having default database h2db
Q22.) Difference b/w spring & springboot
A22.)
S.No.
Spring
Spring Boot
1.
Spring is an open-source lightweight framework widely used to develop enterprise applications.
Spring Boot is built on top of the conventional spring framework, widely used to develop REST APIs.
2.
The most important feature of the Spring Framework is dependency injection.
The most important feature of the Spring Boot is Autoconfiguration.
3.
It helps to create a loosely coupled application.
It helps to create a stand-alone application.
4.
To run the Spring application, we need to set the server explicitly.
Spring Boot provides embedded servers such as Tomcat and Jetty etc.
5.
To run the Spring application, a deployment descriptor is required.
There is no requirement for a deployment descriptor.
6.
To create a Spring application, the developers write lots of code.
It reduces the lines of code.
7.
It doesnβt provide support for the in-memory database.
It provides support for the in-memory database such as H2.
Q23.) @SpringBootApplication β
** the entry point of the spring boot application is the class contains @SpringBootApplication annotation & the main method
** it automatically scans all components included in the project by using @ComponentScan annotation
Indicates a configuration of class that declares one or more @Bean method & also triggers auto-configuration & component scanning
** this is convenience annotation this is equivalent to declare @Configuration + @EnableAutoConfiguration + @componentScan .
@RequestMapping(β/β) β
It is used with class & method level in controller class & which indicates webapp http request or we can cast web-mapping of web request
@RequestBody β
In controller & in rest controller and in rest controller to write data to in the webpage body of the response in the form of String or in form of JSON object
FEATURES OF SPRINGBOOT
1.create standalone applications
2.embeded tomcat & jetty servers
3.provide opionated starter dependencies to simplify your build configuration
4.automatically configure spring & 3rd party libraries whenever possible (LAMBOC)
5.provide production ready features such as metrics , healthchecks & externalised configuration
6.no XML file needed only annotations
7.having default database h2db
Q22.) Difference b/w spring & springboot
A22.)
S.No.
Spring
Spring Boot
1.
Spring is an open-source lightweight framework widely used to develop enterprise applications.
Spring Boot is built on top of the conventional spring framework, widely used to develop REST APIs.
2.
The most important feature of the Spring Framework is dependency injection.
The most important feature of the Spring Boot is Autoconfiguration.
3.
It helps to create a loosely coupled application.
It helps to create a stand-alone application.
4.
To run the Spring application, we need to set the server explicitly.
Spring Boot provides embedded servers such as Tomcat and Jetty etc.
5.
To run the Spring application, a deployment descriptor is required.
There is no requirement for a deployment descriptor.
6.
To create a Spring application, the developers write lots of code.
It reduces the lines of code.
7.
It doesnβt provide support for the in-memory database.
It provides support for the in-memory database such as H2.
Q23.) @SpringBootApplication β
** the entry point of the spring boot application is the class contains @SpringBootApplication annotation & the main method
** it automatically scans all components included in the project by using @ComponentScan annotation
Indicates a configuration of class that declares one or more @Bean method & also triggers auto-configuration & component scanning
** this is convenience annotation this is equivalent to declare @Configuration + @EnableAutoConfiguration + @componentScan .
@RequestMapping(β/β) β
It is used with class & method level in controller class & which indicates webapp http request or we can cast web-mapping of web request
@RequestBody β
In controller & in rest controller and in rest controller to write data to in the webpage body of the response in the form of String or in form of JSON object
π1
Q1.) principles of oops:-
1. Abstraction: Abstraction in Java is a process of hiding the implementation details and showing only functionality to the user.
2. Encapsulation: Encapsulation in Java is a process of wrapping code and data together into a single unit.
3. Inheritance: Inheritance in Java is a mechanism in which one object acquires all the properties and behaviors of a parent object.
4. Polymorphism: Polymorphism in Java is a concept by which we can perform a single action in different ways.
5. Class: A class in Java is a blueprint which includes all your data. A class can contain fields and methods to describe the behavior of an object.
6. Object: An object in Java is the physical as well as a logical entity, with some state and behavior.
7. Method: A method in Java is a collection of statements that are grouped together to perform an operation.
Q2.) what is abstraction :-
Abstraction in Java is the process of hiding or ignoring the implementation details and showing only the functionality. It helps to reduce the complexity and also improves the maintainability of the application. Abstraction can be achieved by using abstract classes and interfaces. An abstract class is a class that contains one or more abstract methods, which are methods without a body. An interface is a collection of abstract methods.
Q3.) what is encapsulation :-
Encapsulation in Java is the process of wrapping code and data together into a single unit. It is a mechanism of hiding of data implementation by restricting access to public methods. It prevents the data from being modified by accident and is a way to achieve data abstraction. Encapsulation helps developers to follow a modular approach for software development and to keep the internal representation of an object hidden from the outside world.
Q4.) what is class :-
In Java, a class is a blueprint or prototype from which objects are created. A class encapsulates data fields and methods, representing the properties and behavior of the objects. It is the basic building block of object-oriented programming.
Q5.) what is object:-
Object in Java is a basic concept of object-oriented programming, which refers to the physical or logical representation of a real-world entity. It is an instance of a class, and can contain attributes and methods that can be used to manipulate its state. An object is created when the class is instantiated.
Q6.) diff b/w this & super &super()
This keyword refers to the current object, or the object whose method or constructor is being called.
super keyword refers to the immediate parent class object.
super() is a constructor used to call the parent class constructor.
Q7.) method vs constructors :-
A method is a section of code within a class which performs a specific task, while a constructor is a special type of method used to create an instance of a class.
Methods are used to perform operations on objects, while constructors are used to create objects. A constructor is called when an object of a class is created, and it is used to initialize the object's state. Methods are called by the user to perform some action on the object, such as calculating a sum or printing out the object's state.
Q8.) inheritance :-
Inheritance in Java is the process by which one class (the subclass) can inherit the properties and methods of another class (the superclass). The subclass can add its own unique properties and methods, but it can also use the properties and methods from the superclass. This allows for code reuse and decreased complexity in the program.
Q9.) polymorphism :-
Polymorphism in Java is the ability of an object to take on many forms. The most common use of polymorphism in Java is when a parent class reference is used to refer to a child class object. Any Java object that can pass more than one IS-A test is considered to be polymorphic.
In Java, all Java objects are polymorphic since any object will pass the IS-A test for their own type and for the
1. Abstraction: Abstraction in Java is a process of hiding the implementation details and showing only functionality to the user.
2. Encapsulation: Encapsulation in Java is a process of wrapping code and data together into a single unit.
3. Inheritance: Inheritance in Java is a mechanism in which one object acquires all the properties and behaviors of a parent object.
4. Polymorphism: Polymorphism in Java is a concept by which we can perform a single action in different ways.
5. Class: A class in Java is a blueprint which includes all your data. A class can contain fields and methods to describe the behavior of an object.
6. Object: An object in Java is the physical as well as a logical entity, with some state and behavior.
7. Method: A method in Java is a collection of statements that are grouped together to perform an operation.
Q2.) what is abstraction :-
Abstraction in Java is the process of hiding or ignoring the implementation details and showing only the functionality. It helps to reduce the complexity and also improves the maintainability of the application. Abstraction can be achieved by using abstract classes and interfaces. An abstract class is a class that contains one or more abstract methods, which are methods without a body. An interface is a collection of abstract methods.
Q3.) what is encapsulation :-
Encapsulation in Java is the process of wrapping code and data together into a single unit. It is a mechanism of hiding of data implementation by restricting access to public methods. It prevents the data from being modified by accident and is a way to achieve data abstraction. Encapsulation helps developers to follow a modular approach for software development and to keep the internal representation of an object hidden from the outside world.
Q4.) what is class :-
In Java, a class is a blueprint or prototype from which objects are created. A class encapsulates data fields and methods, representing the properties and behavior of the objects. It is the basic building block of object-oriented programming.
Q5.) what is object:-
Object in Java is a basic concept of object-oriented programming, which refers to the physical or logical representation of a real-world entity. It is an instance of a class, and can contain attributes and methods that can be used to manipulate its state. An object is created when the class is instantiated.
Q6.) diff b/w this & super &super()
This keyword refers to the current object, or the object whose method or constructor is being called.
super keyword refers to the immediate parent class object.
super() is a constructor used to call the parent class constructor.
Q7.) method vs constructors :-
A method is a section of code within a class which performs a specific task, while a constructor is a special type of method used to create an instance of a class.
Methods are used to perform operations on objects, while constructors are used to create objects. A constructor is called when an object of a class is created, and it is used to initialize the object's state. Methods are called by the user to perform some action on the object, such as calculating a sum or printing out the object's state.
Q8.) inheritance :-
Inheritance in Java is the process by which one class (the subclass) can inherit the properties and methods of another class (the superclass). The subclass can add its own unique properties and methods, but it can also use the properties and methods from the superclass. This allows for code reuse and decreased complexity in the program.
Q9.) polymorphism :-
Polymorphism in Java is the ability of an object to take on many forms. The most common use of polymorphism in Java is when a parent class reference is used to refer to a child class object. Any Java object that can pass more than one IS-A test is considered to be polymorphic.
In Java, all Java objects are polymorphic since any object will pass the IS-A test for their own type and for the
olymorphism in which the response to a function is determined at the compile time. It is also known as compile time polymorphism. In static polymorphism, the response to a function is determined by the JVM based on the object's type. The process of static polymorphism is also known as early binding or overloading.
Dynamic Polymorphism: Dynamic polymorphism is a type of polymorphism in which the response to a function is determined at the runtime. It is also known as runtime polymorphism. In dynamic polymorphism, the response to a function is determined by the JVM based on the actual object passed at the runtime. The process of dynamic polymorphism is also known as late binding or overriding.
Q16.) string vs string builder vs string buffer in java
String:
A String is an immutable object in java. It means once the object is created its content cannot be changed. The object is stored in the String pool. Whenever a new object is created with the same value as an existing object, the reference of the existing object is returned instead of creating a new object.
StringBuilder:
A StringBuilder is a mutable object in java. It means the content of the object can be changed. It is not stored in the String pool. A new object is created each time.
StringBuffer:
StringBuffer is also a mutable object in java. It is similar to StringBuilder but the only difference is that the StringBuffer is thread-safe. It means it is synchronized and can be used in multi-threaded environment. It is slower than StringBuilder.
Q17.) what is collection
Collection in Java is a framework that provides an architecture to store and manipulate the group of objects. Java Collection framework provides many interfaces (List, Set, Queue, Deque etc) and classes (ArrayList, Vector, LinkedList, PriorityQueue, HashSet, LinkedHashSet, TreeSet etc).
Q18.) exceptional handling :-
Exception handling in Java is the process of responding to the occurrence, during the execution of a program, of exceptions β anomalous or exceptional conditions requiring special processing β often disrupting the normal flow of program execution.
Java provides a powerful exception handling mechanism that allows the programmer to separate the normal flow of the program from the code that handles the exceptional conditions.
In Java, an exception is an object that represents an unusual or exceptional event that has occurred within a method. The exceptional event is usually something that the programmer did not anticipate, such as a division by zero or a file not found.
When an exceptional event occurs, an exception object is created and thrown. This object contains information about the exceptional event, such as its type, the state of the program when the event occurred, and other relevant data.
The programmer can then catch the exception object and use it to figure out what went wrong and how to fix it. In Java, this is done using the try/catch statement.
The try/catch statement consists of two parts: the try block and the catch block. The try block is the code that is executed and is followed by one or more catch blocks. Each catch block contains code that handles a different type of exception.
If an exception is thrown, the Java runtime system looks for the catch block that can handle the exception. If a matching catch block is found, the exception is passed to the catch block and the code inside the catch block is executed, otherwise the exception is propagated up the call stack, until a matching catch block is found or the program terminates.
Exception handling in Java is an important part of writing robust and reliable code. Proper exception handling can help you identify and fix errors quickly and efficiently.
Dynamic Polymorphism: Dynamic polymorphism is a type of polymorphism in which the response to a function is determined at the runtime. It is also known as runtime polymorphism. In dynamic polymorphism, the response to a function is determined by the JVM based on the actual object passed at the runtime. The process of dynamic polymorphism is also known as late binding or overriding.
Q16.) string vs string builder vs string buffer in java
String:
A String is an immutable object in java. It means once the object is created its content cannot be changed. The object is stored in the String pool. Whenever a new object is created with the same value as an existing object, the reference of the existing object is returned instead of creating a new object.
StringBuilder:
A StringBuilder is a mutable object in java. It means the content of the object can be changed. It is not stored in the String pool. A new object is created each time.
StringBuffer:
StringBuffer is also a mutable object in java. It is similar to StringBuilder but the only difference is that the StringBuffer is thread-safe. It means it is synchronized and can be used in multi-threaded environment. It is slower than StringBuilder.
Q17.) what is collection
Collection in Java is a framework that provides an architecture to store and manipulate the group of objects. Java Collection framework provides many interfaces (List, Set, Queue, Deque etc) and classes (ArrayList, Vector, LinkedList, PriorityQueue, HashSet, LinkedHashSet, TreeSet etc).
Q18.) exceptional handling :-
Exception handling in Java is the process of responding to the occurrence, during the execution of a program, of exceptions β anomalous or exceptional conditions requiring special processing β often disrupting the normal flow of program execution.
Java provides a powerful exception handling mechanism that allows the programmer to separate the normal flow of the program from the code that handles the exceptional conditions.
In Java, an exception is an object that represents an unusual or exceptional event that has occurred within a method. The exceptional event is usually something that the programmer did not anticipate, such as a division by zero or a file not found.
When an exceptional event occurs, an exception object is created and thrown. This object contains information about the exceptional event, such as its type, the state of the program when the event occurred, and other relevant data.
The programmer can then catch the exception object and use it to figure out what went wrong and how to fix it. In Java, this is done using the try/catch statement.
The try/catch statement consists of two parts: the try block and the catch block. The try block is the code that is executed and is followed by one or more catch blocks. Each catch block contains code that handles a different type of exception.
If an exception is thrown, the Java runtime system looks for the catch block that can handle the exception. If a matching catch block is found, the exception is passed to the catch block and the code inside the catch block is executed, otherwise the exception is propagated up the call stack, until a matching catch block is found or the program terminates.
Exception handling in Java is an important part of writing robust and reliable code. Proper exception handling can help you identify and fix errors quickly and efficiently.
CrudRepo
1.save(S entity);
entities);
3.findById(ID id);
4.existsById(ID id); 5.findAll();
6.findAllById(Iterable<ID> ids);
7.count();
8.deleteById(ID id); 9.delete(Entity)
10.deleteAll(Iterable<? extends T> entities);
11.deleteAll()
1.save(S entity);
entities);
3.findById(ID id);
4.existsById(ID id); 5.findAll();
6.findAllById(Iterable<ID> ids);
7.count();
8.deleteById(ID id); 9.delete(Entity)
10.deleteAll(Iterable<? extends T> entities);
11.deleteAll()
JpaRepository
->JpaRepository interface given Spring Data JPA Module. ->The Use of JpaRepository is To Perfrom CRUD operations and sorting and paginations operation with Any relational Data base.
IMPLEMENTED METHODS
1.findAll();
2.findAll(Sort sort); 4.saveAll(Iterable<S> entities);
3.findAllById(Iterable<ID> ids);
5.flush();
6.saveAndFlush(S entity);
7.deleteInBatch(Iterable<D entities):
8.deleteAllInBatch():
9.getOne(ID id); 10.findAll(Example<S> example);
11.findAll(Example<S> example, Sort sorty,
->JpaRepository interface given Spring Data JPA Module. ->The Use of JpaRepository is To Perfrom CRUD operations and sorting and paginations operation with Any relational Data base.
IMPLEMENTED METHODS
1.findAll();
2.findAll(Sort sort); 4.saveAll(Iterable<S> entities);
3.findAllById(Iterable<ID> ids);
5.flush();
6.saveAndFlush(S entity);
7.deleteInBatch(Iterable<D entities):
8.deleteAllInBatch():
9.getOne(ID id); 10.findAll(Example<S> example);
11.findAll(Example<S> example, Sort sorty,
π2