Ques - With Ansy
Ques - With Ansy
OOP allows objects to interact with each other using four basic
principles: encapsulation, inheritance, polymorphism, and abstraction. These
four OOP principles enable objects to communicate and collaborate to create
powerful applications.
What are the 4 pillars of OOP? The four pillars of OOPS (object-oriented
programming) are Inheritance, Polymorphism, Encapsulation and Data
Abstraction.
An interface can only declare methods and properties but cannot implement
them, and it cannot hold state
Java Syntax is a basic of the language, all the main rules, commands,
constructions to write programs that the compiler and computer
“understands”. Every programming language has its syntax as well as human
language.
Data types refer to the different sizes and values that can be stored in the
variable. Two types of data type are in Java programming: (A) Primitive data
types: The primitive data types consist of int, float, boolean, byte, short, long,
char and double
What are access modifiers in Java and how do they affect visibility?
Access modifiers in Java allow you to encapsulate your code and define clear
visibility for classes and members. The private, default, protected and public
modifiers control access from other classes
Java provides two different options to handle an exception. You can either use
the try-catch-finally approach to handle all kinds of exceptions. Or you can
use the try-with-resource approach which allows an easier cleanup process for
resources.
The try block is used to specify a block of code that may throw an exception.
The catch block is used to handle the exception if it is thrown. The finally
block is used to execute the code after the try and catch blocks have been
executed.
Implementations of the singleton pattern ensure that only one instance of the
singleton class ever exists and typically provide global access to that instance.
Typically, this is accomplished by: Declaring all constructors of the class to be
private, which prevents it from being instantiated by other objects
What is the Factory pattern? When would you use it?
A data structure is a generic term for an object that represents some sort of
data, so a linked list, array, etc are all data structures. A collection in the Java
sense refers to any class that implements the Collection interface. A collection
G1 Garbage Collector.
Z Garbage Collector.
The volatile keyword in Java is used to indicate that a variable's value can be
modified by different threads. Used with the syntax, volatile dataType
variableName = x; It ensures that changes made to a volatile variable by one
thread are immediately visible to other threads.
Describe unit testing in Java. What frameworks can be used for unit testing?
JUnit is a widely adopted testing framework for running Java unit tests. It
provides annotations for test methods, supports assertions for result
verification, and offers various runners for executing tests. JUnit is well-
integrated with popular IDEs and build tools, making it a standard choice for
developers
=======================================================
Advanced Topics:
What are lambdas and streams? How do you use them in Java?
Default methods allow you to add new methods to interfaces without breaking
existing implementations. They provide a way to extend interfaces without
forcing implementing classes to provide an implementation for the new
methods.
How does the java.time package improve date and time handling in Java 8?
The java.time package introduces a new date and time API that addresses the
shortcomings of the old java.util.Date and java.util.Calendar classes. It
provides immutable date and time classes, support for time zones, and a fluent
interface for manipulation.
The Optional class is intended to represent a value that may or may not be
present. It helps avoid null pointer exceptions by providing a way to handle
cases where a value might be absent.
==========================================================
Spring quesions
3. Add dependencies
Dependency Detection:
Classpath Scanning:
Conditional Configuration:
Overrides:
Simplified Setup:
How does Spring Boot simplify the development of RESTful web services?
In Spring Boot, you can handle database operations using Spring Data JPA,
which is a part of the larger Spring Data project. Spring Data JPA simplifies
the implementation of data access layer by providing a high-level abstraction
over the underlying persistence mechanism (such as relational databases).
What is dependency injection, and how does Spring Boot support it?
Spring Boot allows developers to easily build applications or services using the
3 most mature containers available: Tomcat, Undertow, and Jetty
Explain the concept of Spring Boot Actuator endpoints and their significance
in monitoring and managing applications.
Performance Optimization