You are on page 1of 44

Infosys:

Java Streams, OOPS Concepts, Abstract Class, Interface, Internal workings of Collections

Core Java , hashmap & it's internal working,stream api, Microservices, Kafka, Spring Boot,
SQL bacis questions,

Interview Questions
 hashmap and internal working

Java 8 features
Primarily on Spring and REST APIs. Java 8 basic knowledge is required Core Java questions -
Collections framework, OOPS concepts. Spring and REST APIs Java 8 basic knowledge is
required
It was brief more technical mainly spring, spring boot, spring MVC, was a great experience,
also about Hibernate, SQL, front end technology like Angular

 Java concepts in depth

1 Answer

 Comparable vs Comparator interface

1 Answer

JAVA collection, Exception handling and basic REST APIs. Discussed about project
mentioned in resume.

Interview Questions
 Concurrent Exception in collection

Interview Questions
 difference between final, finally and finalize
1 Answer

 oops 4 main principals

Answer Question

 static and final

Answer Question

 reverse a string

Interview Questions
 Springboot, Spring, Java, Rest services

Multithreading, Springboot, continues integrations tools, project level questions

oops concept, role in project, difference between json and bson? How is mongodb different
from sql? What is synchronization and is it applied on classes? architecture of the project
Exception handling and questions related to string immutability?
Interview Questions
 Core Java Exceptions in details

Answer Question

 Best way to reverse string.

1 Answer

 what is trigger?

Answer Question

.design pattern
Interview Questions
 Basic oops concepts like Multithreading, exception handling, abstraction, polymorphism and
Collections concepts
Answer Question

 Output of Java programs related to basic oops concepts

Answer Question

 Spring Framework questions like IOC, Dependency Injection, MVC etc.

UBS:
First They conducted one Written test :
Write a program to find minimum element from unsorted array.
Count ways to reach the nth stair using step 1, or 2 or both
For ex :If we want to reach at 4th Step:
No of ways would be :
1+1+1+1
2+2
1+1+2
2+1+1

Java Program to Print sequence of numbers using threads


Data Strucutres
Core Java -Generics,Hash Map internal working,Collection API,Exception Handling
Rest API related question

How would you handle memory issues, Spring basic, database indexes, Unix commands,
questions on multithreading, concurrency etc
Interview Questions
 1. what are 4 pillars of OOPS 2. what is abstraction 3. sql query to find employee strength of
all the departments given two tables 1. department 2. employee

Questions were on core JAVA, project lifecycle, simple design problems.


nterview Questions
 basic Java questions, generics, Java 8 features

Answer Question

 project details, maven, find mid of a linked list

Answer Question

 implementation of LRU, how would you maintain version of API

Answer Question

fter 15 days got the call from UBS saying we will have 1 more technical round. The role was
for java developer and in the final round, they asked me all the things about the database.
And after that round there is no response.

Interview Questions
 in 1st technical, they asked about threading, java8, collections

Core java, design patterns.

MORGAN STANLEY:
Interview Questions
1) How ConcurrentHash Map works
2) Blocking queue implementation
3) write code for producer consumer problem
4) write code to print even odd in sequence using MultiThreading

Interview Questions
 What is reflective API , Multi threading concepts and questions

Interview Questions
 Difference between equals and hashcode method?

Interview Questions
Multithreading and Concurrency
Hashmap
Blocking queue
LinkedHashMap Implementation
Immutable class Implementation
Design notepad with search functionality

, they ask you about the internal working of collections like hashmaps and treemaps.
Multithreading is something you have to prepare a lot to get through all the tech rounds.

Interview Questions
 How does priority queues and TreeMap works internally?

The Recruiter asked the questions:

1. What is the garbage collector


2. Difference between Spring and Spring Boot
3. Transaction in Java

What is reflective API , Multi threading concepts and questions


Difference between equals and hash code method?

Mostly focused on resume and data structures, algorithm based coding

Interview Questions
 Algorithm and Data Structure questions

Why choose Morgan Stanley?

