0% found this document useful (0 votes)
7 views82 pages

Product Java Questions-Part1

The document contains a comprehensive list of interview questions for a product company, covering topics such as Spring vs Spring Boot, coding challenges like finding the majority element and implementing binary search, and various Java and SQL concepts. It also includes questions on microservices, design patterns, and practical coding tasks. Additionally, it addresses advanced topics like RESTful web services, dependency injection, and functional programming.

Uploaded by

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

Product Java Questions-Part1

The document contains a comprehensive list of interview questions for a product company, covering topics such as Spring vs Spring Boot, coding challenges like finding the majority element and implementing binary search, and various Java and SQL concepts. It also includes questions on microservices, design patterns, and practical coding tasks. Additionally, it addresses advanced topics like RESTful web services, dependency injection, and functional programming.

Uploaded by

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

Interview Questions - Product Company

1. Spring vs Spring Boot


- Explain the difference between Spring and Spring Boot.
- What is the use of @Component and @Configuration annotations?

Coding Question:
Given an integer array nums, find the subarray with the largest sum, and return its sum.

Example:
Input: nums = [-2,1,-3,4,-1,2,1,-5,4]
Output: 6

Explanation:
The subarray [4,-1,2,1] has the largest sum 6.

2. Majority Element & Two Sum

Given an array nums of size n, return the majority element.

The majority element is the element that appears more than floor(n / 2) times.

Example 1:
Input: nums = [3,2,3]
Output: 3

Example 2:
Input: nums = [2,2,1,1,1,2,2]
Output: 2

Two Sum Problem:

Given an array of integers nums and an integer target, return indices of the two numbers
such that they add up to target.

Example 1:
Input: nums = [2,7,11,15], target = 9
Output: [0,1]

Example 2:
Input: nums = [3,2,4], target = 6
Output: [1,2]
Example 3:
Input: nums = [3,3], target = 6
Output: [0,1]

3. Java, SQL & Debugging Questions

- Explain polymorphism with code example using Animal, Dog, Cat etc.
- Write palindrome code.
- Find the index where target value can be inserted in a sorted array.

Example:
int nums[] = {1,5,7,12,15,20};
int target = 14;

Output: 4

- Binary Search implementation.


- Singleton Design Pattern with code.
- Find the second highest salary from Employee table.
- Difference between INNER JOIN and LEFT JOIN.
- How do you improve code quality in your project?
- How do you debug your code?

4. Java & SQL Questions

- Explain polymorphism with code example using Animal, Dog, Cat etc.

- Find the index where target value can be inserted in a sorted array.

Example:
int nums[] = {1,5,7,12,14,20};
int target = 14;

Output: 4

- Binary Search implementation.


- Difference between INNER JOIN and LEFT JOIN.

5. String, SQL & Spring Boot Questions


- Reverse a string array using O(1) space.
- Find the second highest distinct employee salary. If not found, return NULL.
- Difference between @Component and @Configuration in Spring Boot.

6. Daily Temperatures Problem

Given an array of integers temperatures representing daily temperatures, return an array


answer such that answer[i] is true if there is any warmer day after ith day.

Example 1:
Input: temperatures = [73,74,75,71,69,72,76,73]
Output: [true,true,true,true,true,true,false,false]

Example 2:
Input: temperatures = [30,40,50,60]
Output: [true,true,true,false]

Example 3:
Input: temperatures = [30,60,90]
Output: [true,true,false]

Interview Questions

Difference between spring vs spring boot?

What is inside starter package?

Explain the Maven lifecycle


How spring creates beans?

What is microservice?

What is different between SOA vs microservice?

Which cloud technology have you worked?

Azure related questions as I worked on azure

Design patterns

Explain SOLID with examples

What is docker?
What is
kubernetes?
Have you created

dockerfile?

have you configured

kubernetes?

Have you worked on

linux commands?

Difference between REST vs http?

What is CAP theorem?

previous project architecture

questions on java 8 stream API