What is reflective API , Multi threading concepts and questions

The first round is one to one on phone call. The candidate start to introduce himself, then
the algo test on hackerrank. And they will ask some technical questions about the
programming language.
Interview Questions
 The question of leetcode

Interview Questions
 Multithreading and Concurrency Hashmap Blocking queue LinkedHashMap Implementation
Immutable class Implementation Design notepad with search functionality

Interview Questions

Q- How to find whether if a permutation of a string can be a palindrome ?

Q- Find sum of two number =K in an sorted and unsorted array?

Q-Hashmap internal working and where can you use identityHashMap

Q-Design a realtime dashboard where you would display top 10 players in a game.

Q-Design an algorithm to schedule a match within N teams where each match is elimination?How would
you handle if you have N%2=1(where N is odd)? On what basis you would sit out a team and play
another

Q-How would you send and receive XML as Req and Res in REST

Q-How would you inject a prototype bean into Singleton bean

Q-What are the alternatives to Databases ? How can you compute 1 billion records in a distributed
system? How would you breakdown data and remerge the results across distributed systems.

Q- Find the longest prefix of words in a string of array

Q- MQ vs Rest Services - Which is best in what scenario?

Q- In what scenario thread becomes heavy weight ?

they ask you about the internal working of collections like hashmaps and treemaps.
Multithreading is something you have to prepare a lot to get through all the tech rounds.

Interview Questions
 How does priority queues and TreeMap works internally?

Java Collections and Multi threading

Interview Questions
 Basic questions on Java collections, multithreading, design patterns

Interview Questions
 HashMap, Concurrency, SQL, Exceptions, Iterators.
Interview Questions
 REST API protocol The difference between PUT and POST

Interview Questions
 Implementation of Linked list

Below questions were asked 1- How the Spring works internally? 2- Map works internally? 3
What approach is followed if two same object stored in map with same value. 4- What is
singleton ? When you will use singleton? 5- Advantages of OOps with real time example.

Interview Questions
 Phone Screen: Check if two elements in an array equal to a sum or not?

1 Answer

 Onsite #1: Fibonacci, recursively and iteratively, Tradeoff and complexities for both solution

1 Answer

 Onsite #2: Return max difference between two elements in an array

1 Answer

 Onsite #3 Sqrt of a number within a range of tolerance

1 Answer

 Onsite #4 Generate all anagrams of a string

1 Answer

 Onsite #5 System Design question to process multiple feeds and an API to serve various
queries

Answer Question

 Onsite#6 Return all characters from a string which appeared more than once

1 Answer

 Onsite #7 Remove duplicates from a sorted array with O(1) space

nterview Questions
 I have an array of million integers. I want to sum it efficiently. How would you do it without
using Java 8 parallel streams?

3 Answers

 I have a collection of string that is sorted and unique. You will receive an input as string.
Your job is to search that string in that group and return true or false based on its presence. How will
you solve this?

1 Answer

 I have an online radio player application. There are two types of subscription free and paid.
In free there is a restriction that user can only listen upto 50 songs in 1 hour. How will you code this?

Answer Question

 How does HashMap works? What is the time complexity of the get method in HashMap?

Glassdoor:

What is OOP? Describe java access modifiers


What are Access Modifiers?
In Java, access modifiers are used to set the accessibility (visibility) of
classes, interfaces, variables, methods, constructors, data members, and the
setter methods. For example

Modifier Description

Default declarations are visible only within the package (package private)

Private declarations are visible within the class only

Protected declarations are visible within the package or all subclasses

Public declarations are visible everywhere

Object Oriented Programming system (OOPS) is designed based on the concept of “Object”.

“Object” contains both variables (used for holding the data) and methods(used for defining the
behaviors)

OOPS concept brings this data and behavior in a single place called “class” and we can create


any number of objects to represent different state for each object.

OOPS Concepts are very important mainly because without having idea of OOPS concepts, we will
not be able to design systems in object oriented programming model.
Abstraction
Abstraction is the concept of hiding the internal details of a functionality and providing a simple
representation for the same.

So complex functionality can be made available to the outside world in a simple way.

Example:
We use mobile phone everyday but we don’t know how the functionalities are designed inside it
so that we receive the calls and send messages etc.

These functionalities have been kept inside and we are just accessing them using the options
provided in the mobile.

Similarly, we drive a car and change the gears as and when its required to go high speed and come
back to low speed but We don’t know how the gear box works internally.

So, gearbox working is abstracted and provided with simple mechanism of changing gears to the
outside world.

Similary, we apply brakes whenever we want to stop the car but we are not sure how the braking
system works internally.
Similarly, in java we can write a method to perform some functionality inside a class and we
can expose it to outside world just by providing an option to call this method.

So, anyone who calls this method will not be knowing the internal complexity of the method but
will be knowing the functionality of the method and hence he calls it and uses it.

So, this way, we hide the internal implementation and abstract it inside a method.

We can achieve “ abstraction ” in Java using 2 ways

1. Abstract class

2. Interface

1. Abstract Class
Abstract class in Java can be created using “ abstract ” keyword.

If we make any class as abstract then it can't be instantiated which means we are not able to create the
object of abstract class.

Inside Abstract class, we can declare abstract methods as well as concrete methods

So using abstract class, we can achieve 0 to 100 % abstraction.

Example:

1. Abstract class Phone{
2. Abstract void receiveCall();
3. Abstract void sendMessage();
4. }

Now any concrete class which extends the above abstract class will provide the definition of


these abstract methods.

This definition is the actual internal details of how this functionality has been implemented.

Anyone who needs to access this functionality has to call the method using the Phone
object pointing to its subclass.

Check Abstract Class in Java article for more details on Abstract class and methods
2. Interface
Interface is used to achieve pure or complete abstraction.

We will have all the methods declared inside Interface as abstract only.

So, we call interface as 100% abstraction.

Example:
We can define interface for Car functionality abstraction as below

1. Interface Car{
2. public void changeGear( int gearNumber);
3. public void applyBrakes();
4. }

Now these functionalities like changing a gear and applying brake are abstracted using


this interface.

Actual implementation will be provided by the sub-classes which implements the above


the interface.

1. Class Lamborghini implements car {
2. public void changeGear( int gearNumber){
3. //Actual logic to change the gear
4. System.out.println("Gear changed in Lamborghini car to "+gearNumber);
5.  
6. }
7.  
8. public void applyBrakes(){
9. //Actual logic to apply the brake
10. System.out.println("Break applied in Lamborghini car ");
11.  
12. }
13. }

Similarly , we can implement this interface for Audi car

1. Class Audi implements car {
2. public void changeGear( int gearNumber){
3. //Actual logic to change the gear
4. System.out.println("Gear changed in Audi car to "+gearNumber);
5.  
6. }
7.  
8. public void applyBrakes(){
9. //Actual logic to apply the brake
10. System.out.println("Break applied in Audi car ");
11.  
12. }
13. }

So, we can see that, internal working of gear box and the brake system is implemented in the
subclass and its abstracted using the interface.

Anyone who would like to use this functionality can call the appropriate method using interface
variable pointing to the required implementation as below

1. Car c = new Audi();
2. c. changeGear(2);
3. c. applyBrakes();

Since variable “c” is pointing to Audi class object , we can see below output

Output :

Gear changed in Audi car to 2


Break applied in Audi car

Check Interfaces in java article for more details

Encapsulation
Encapsulation is the process of binding object state(fields) and behaviors(methods) together in a single
entity called “Class”.

Since encapsulation wraps both fields/variables and methods in a class, it will be secured from


the outside access.

We can restrict the access to the members of a class using access modifiers such


as private,protected and public keywords

When we create a class in Java, It means we are doing encapsulation.

Encapsulation helps us to achieve the re-usability of code without compromising the security.

Inheritance
One class inherits or acquires the properties of another class.

The class from which the properties are inherited is called Super class or Parent class

The class which inherit the properties is called Subclass or Child class.