Java 8 features
Why default method has been added in Java 8 ?

how to remove duplicate element from an array ?

reverse a string and remove white spaces

CI CD pipeline flow

Docker file

Main components of Kubernetes cluster

Design pattern used in Spring

Design Pattern used in your projects


Advantages and disadvantages of Microservices

How to deploy microservices?

What is API gateway

Why we use Reactive streams ?

Previous Project complete flow (front end to backend)

What is docker container?

What
is Streams in java?
Calculate the average of all the elements in below code snippet using streams:-

List<List<Integer>>
marksByStudents = [Link] (
[Link] (60, 70, 80),

[Link](50, 70, 85),

[Link](65, 70, 75)

);

write a program to reverse the linked list.

Singleton, Factory, Proxy Pattern, etc

Microservices advantages

Spring s ="energy" ->


print first non repeating character
Spring s ="energy";
String s1 = "enemy"; -> print uncommon characters

query to print 3rd largest salary

query to print no. of employees in each department.


design patterns used.

communication between microservices

spring profiles

How to read multiple properties files

Autowiring annotation

JPA annotations

@Query Annotation

RestTemplate methods.

Reading HTTP headers and cookies in spring

excluding auto configuration of some classes in

springboot
Exception Handling in Spring

Microservices advantages

2. Spring s ="energy" -> print first

non repeating character

3. Spring s ="energy"; -> print uncommon characters

String s1 = "enemy";

4. query to print 3rd largest salary


5. query to print no. of employees in each department.

6. design patterns used.

7. communication between microservices

8. spring profiles

9. How to read multiple properties files

10
Autowiring annotation

11. JPA annotations

12. @Query Annotation

13
RestTemplate methods.
14. Reading HTTP headers and cookies in spring

15. excluding auto configuration of some classes in

springboot

16. Exception Handling in Spring

Questions for Raju

Have you implemented Restful webservices in your previous projects? If so, how
did you implement?
What are microservices and any projects implemented so far?

How does Restful webservices communicate?

How is transaction management handled in spring?

What is Dependency Injection?

Constructor injection vs Setter Injection? Which is preferred and why?


List vs set differences?

How to transform a list of objects in java?

Java 8 features

How do you configure environment specific properties?

Reactor streams and

RestTemplate

Annotations in JPA

design patterns

How do you keep up with latest technologies?


How to create immutable classes

How do you handle JSON response in webservices

How to ignore certain values of JSON response

Relationships in Hibernate - How do you configure

one to one mapping - what happens if there is a bidirectional dependency


Project Architecture

Employee list given - filter employees with salary more than 30k

Check whether two strings are Anagram or not

Steps for creating Restful webservice

Equals &

Hashcode , what hashcode does and what is hash collision

Java 8 features and what features are used in your project


Exceptional Handling in spring

explain functional programming

use cases of API-Gateway Design pattern

oops concept and example

functional interface and example

loose coupling and example and implementation

thread safe
arraylist
concurrent
hashmap

collections in java

caching and its techniques (examples)

least frequency used cache

async vs sync transactions

system design question (appointment and

updation-whole technical flow and implementation)

Explain last project

Explain Design patterns by category


write the code to create a singleton class. Explain how object is created

Which line in singleton class code can give error if 2 requests access the same
code

write the code to create an immutable class in java, create other mutable

class and use its object in immutable class maintaining immutability


Implement linked list data structure in java . Write code to insert and display
elements in a linked list

How
hashmap works internally. How distinct key implementation is done

what is Docker

Write a code to create a rest

api and return a string with response status 200

Explain Spring MVC

Difference between synchronous and asynchronous calls

H2 database
JPA/Hibernate

create restful webservices & how restful

ws communicate
explain
jwt

how to fetch data from

appliction properties file

Java 8 features

Given a
studentList, add the student data in map with key as

StudentId, value Student data.

LinkedList- program to check if loop in

Linkedlist

SQL Joins

put vs patch mapping diff