We use “ extends ” keyword to achieve the same.

The whole idea behind inheritance is “ Re-usability ”.

We can create more specific classes by inheriting fields and methods from the Generic class.

And we can add additional fields and methods in the Subclass.

Polymorphism
Polymorphism is the concept where an object behaves differently in different situations

Since the object takes multiple forms, it is called Polymorphism.

In java, we can achieve polymorphism using method overloading and method overriding

There are 2 types of Polymorphism available in Java

Method overloading
In this case, which method to call will be decided at the compile time itself based on number or type of
the parameters

Static/Compile Time polymorphism is an example for method overloading.

Method overriding
In this case, which method to call will be decided at the run time time based on what object is actually
pointed by the reference variable.

Run Time Polymorphism is an example for method overriding


https://www.geeksforgeeks.org/reflection-in-java/

Reflection can be used to get information about –


1. Class The getClass() method is used to get the name of the class to
which an object belongs.
2. Constructors The getConstructors() method is used to get the public
constructors of the class to which an object belongs.
3. Methods The getMethods() method is used to get the public methods of
the class to which an objects belongs.
// A simple Java program to demonstrate the use of reflection

import java.lang.reflect.Method;

import java.lang.reflect.Field;

import java.lang.reflect.Constructor;

// class whose object is to be created

class Test

{
// creating a private field

private String s;

// creating a public constructor

public Test() { s = "GeeksforGeeks"; }

// Creating a public method with no arguments

public void method1() {

System.out.println("The string is " + s);

// Creating a public method with int as argument

public void method2(int n) {

System.out.println("The number is " + n);

// creating a private method

private void method3() {

System.out.println("Private method invoked");


}

class Demo

public static void main(String args[]) throws Exception

// Creating object whose property is to be checked

Test obj = new Test();

// Creating class object from the object using

// getclass method

Class cls = obj.getClass();

System.out.println("The name of class is " +

cls.getName());

// Getting the constructor of the class through the

// object of the class

Constructor constructor = cls.getConstructor();


System.out.println("The name of constructor is " +

constructor.getName());

System.out.println("The public methods of class are : ");

// Getting methods of the class through the object

// of the class by using getMethods

Method[] methods = cls.getMethods();

// Printing method names

for (Method method:methods)

System.out.println(method.getName());

// creates object of desired method by providing the

// method name and parameter class as arguments to

// the getDeclaredMethod

Method methodcall1 = cls.getDeclaredMethod("method2",

int.class);
// invokes the method at runtime

methodcall1.invoke(obj, 19);

// creates object of the desired field by providing

// the name of field as argument to the

// getDeclaredField method

Field field = cls.getDeclaredField("s");

// allows the object to access the field irrespective

// of the access specifier used with the field

field.setAccessible(true);

// takes object and the new value to be assigned

// to the field as arguments

field.set(obj, "JAVA");

// Creates object of desired method by providing the

// method name as argument to the getDeclaredMethod


Method methodcall2 = cls.getDeclaredMethod("method1");

// invokes the method at runtime

methodcall2.invoke(obj);

// Creates object of the desired method by providing

// the name of method as argument to the

// getDeclaredMethod method

Method methodcall3 = cls.getDeclaredMethod("method3");

// allows the object to access the method irrespective

// of the access specifier used with the method

methodcall3.setAccessible(true);

// invokes the method at runtime

methodcall3.invoke(obj);

}
Output :
The name of class is Test
The name of constructor is Test
The public methods of class are :
method2
method1
wait
wait
wait
equals
toString
hashCode
getClass
notify
notifyAll
The number is 19
The string is JAVA
Private method invoked

2. PUT vs POST Dilemma


In a typical REST architecture, a client sends requests in the form of HTTP methods
to the server to create, retrieve, modify, or destroy resources. While both PUT and
POST can be used to create resources, there are significant differences between them
in terms of their intended applications.
According to the RFC 2616 standard, the POST method should be used to request the
server to accept the enclosed entity as a subordinate of the existing resource identified
by the Request-URI. This means the POST method call will create a child
resource under a collection of resources.
On the other hand, the PUT method should be used to request the server to store the
enclosed entity under the provided Request-URI. If the Request-URI points to an
existing resource on the server, the supplied entity will be considered a modified
version of the existing resource. Therefore, the PUT method call will either create a
new resource or update an existing one.
Another important difference between the methods is that PUT is an idempotent
method while POST is not. For instance, calling the PUT method multiple times will
either create or update the same resource. On the contrary, multiple POST requests
will lead to the creation of the same resource multiple times.

PUT POST

POST method is used to


request that the origin server
accept the entity enclosed in
the 
PUT request is made to a particular resource. If request as a new
the Request-URI refers to an already existing subordinate of the resource
resource, an update operation will happen, identified by the Request-
otherwise create operation should happen if URI in the Request-Line. It
Request-URI is a valid resource URI (assuming essentially means that
client is allowed to determine resource POST request-URI should
identifier).  be of a collection URI. 
Example –  Example – 
   
PUT /article/{article-id} POST /articles
   

POST is NOT idempotent.


So if you retry the request N
PUT method is idempotent. So if you send retry times, you will end up having
a request multiple times, that should be N resources with N different
equivalent to single request modification. URIs created on server.

Use PUT when you want to modify a single


resource which is already a part of resources
collection. PUT overwrites the resource in its
entirety. Use PATCH if request updates part of Use POST when you want
the resource.  to add a child resource
  under resources collection.
PUT POST

Generally, in practice, always use PUT for Always use POST for
UPDATE operations. CREATE operations.

How to create immutable class?


1. The class must be final, so that no other classes can extend it.
2. All the data member(Variables) must be declared as final, so that, they can’t
change the value of it after object creation.
3. No setter method should be there.

4. Create getter method for each data member.

5. A parametrized constructor that will assign the value during creation of object.

6. If the class holds the reference of other class(mutable object):

The constructor should not assign real instances to mutable objects. It must
create a clone copy of the passed argument and then use the clone copy. Make
sure to always return a clone copy of the field and never return the real object
instance.

Immutable class in java example


Let’s create an immutable class with the final keyword and final data
members. Here we are creating an ImmutableStudent class, which is an
immutable class.
final class ImmutableStudent
{
private final int id;
private final String name;
public ImmutableStudent(int id, String name)
{
this.name = name;
this.id = id;
}
public int getId()
{
return id;
}
public String getName()
{
return name;
}
}

The above class is immutable because:

o The instance variable of the class is final i.e. we cannot change the value of it after
creating an object.
o The class is final so we cannot create the subclass.
o There is no setter methods i.e. we have no option to change the value of the
instance variable.

HashMap stores the data in Key-Value pair and it uses node to store the key-
value. It uses the Node class that is a static inner class to represent the
pair(Key-Value) as a node.  The HashMap contains an array and LinkedList
data structure internally for storing Key and Value. Let’s see the object of the
structure of HashMap or Internal working of HashMap in JDK:

final int hash;

final K key;

V value;

Node<K,V> next;

In HashMap, each node has some specific data that


is hashCode, key, value, and address of the next node.
The internal implementation of HashMap depends upon the hash code of the
object.  It performs each operation based on hashCode() method and equals()
method. If you are not familiar with the hashcode() method and equals()
method, then please read it from here.
The HashMap uses the Hashing technique to store and retrieve the data.
Hashing is a technique that is used to get the unique integer value.

Interview questions on 12TH JULY 2021:


Autoboxing and un autoboxing
Why string is mutable?
OPTIONAL (java 8)
Pick() method..
callable and runnable difference

SDLC:

So, If we need to make a software, then you need to follow some steps and that’s what SDLC.

It involves steps like, Requirement gathering, Analysis, Design, Implementation, Integration & Testing,
Delivery and maintenance.
𝐒𝐃𝐋𝐂 𝐢𝐬 𝐚 𝐟𝐫𝐚𝐦𝐞𝐰𝐨𝐫𝐤 𝐝𝐞𝐟𝐢𝐧𝐢𝐧𝐠 𝐭𝐚𝐬𝐤𝐬 𝐩𝐞𝐫𝐟𝐨𝐫𝐦𝐞𝐝 𝐚𝐭 𝐞𝐚𝐜𝐡 𝐬𝐭𝐞𝐩 𝐢𝐧 𝐭𝐡𝐞 𝐬𝐨𝐟𝐭𝐰𝐚𝐫𝐞 𝐝𝐞𝐯𝐞𝐥𝐨𝐩𝐦𝐞𝐧𝐭
𝐩𝐫𝐨𝐜𝐞𝐬𝐬. 𝐇𝐞𝐫𝐞'𝐬 𝐩𝐫𝐨𝐜𝐞𝐬𝐬 𝐢𝐧 𝐝𝐞𝐭𝐚𝐢𝐥.

REQUIREMENT GATHERING:

In this phase, business analyst meets with the stakeholders and tries to figure out what the requirement
exactly is. A requirement specification document is then created which serves as a guideline for the
development team to work on.

ANALYSIS:

In this phase, a detailed requirement are done to understand the following things:/

The analysis phase has be done on the based of the requirement document about the following things:

- Are the requirements possible to fulfill?


- Time requirement and time planning for the project
- Technologies required to complete the project within the given parameters
- Software , Hardware and human resource required

DESIGN:

In this Phase, the whole project is divided into modules and submodules using UML (Unified Modelling
Language) diagrams.
IMPLEMENTATION:

Programming/Coding is done in this phase. Developers develop the source code using the pseudo code
as a reference.

TESTING AND INTEGRATION:

In this phase, the test engineer reviews the requirement documents and prepares the certain test cases
for the software.

If there are any defects, the testing team then prepare a Defect Profile document, sends it back to the
development team, and waits for the next build.

Delivery:

Once the defects are removed, the software is then installed into the client environment with the help
of guidelines provided in the deployment document.

Maintenance:

In case there is an issue post-delivery, the task is then resolved according to the situation of the problem

Pseudocode: It is a methodology that allows the programmer to represent the


implementation of an algorithm. Simply, we can say that it’s the cooked up
representation of an algorithm.
_
1. HTTP OPTIONS Method
The HTTP OPTIONS method is used to describe the communication options
for the target resource. This method allows the client to determine the
options and/or requirements associated with a resource, or the capabilities of
a server, without implying a resource action or initiating a resource retrieval.

 If the Request-URI is an asterisk (“*”), the OPTIONS request is intended


to apply to the server in general rather than to a specific resource.
 If the Request-URI is not an asterisk, the OPTIONS request applies only
to the options that are available when communicating with that resource.
 Responses to this method are not cacheable.

2. Add Options handler methods to REST Controller


Next step is to add the handler method to handle OPTIONS request.

@RestController
@RequestMapping(value = "/employee-management", produces =
{ MediaType.APPLICATION_JSON_VALUE })
public class EmployeeRESTController
{
     @RequestMapping(value="/employees", method =
RequestMethod.OPTIONS)
     ResponseEntity<?> collectionOptions()
     {
          return ResponseEntity
                  .ok()
                  .allow(HttpMethod.GET, HttpMethod.POST,
HttpMethod.OPTIONS)
                  .build();
     }
      
     @RequestMapping(value="/employees/{id}", method =
RequestMethod.OPTIONS)
     ResponseEntity<?> singularOptions()
     {
          return ResponseEntity
                  .ok()
                  .allow(HttpMethod.GET, HttpMethod.DELETE,
HttpMethod.PUT, HttpMethod.OPTIONS)
                  .build();
     }
 
     //Other APIs
}

curl -i -X OPTIONS
http://localhost:8080/SpringRestExample/api/rest/employee-
management/employees/
 
Response:
 
#status#        HTTP/1.1 200 OK
Server          Apache-Coyote/1.1
Content-Length  0
Date            Thu, 02 May 2019 10:41:02 GMT
Allow           GET,POST,OPTION

curl -i -X OPTIONS
http://localhost:8080/SpringRestExample/api/rest/employee-
management/employees/1
 
Response:
 
#status#        HTTP/1.1 200 OK
Server          Apache-Coyote/1.1
Content-Length  0
Date            Thu, 02 May 2019 10:43:15 GMT
Allow           GET,DELETE,PUT,OPTIONS

http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html

OPTIONS method returns info about API (methods/content type)

HEAD method returns info about resource (version/length/type)

Server response

OPTIONS

HTTP/1.1 200 OK
Allow: GET,HEAD,POST,OPTIONS,TRACE
Content-Type: text/html; charset=UTF-8
Date: Wed, 08 May 2013 10:24:43 GMT
Content-Length: 0
HEAD
HTTP/1.1 200 OK
Accept-Ranges: bytes
Content-Type: text/html; charset=UTF-8
Date: Wed, 08 May 2013 10:12:29 GMT
ETag: "780602-4f6-4db31b2978ec0"
Last-Modified: Thu, 25 Apr 2013 16:13:23 GMT
Content-Length: 1270

OPTIONS tells you things such as "What methods are allowed for this resource".

HEAD gets the HTTP header you would get if you made a GET request, but without the
body. This lets the client determine caching information, what content-type would be
returned, what status code would be returned. The availability is only a small part of it.
The lifecycle of any object means when & how it is born, how it behaves
throughout its life, and when & how it dies. Similarly, the bean life cycle refers to
when & how the bean is instantiated, what action it performs until it lives, and
when & how it is destroyed. In this article, we will discuss the life cycle of the
bean.
Bean life cycle is managed by the spring container. When we run the program
then, first of all, the spring container gets started. After that, the container
creates the instance of a bean as per the request and then dependencies are
injected. And finally, the bean is destroyed when the spring container is closed.
Therefore, if we want to execute some code on the bean instantiation and just
after closing the spring container, then we can write that code inside the
custom init() method and the destroy() method. The following image shows the
process flow of the bean life cycle.
What is Distributed Caching? Explained
with Redis!
Design Patterns in Java
A design patterns are well-proved solution for solving the specific problem/task.

Now, a question will be arising in your mind what kind of specific problem? Let me explain by
taking an example.

Problem Given:
Suppose you want to create a class for which only a single instance (or object) should be created
and that single object can be used by all other classes.

Solution:
Singleton design pattern is the best solution of above specific problem. So, every design
pattern has some specification or set of rules for solving the problems. What are those
specifications, you will see later in the types of design patterns.

By using the design patterns you can make your code more flexible, reusable and
maintainable. It is the most important part because java internally follows design patterns.
Advantage of design pattern:
1. They are reusable in multiple projects.
2. They provide the solutions that help to define the system architecture.
3. They capture the software engineering experiences.
4. They provide transparency to the design of an application.
5. They are well-proved and testified solutions since they have been built upon the
knowledge and experience of expert software developers.
6. Design patterns don?t guarantee an absolute solution to a problem. They provide clarity
to the system architecture and the possibility of building a better system.

When should we use the design patterns?


We must use the design patterns during the analysis and requirement phase of
SDLC(Software Development Life Cycle).

Design patterns ease the analysis and requirement phase of SDLC by providing
information based on prior hands-on experiences.
Design pattern:
1) CRAETIONAL
2) STR
TCS:

Interview

Based on project then ask on core java Question.... Collection.... Hashmap .... implementation
of arraylist.... Difference between Hashmap and hashtable.... Microservices Question...Uses
of Microservices... How to deploy Microservices on server.... How Microservices
communicate with each other

Difference between interface and abstract class, scope of sprig bean, singleton, immutability,
multithreading, exception handling, polymorphism.

Java 8 API

Interview Questions
 Java basic questions, spring boot, rest api, security related questions

Basic technical questions and programming logic were asked. OOPS and Software
Engineering concepts were also asked. I got selected.

Interview Questions
 Program to Swap two numbers

You might also like