Ehcache in hibernate
Composite primary key in hibernate

Serialization

Collections : LinkedList &

Arraylist difference

Cache - annotations

Builder design pattern

Explain project architecture

nosql & relational


db diff and why relational was being used in project

Challenges for Microservices

DB -
sql queries:

1. id, name, salary, email,

current_city --> employee table,

emp_id, designation --> designation

find no of
employees wit salary more than 20000

find no of employees in

each with salary more than 20000

find no of managers in each city

BY S N
PrasadRao

Challenges

print list item with index using streams

print unique character using streams

arr[1,2,3,4,5,6], target=4, required

output=[1,3]
Print the count of minimum duplicate number in array [1,2,2,2,3,3,4,4,4,4] output=
2

int a[] = {1,2,2,3,3,4,4,5};

Map<Integer,Integer> hm = new HashMap<Integer,Integer>();

for(Integer in:a) {

[Link](in,

[Link](in)?[Link](in)+1:1);

[Link](
[Link]().stream().sorted([Link]([Link]
alue())).filter(k->

[Link]()>1).findFirst().get().getKey());

functional interface in java 8

what is
hashset?
What is
final,Finally,Finilizer ?
how
ioc works internally?
status codes

annotations you worked in spring boot

how many microservices you created.


make an architecture of your microservice

write pseudo code to fine employee list by dept id

if you
have to create a microservice then which technology & DB will choose & why?

how to set traffic level?

Solid
princples.

How to create docker image

How you are implementing security in microservices.

Thread life cycle


wait & join difference

two diff array merge it in diff array and sort it with your logic

Interview Questions

Difference between spring vs spring boot?

What is inside starter package?

Explain the Maven lifecycle

How spring creates beans?


What is microservice?

What is different between SOA vs microservice?

Which cloud technology have you worked?

Azure related questions as I worked on azure

Design patterns

Explain SOLID with examples

What is docker?
What is kubernetes?

Have you created dockerfile?

have you configured kubernetes?

Have you worked on linux commands?

Difference between REST vs http?

What is CAP theorem?

previous project architecture


questions on java 8 stream API

Java 8 features

Why default method has been added in Java 8 ?

how to remove duplicate element from an array ?

reverse a string and remove white spaces

CI CD pipeline flow

Docker file
Main components of Kubernetes cluster

Design pattern used in Spring

Design Pattern used in your projects

Advantages and disadvantages of Microservices

How to deploy microservices?

What is API gateway

Why we use Reactive streams ?


Previous Project complete flow (front end to backend)

What is docker container?

What is Streams in java?

Calculate the average of all the elements in below code snippet using streams:-
List> marksByStudents = [Link] (

[Link] (60, 70, 80),


[Link](50, 70, 85),
[Link](65, 70, 75)
);
write a program to reverse the linked list.

Singleton, Factory, Proxy Pattern, etc

Microservices advantages

Spring s ="energy" -> print first non repeating character


Spring s ="energy"; String s1 = "enemy"; -> print uncommon characters

query to print 3rd largest salary

query to print no. of employees in each department.

design patterns used.

communication between microservices

spring profiles
How to read multiple properties files

Autowiring annotation

JPA annotations

@Query Annotation

RestTemplate methods.

Reading HTTP headers and cookies in spring

excluding auto configuration of some classes in springboot


Exception Handling in Spring

Microservices advantages

2. Spring s ="energy" -> print first non repeating character

3. Spring s ="energy"; -> print uncommon characters

String s1 = "enemy";
4. query to print 3rd largest salary

5. query to print no. of employees in each department.

6. design patterns used.

7. communication between microservices

8. spring profiles

9. How to read multiple properties files


10. Autowiring annotation

11. JPA annotations

12. @Query Annotation

13. RestTemplate methods.

14. Reading HTTP headers and cookies in spring

15. excluding auto configuration of some classes in springboot


16. Exception Handling in Spring

Questions for Raju

Have you implemented Restful webservices in your previous projects? If so, how
did you implement?

What are microservices and any projects implemented so far?


How does Restful webservices communicate?

How is transaction management handled in spring?

What is Dependency Injection?

Constructor injection vs Setter Injection? Which is preferred and why?

List vs set differences?


How to transform a list of objects in java?

Java 8 features

How do you configure environment specific properties?

Reactor streams and RestTemplate

Annotations in JPA

design patterns

How do you keep up with latest technologies?


How to create immutable classes

How do you handle JSON response in webservices

How to ignore certain values of JSON response

Relationships in Hibernate - How do you configure


one to one mapping - what happens if there is a bidirectional dependency

Project Architecture

Employee list given - filter employees with salary more than 30k

Check whether two strings are Anagram or not


Steps for creating Restful webservice

Equals & Hashcode , what hashcode does and what is hash collision

Java 8 features and what features are used in your project

Exceptional Handling in spring

explain functional programming


use cases of API-Gateway Design pattern

oops concept and example

functional interface and example

loose coupling and example and implementation

thread safe arraylist

concurrent hashmap

collections in java
caching and its techniques (examples)

least frequency used cache

async vs sync transactions

system design question (appointment and updation-whole technical flow and


implementation)

Explain last project

Explain Design patterns by category


write the code to create a singleton class. Explain how object is created

Which line in singleton class code can give error if 2 requests access the same
code
write the code to create an immutable class in java, create other mutable class and
use its object in immutable class maintaining immutability

Implement linked list data structure in java . Write code to insert and display
elements in a linked list
How hashmap works internally. How distinct key implementation is done

what is Docker

Write a code to create a rest api and return a string with response status 200

Explain Spring MVC

Difference between synchronous and asynchronous calls


H2 database

JPA/Hibernate

create restful webservices & how restful ws communicate

explain jwt

how to fetch data from appliction properties file

Java 8 features
Given a studentList, add the student data in map with key as StudentId, value
Student data.

LinkedList- program to check if loop in Linkedlist

SQL Joins

put vs patch mapping diff

Ehcache in hibernate

Composite primary key in hibernate


Serialization

Collections : LinkedList & Arraylist difference

Cache - annotations

Builder design pattern

Explain project architecture

nosql & relational db diff and why relational was being used in project

Challenges for Microservices


DB - sql queries:

1. id, name, salary, email, current_city --> employee table, emp_id, designation -->
designation

find no of employees wit salary more than 20000

find no of employees in each with salary more than 20000


find no of managers in each city

BY S N PrasadRao

Challenges

print list item with index using streams

print unique character using streams

arr[1,2,3,4,5,6], target=4, required output=[1,3]


Print the count of minimum duplicate number in array [1,2,2,2,3,3,4,4,4,4] output=
2

int a[] = {1,2,2,3,3,4,4,5};

Map hm = new HashMap();

for(Integer in:a) {

[Link](in, [Link](in)?[Link](in)+1:1);
}

[Link](

[Link]().stream().sorted([Link]([Link]
alue())).filter(k-> [Link]()>1).findFirst().get().getKey());

functional interface in java 8


what is hashset?

What is final,Finally,Finilizer ?

how ioc works internally?

status codes

annotations you worked in spring boot

how many microservices you created.

make an architecture of your microservice


write pseudo code to fine employee list by dept id

if you have to create a microservice then which technology & DB will choose &
why?

how to set traffic level?

Solid princples.

How to create docker image


How you are implementing security in microservices.

Thread life cycle

wait & join difference

two diff array merge it in diff array and sort it with your logic

Interview Questions

Difference between spring vs spring boot?


What is inside starter package?

Explain the Maven lifecycle

How spring creates beans?

What is microservice?

What is different between SOA vs microservice?

Which cloud technology have you worked?


Azure related questions as I worked on azure

Design patterns

Explain SOLID with examples

What is docker?

What is kubernetes?

Have you created dockerfile?

have you configured kubernetes?


Have you worked on linux commands?

Difference between REST vs http?

What is CAP theorem?

previous project architecture

questions on java 8 stream API

Java 8 features

Why default method has been added in Java 8 ?


how to remove duplicate element from an array ?

reverse a string and remove white spaces

CI CD pipeline flow

Docker file

Main components of Kubernetes cluster

Design pattern used in Spring

Design Pattern used in your projects


Advantages and disadvantages of Microservices

How to deploy microservices?

What is API gateway

Why we use Reactive streams ?

Previous Project complete flow (front end to backend)

What is docker container?


What is Streams in java?

Calculate the average of all the elements in below code snippet using streams:-
List> marksByStudents = [Link] (

[Link] (60, 70, 80),


[Link](50, 70, 85),
[Link](65, 70, 75)
);

write a program to reverse the linked list.

Singleton, Factory, Proxy Pattern, etc


Microservices advantages

Spring s ="energy" -> print first non repeating character

Spring s ="energy"; String s1 = "enemy"; -> print uncommon characters

query to print 3rd largest salary


query to print no. of employees in each department.

design patterns used.

communication between microservices

spring profiles

How to read multiple properties files

Autowiring annotation

JPA annotations

@Query Annotation
RestTemplate methods.

Reading HTTP headers and cookies in spring

excluding auto configuration of some classes in springboot

Exception Handling in Spring

Microservices advantages
2. Spring s ="energy" -> print first non repeating character

3. Spring s ="energy"; -> print uncommon characters

String s1 = "enemy";

4. query to print 3rd largest salary


5. query to print no. of employees in each department.

6. design patterns used.

7. communication between microservices

8. spring profiles

9. How to read multiple properties files

10. Autowiring annotation

11. JPA annotations


12. @Query Annotation

13. RestTemplate methods.

14. Reading HTTP headers and cookies in spring

15. excluding auto configuration of some classes in springboot

16. Exception Handling in Spring

Questions for Raju


Have you implemented Restful webservices in your previous projects? If so, how
did you implement?

What are microservices and any projects implemented so far?

How does Restful webservices communicate?

How is transaction management handled in spring?


What is Dependency Injection?

Constructor injection vs Setter Injection? Which is preferred and why?

List vs set differences?

How to transform a list of objects in java?

Java 8 features
How do you configure environment specific properties?

Reactor streams and RestTemplate

Annotations in JPA

design patterns

How do you keep up with latest technologies?

How to create immutable classes


How do you handle JSON response in webservices

How to ignore certain values of JSON response

Relationships in Hibernate - How do you configure

one to one mapping - what happens if there is a bidirectional dependency


Project Architecture

Employee list given - filter employees with salary more than 30k

Check whether two strings are Anagram or not

Steps for creating Restful webservice

Equals & Hashcode , what hashcode does and what is hash collision
Java 8 features and what features are used in your project

Exceptional Handling in spring

explain functional programming

use cases of API-Gateway Design pattern

oops concept and example

functional interface and example


loose coupling and example and implementation

thread safe arraylist

concurrent hashmap

collections in java

caching and its techniques (examples)

least frequency used cache

async vs sync transactions


system design question (appointment and updation-whole technical flow and
implementation)

Explain last project

Explain Design patterns by category

write the code to create a singleton class. Explain how object is created
Which line in singleton class code can give error if 2 requests access the same
code

write the code to create an immutable class in java, create other mutable class and
use its object in immutable class maintaining immutability
Implement linked list data structure in java . Write code to insert and display
elements in a linked list

How hashmap works internally. How distinct key implementation is done

what is Docker

Write a code to create a rest api and return a string with response status 200
Explain Spring MVC

Difference between synchronous and asynchronous calls

H2 database

JPA/Hibernate

create restful webservices & how restful ws communicate

explain jwt

how to fetch data from appliction properties file


Java 8 features

Given a studentList, add the student data in map with key as StudentId, value
Student data.

LinkedList- program to check if loop in Linkedlist

SQL Joins

You might also like