Interview Notes Java Springboot HCL
Interview Notes Java Springboot HCL
[Link] name
Problem statement
Microservices architecture promotes modularity, scalability, and maintainability. Your task is to build
a financial system consisting of two services: Account Service and Transaction Service. These services
will communicate with each other to manage account information and financial transactions. You will
implement and complete the code for the following services to handle deposits, withdrawals,
account management, and fund transfers.
Technical specifications
Tech Stack
o Database: SQLite
o Transaction: [ Long: id, Long: accountId, Double: amount, TransactionType: type (DEPOSIT or
WITHDRAWAL) ]
Port
o Account-service: 8001
o Transaction-service: 8002
Tasks
1. Account Service
o POST /api/account/open
Create a new account with the given account holder name and initial balance.
o GET /api/account/{id}
o GET /api/account/balance/{id}
o PUT /api/account/update-balance/{id}/{amount}
Update the balance of the specified account by adding or subtracting the given amount. If
the new balance is negative, throw an exception.
o POST /api/account/transfer
Transfer funds between two accounts using the fromId, toId, and amount. Throw an
exception if there is insufficient balance in the source account.
o GET /api/account/interest/{id}
2. Transacion Service
o POST /api/transaction/deposit/{id}/{amount}
Perform a deposit by adding the specified amount to the account balance and recording the
transaction.
o POST /api/transaction/withdraw/{id}/{amount}
Perform a withdrawal by deducting the specified amount from the account balance. Ensure
the account has sufficient funds before proceeding.
Testing instructions
1. To run any additional commands, navigate to the respective directories in the Terminal. Refer
to the given examples:
2. Use the Thunder Client extension in the IDE's left sidebar to test API requests.
3. After clicking the Run code or Submit code, you can access the Build log or Execution log to
review comprehensive details about the test outcomes.
Answer Ref:
[Link]
import [Link];
import [Link];
import [Link];
import [Link];
@Entity
@Id
@GeneratedValue(strategy = [Link])
[Link]
[Link]
import [Link];
[Link]
import [Link];
import [Link];
import [Link];
@Service
@Autowired
[Link]([Link]);
return [Link](account);
return [Link](id).map(Account::getBalance);
if ([Link]()) {
if (newBalance < 0) {
[Link](newBalance);
return [Link](acc);
} else {
[Link]([Link]() - amount);
[Link]([Link]() + amount);
[Link](fromAcc);
[Link](toAcc);
} else {
[Link]
import [Link];
import [Link].*;
import [Link];
import [Link];
import [Link];
@RestController
@RequestMapping("/api/account")
@Autowired
@PostMapping("/open")
@GetMapping("/{id}")
@GetMapping("/balance/{id}")
@PutMapping("/update-balance/{id}/{amount}")
try {
return [Link](updatedAccount);
} catch (IllegalArgumentException e) {
return [Link]().body(null);
@PostMapping("/transfer")
try {
} catch (IllegalArgumentException e) {
return [Link]().body([Link]());
@GetMapping("/interest/{id}")
2 . Problem name
Problem statement
You are given a student model with ID, name, age, marks, attendance, and promotion status. Your
objective is to perform validation and exception handling around student objects in given scenarios.
Technical specifications
Tech Stack
o Database: MySQL
Port
o Backend: 8000
Tasks
o Throw CustomException when the value of the mark is negative or greater than 100.
o Throw CustomException when the attendance value is negative or greater than 100.
2. Fetch a single student using GET mapping with API endpoint /students/{id}
3. Fetch all students using GET mapping with API endpoint /students
4. Delete a single student using DELETE mapping with API endpoint /students/{id}
6. Update promotion_status for a student to true when both the marks and attendance are
greater than 85 in any other case update as false.
Testing instructions
1. To run any additional commands, use the Terminal. For example, navigate to the
'/backend' directory in the Terminal and use the command: mvn compile.
o Use the CURL command to test the different endpoint requests. For example: curl -X
GET [Link] will check if your GET request for the endpoint is
working or not.
3. Upon clicking the Run code or Submit code buttons, access the Build log or Execution log to
review comprehensive details about the test outcomes.
Answer:
[Link]
import [Link];
import [Link];
import [Link];
import [Link];
@Entity
@Id
@GeneratedValue(strategy = [Link])
[Link]
import [Link];
[Link]
super(message);
[Link]
import [Link];
import [Link];
import [Link];
import [Link];
@ControllerAdvice
@ExceptionHandler([Link])
[Link]
import [Link];
import [Link];
import [Link];
import [Link];
@Service
@Autowired
updatePromotionStatus(student);
return [Link](student);
return [Link](id);
return [Link]();
}
public void deleteStudent(Long id) {
[Link](id);
if ([Link]()) {
[Link]([Link]());
[Link]([Link]());
[Link]([Link]());
[Link]([Link]());
updatePromotionStatus(student);
return [Link](student);
} else {
[Link](true);
} else {
[Link](false);
[Link]
import [Link];
import [Link].*;
import [Link];
import [Link];
import [Link];
import [Link];
@RestController
@RequestMapping("/students")
@Autowired
@PostMapping
@GetMapping("/{id}")
@GetMapping
return [Link](students);
@DeleteMapping("/{id}")
public ResponseEntity<Void> deleteStudent(@PathVariable Long id) {
[Link](id);
return [Link]().build();
@PutMapping("/{id}")
try {
return [Link](updatedStudent);
} catch (CustomException e) {
return [Link]().body(null);
3 . Problem name
Problem statement
You are given a To-do application. The To-do model has ID, task, and status of completion. Your
objective is to complete the functions in [Link].
Technical specifications
Tech Stack
o Database: SQLite
Port
o Backend: 8000
Tasks
1. Fetch list of all the to-do tasks with API endpoint /api/todos
4. To delete a single to-do task from the database with API endpoint /api/todos/{id}
Testing instructions
1. To run any additional commands, use the Terminal. For example, navigate to the '/backend'
directory in the Terminal and use the command: mvn compile
2. Use the Thunder Client extension in the IDE's left sidebar to test API requests.
3. Upon clicking the Run code or Submit code buttons, access the Build log or Execution log to
review comprehensive details about the test outcomes.
Answer:
[Link]
import [Link];
import [Link];
import [Link];
import [Link];
@Entity
@Id
@GeneratedValue(strategy = [Link])
[Link]
import [Link];
[Link]
import [Link];
import [Link];
import [Link];
import [Link];
@Service
@Autowired
return [Link]();
return [Link](id);
return [Link](toDo);
[Link](id);
[Link]
import [Link];
import [Link].*;
import [Link];
import [Link];
import [Link];
import [Link];
@RestController
@RequestMapping("/api/todos")
@Autowired
@GetMapping
return [Link](toDos);
@GetMapping("/{id}")
@PostMapping
@DeleteMapping("/{id}")
public ResponseEntity<Void> deleteToDoById(@PathVariable Long id) {
[Link](id);
return [Link]().build();
4 .Problem name
Problem statement
You are provided with an employee model comprising attributes such as ID, first name, last name,
email, department, and salary. Your task involves executing REST API operations on this model.
Technical specifications
Tech Stack
o Database: MS SQL
Port
o Backend: 8000
Tasks
2. Fetch a single employee using GET mapping with API endpoint /employees/{id}.
3. Fetch all employees using GET mapping with API endpoint /employees.
4. Delete a single employee using DELETE mapping with API endpoint /employees/{id}.
6. Fetch a list of employees with a given department using GET mapping API
endpoint /employees/searchDept.
Note: Initially, the project may encounter build errors due to incomplete code in
the [Link] file, which you should resolve by crafting custom queries.
Testing instructions
1. To run any additional commands, use the Terminal. For example, navigate to the '/backend'
directory in the Terminal and use the command: mvn compile,
2. Use the CURL command to test the different endpoint requests. For example: curl -X
GET [Link] will check if your GET request for the endpoint is
working or not..
3. Upon clicking the Run code or Submit code buttons, access the Build log or Execution log to
review comprehensive details about the test outcomes.
Answer:
Sure, I'll provide the implementation for the [Link] along with the necessary
service, repository, and custom queries.
[Link]
import [Link];
import [Link];
import [Link];
import [Link];
@Entity
@Id
@GeneratedValue(strategy = [Link])
[Link]
import [Link];
import [Link];
import [Link];
import [Link];
[Link]
import [Link];
import [Link];
import [Link];
import [Link];
@Service
@Autowired
return [Link](id);
return [Link]();
[Link](id);
if ([Link]()) {
[Link]([Link]());
[Link]([Link]());
[Link]([Link]());
[Link]([Link]());
[Link]([Link]());
return [Link](employee);
} else {
return [Link](salary);
[Link]
import [Link];
import [Link].*;
import [Link];
import [Link];
import [Link];
import [Link];
@RestController
@RequestMapping("/employees")
@Autowired
@PostMapping
@GetMapping("/{id}")
@GetMapping
return [Link](employees);
@DeleteMapping("/{id}")
[Link](id);
return [Link]().build();
@PutMapping("/{id}")
try {
return [Link](updatedEmployee);
} catch (RuntimeException e) {
return [Link]().build();
@GetMapping("/searchDept")
return [Link](employees);
}
@GetMapping("/searchSalary")
return [Link](employees);
5 . Problem name
Problem statement
Technical specifications
Tech Stack
o Database: SQLite
o Student: [ Long: id, String: firstname, String: lastname, String: email, Date: dob, Long:
schoolId ]
Port
o Student-service: 8000
o School-service: 8001
Tasks
1. Fetch a single student using GET mapping with API endpoint /students/{id}.
2. Fetch all students using GET mapping with API endpoint /students/.
3. Create a single student using POST mapping with API endpoint /students/.
4. Update a single student using PUT mapping with API endpoint /students/{id}.
5. Delete a single student using DELETE mapping with API endpoint /students/{id}.
6. Search for students by first name using GET mapping with API endpoint /students/search.
7. Fetch a list of students from a particular school using GET mapping with API
endpoint /students/by-school/{schoolId}.
2. School service
1. Fetch a single school using GET mapping with API endpoint /schools/{id}.
2. Fetch all schools using GET mapping with API endpoint /schools/.
3. Create a single school using POST mapping with API endpoint /schools/.
4. Update a single school using PUT mapping with API endpoint /schools/{id}.
5. Delete a single school using DELETE mapping with API endpoint /schools/{id}.
6. Search for schools by name using GET mapping with API endpoint /schools/search.
7. Fetch a list of schools by location using GET mapping with API endpoint /schools/by-
location/{location}.
Testing instructions
1. To run any additional commands, navigate to the respective directories in the Terminal. Refer
to the given examples:
2. Use the Thunder Client extension in the IDE's left sidebar to test API requests.
3. Upon clicking the Run code or Submit code buttons, access the Build log or Execution log to
review comprehensive details about the test outcomes.
Answer Ref:
[Link]
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
@Entity
@Id
@GeneratedValue(strategy = [Link])
[Link]
import [Link];
import [Link];
import [Link];
import [Link];
@Entity
@Id
@GeneratedValue(strategy = [Link])
[Link]
import [Link];
import [Link];
import [Link];
import [Link];
[Link]
import [Link];
[Link]
import [Link];
import [Link];
import [Link];
import [Link];
@Service
public class StudentService {
@Autowired
return [Link](id);
return [Link]();
return [Link](student);
if ([Link]()) {
[Link]([Link]());
[Link]([Link]());
[Link]([Link]());
[Link]([Link]());
[Link]([Link]());
return [Link](student);
} else {
}
public void deleteStudent(Long id) {
[Link](id);
return [Link](firstname);
return [Link](schoolId);
[Link]
import [Link];
import [Link];
import [Link];
import [Link];
@Service
@Autowired
return [Link](id);
return [Link](school);
if ([Link]()) {
[Link]([Link]());
[Link]([Link]());
return [Link](school);
} else {
[Link](id);
return [Link](name);
return [Link](location);
}
[Link]
import [Link];
import [Link].*;
import [Link];
import [Link];
import [Link];
import [Link];
@RestController
@RequestMapping("/students")
@Autowired
@GetMapping("/{id}")
@GetMapping
return [Link](students);
@PostMapping
@PutMapping("/{id}")
try {
return [Link](updatedStudent);
} catch (RuntimeException e) {
return [Link]().build();
@DeleteMapping("/{id}")
[Link](id);
return [Link]().build();
@GetMapping("/search")
return [Link](students);
@GetMapping("/by-school/{schoolId}")
return [Link](students);
}
}
[Link]
import [Link];
import [Link].*;
import [Link];
import [Link];
import [Link];
import [Link];
@RestController
@RequestMapping("/schools")
@Autowired
@GetMapping("/{id}")
@GetMapping
return [Link](schools);
@PostMapping
@PutMapping("/{id}")
try {
return [Link](updatedSchool);
} catch (RuntimeException e) {
return [Link]().build();
@DeleteMapping("/{id}")
[Link](id);
return [Link]().build();
@GetMapping("/search")
return [Link](schools);
@GetMapping("/by-location/{location}")
return [Link](schools);
}
Programming Question:
1 -- Ambiguity value
Problem statement
Given a 2D plane. You can move in any of the 4 directions in the first second. After the first second,
you change direction by 90 degrees every second. For example, if you just moved north or south, the
next step you take has to be either west or east and vice versa. In each second, you move 1 unit. You
are given integer N.
Calculate the ambiguity value in your position that is defined by the number of different locations
you can be after exactly N seconds.
Function description
Complete the function Ambuiguity(). This function takes the following parameter and returns the
required answer:
Note: Use this input format if you are testing against custom input or writing code in a language
where we don’t provide boilerplate code
Output format
Calculate the ambiguity value in your position defined by the number of different locations you can
be after exactly N seconds.
Constraints
1<=N<=1000
Ref Answer:
import [Link];
import [Link];
import [Link];
public class Ambiguity {
int x = 0, y = 0;
int direction = 0;
if (direction == 0) {
y += 1;
} else if (direction == 1) {
x += 1;
} else if (direction == 2) {
y -= 1;
} else if (direction == 3) {
x -= 1;
direction = (direction + 1) % 4;
}
// Return the number of unique positions
return [Link]();
int N = [Link]();
[Link]();
2.
Problem name
Valid combinations
Problem statement
Choose a stream of data of size A. You have B different types of integers from which you have to
select the stream of data. You can select an integer multiple times.
A valid combination is a stream of data in which there are exactly C integers that are different from
the previous integer in the sequence.
You are given integers A, B, and C. The first integer in the stream of data is not included among the C
integers.
Complete the function ValidCombinations(). This function takes the following 3 parameters and
returns the required answer:
C: Represents the number of integers that should be different from the previous integer in
the sequence
Note: Use this input format if you are testing against custom input or writing code in a language
where we don’t provide boilerplate code
The first line contains an integer A denoting the number of integers in the data stream.
The second line contains an integer B denoting the number of types of integers.
The third line contains an integer C denoting the number of integers that should be different
from the previous integer in the sequence.
Output format
Constraints
1≤A≤2000
1≤B≤2000
0≤C≤A−1
import [Link];
// Base case: There's one way to have a stream of length 1 with 0 changes
dp[1][0] = B;
if (j > 0) {
dp[i][j] %= MOD;
// Return the number of valid combinations for a stream of length A with exactly C changes
return dp[A][C];
int A = [Link]();
int B = [Link]();
[Link]("Enter the number of integers that should be different from the previous
integer in the sequence: ");
int C = [Link]();
[Link]();
}
3. Problem name
Chocolate stack
Problem statement
A shop has a stack of chocolate boxes each containing a positive number of chocolates. Initially, the
stack is empty. During the next N minutes, either of these two things may happen:
You receive a box of chocolates from the warehouse and put it on top of the stack.
Determine the number of chocolates in the sold box each time he sells a box.
Notes
If C[i] = 0, he sells a box. If C[i] > 0, he receives a box containing C[i] chocolates.
Function description
Complete the solve() function provided in the editor. The function takes the following 2 parameters
and returns the solution.
Note: Use this input format if you are testing against custom input or writing code in a language
where we don’t provide boilerplate code
The second line contains C denoting the array consisting of the box descriptions.
Output format
Print an array, representing the number of chocolates in the sold box each time you sell a box.
Constraints
1≤N≤105
0≤C[i]≤109
Ref Answer :
import [Link];
import [Link];
int resultIndex = 0;
if (C[i] == 0) {
result[resultIndex++] = [Link]();
} else {
[Link](C[i]);
return trimmedResult;
int N = [Link]();
[Link]("The number of chocolates in the sold box each time you sell a box: ");
[Link]();
4. Problem name
Consecutive sale
Problem statement
A shop is open for N days. Each day, one of the following events may occur:
1. If shop[i] = 1, the shopkeeper returns any remaining stock from the previous batch (if there
is any) and receives a large number of items from the new batch. During this time, no
customers are served.
3. If shop[i] = -1, the shopkeeper returns all the items that are currently in the shop.
Find the maximum number of days the shopkeeper sells items from the same lot.
Notes
It is possible that a customer comes to the shop and there are no items available. In such a
case, the shopkeeper does not sell anything to that customer.
Function description
Complete the solution() function. The function takes the following 2 parameters and returns the
solution:
The second line contains array shop of size N, denoting the details of each day.
Output format
Print a single integer representing the maximum number of days in which the shopkeeper sells
items from the same lot.
Constraints
1≤N≤105−1≤shop[i]≤1
Given
Input:
N=4
shop = [1,1,0,0]
Output: 2
Approach :
On day 2, the shopkeeper returns all items from lot number 1 and gets items from lot number 2.
For the next 2 days, the sells items from lot number 2.
Ref Answer :
import [Link];
int maxDays = 0;
int currentDays = 0;
if (shop[i] == 1) {
currentDays = 0;
hasStock = true;
} else if (shop[i] == 0) {
if (hasStock) {
currentDays += 1;
currentDays = 0;
hasStock = false;
return maxDays;
int N = [Link]();
shop[i] = [Link]();
[Link]("The maximum number of days in which the shopkeeper sells items from
the same lot is " + solution(N, shop) + ".");
[Link]();
}
5 . Problem name
Problem statement
The Department of Parks and Recreation wants to minimize the maximum distance between any
two trees in the city by cutting exactly one tree. The trees' locations are represented by
coordinates (x, y) where x and y are the distances from the x-axis and y-axis, respectively. The
distance between two trees is defined as the Manhattan distance between them. Find the
minimum possible, maximum distance between any two trees by cutting exactly one tree.
Function description
Complete the function solve() which takes as input an integer N denoting the number of trees in
the city and a 2-D integer array trees denoting the coordinates of the trees.
Note: Use this input format if you are testing against custom input or writing code in a language
where we don’t provide boilerplate code
The first line contains N denoting the number of trees in the city.
Output format
Print a single integer representing the minimum possible, maximum distance that can be achieved
by cutting precisely one tree.
Constraints
3≤N≤1e3
1≤xi,yi≤1e9
dist(1,2)=|1-2|+|2-4|=3
dist(1,3)=|1-2|+|2-6|=5
dist(1,4)=|1-3|+|2-9|=9
dist(1,5)=|1-2|+|2-8|=7
dist(2,3)=|2-2|+|4-6|=2
dist(2,4)=|2-3|+|4-9|=6
dist(2,5)=|2-2|+|4-8|=4
dist(3,4)=|2-3|+|6-9|=4
dist(3,5)=|2-2|+|6-8|=2
dist(4,5)=|3-2|+|9-8|=2
Initial max
distance=max(dist(1,2),dist(1,3),dist(1,4),dist(1,5),dist(2,3),dist(2,4),dist(2,5),dist(3,4),dist(3
,5),dist(4,5)
=max(3,5,9,7,2,6,4,4,2,2)=9
New max
distance=max(dist(2,3),dist(2,4),dist(2,5),dist(3,4),dist(3,5),dist(4,5))=max(2,6,4,4,2,2)=6
It can be proved that 6 is the minimum maximum distance that can be achived.
Ref Answer :
import [Link];
int maxDistance = 0;
if (i != j) {
maxDistances[i] = maxDistance;
}
int minMaxDistance = Integer.MAX_VALUE;
return minMaxDistance;
int N = [Link]();
trees[i][0] = [Link]();
trees[i][1] = [Link]();
[Link]();
Problem statement
Which of the following command line tools is built by using the RabbitMQ HTTP API?
Choices
Rabbitmqctl
Rabbitmq-plugins
Rabbitmq-diagnostics
Problem statement
In the microservice architecture, which of the following modules of the Netflix Ribbon component
supports HTTP that uses the RxNetty library with the load balancing capacity?
Choices
ribbon-eureka
ribbon-loadbalancer
ribbon-httpclient
Problem statement
While working on a large application using microservices you came across the concept of bounded
context. Which among the following options best describes the functionality of bounded context in
Microservice Architecture?
Options:
2. A logic domain that is usually represented by the data consumed and emitted by a
microservice-based on its purpose, structure, and meaning
Choices
1
2 Correct answer
3
None of these
In RabbitMQ, which of the following commands is used to activate the confirm mode on a channel?
Choices
[Link]
[Link]
[Link]
Problem statement
In the microservice architecture, which of the following statements about the Hystrix server are
correct:
Statements:
2. If the application is running without an issue, then the circuit remains open.
3. If the application is running without an issue, then the circuit remains closed.
4. If the application is running with an issue, then the server opens the circuit
Choices
1, 2, and 4
2, 3, and 4
1, 2, and 3
Problem statement
Alice is currently using Java and wants to build a large application. For such a scenario, she wants to
make use of certain architecture. Which among the following architecture involves structuring an
application in the form of a cluster of small, autonomous services modeled around a business
domain?
Choices
Monolithic Architecture
Modular Architecture
Problem statement
Which of the following statements about using the microservices over the Service-Oriented
Architecture (SOA) are correct?
Statements:
Choices
1 and 2
3 and 4
2 and 3
Choices
Hystrix server
While working on microservices you want to test your application before deployment and wish to
make use of testing that tests the end-to-end functionality of the application. As microservices
architecture has multiple services which might need to interact with other microservices as part of a
user request, which among the following testing techniques would you choose for the above
functionality?
Choices
Unit Testing
Load Testing
Resilience Testing
Problem statement
Choices
Hystrix server
Problem statement
In RabbitMQ, a default exchange that is referred by an empty string (" ") is a pre-declared direct
exchange that contains no name. If the default exchange is used to deliver a message to a queue,
then which of the following entities represents the name of the message?
Choices
Queue
Binding
You're implementing
4. Event-based notifications.
7. Performance monitoring.
Choices
Observer Pattern
Strategy Pattern
Command Pattern
Problem statement
Which of the following versions of ERLANG OTP is not supported by RabbitMQ versions prior to
3.7.7?
Which of the following versions of ERLANG OTP is not supported by versions of RabbitMQ that are
older than 3.7.7?
Choices
John is working on a project and he is required to use MicroServices. Now he wants to know about
Microservices. help him to find which of the following statements are correct about the above-
mentioned context.
Statements:
1. While designing a microservice, the developer should be specific about the focal point of the
service.
2. Each microservice should be an autonomous business unit of the entire application.
3. It is cheaper than SOA and it is used to maintain different server spaces for different business
tasks.
Choices
2 and 3
1 and 3
All of these
Bob is working on a project using Microservices Architecture. He came across the term API gateway.
Which among the following best describes the acknowledged term?
Options
2. API Gateway can aggregate the results from the microservices back to the client. API
Gateway can also translate between web protocols like HTTP, web socket, etc.
3. API Gateway is responsible for routing the request, composition, and translation of the
protocol.
4. API Gateway can provide only one client with a custom API.
Choices
1 and 2
3 and 4
1 and 4
Which of the following statements represent the disadvantages of using microservices:
1. A large group of developers is required to support this heterogeneous distributed software.
2. It is difficult to make a microservice application enterprise ready to compare to the conventional
software development model.
3. Microservice does not follow a high level of resilience in building methodology.
Choices
2 and 3
1 and 3
All of these
Choices
All microservices should be strongly coupled with one another such that changes in one will
not affect the other.
Each service unit of the entire application should be the largest and capable of delivering one
specific business goal.
All of these
An organization is required to handle 0.96 million people every second. In order to control this heavy
traffic, the organization redirects all the traffic from one region to a specific server. If you are required
to perform the Y-axis scaling in this scenario to overcome this hindrance, then which of the following
actions is performed?
Choices
Run the single server with the same application at a different time.
Run the multiple servers with the same application at a different time.
Run the single server with the same application at the same time.
Run the multiple servers with the same application at the same time. --- correct
Bob is working on MicroServices. While working on an application he wants to know about
the benefits of using an API gateway. Help him to find which of the following statements are correct
for the above-mentioned context.
Statements:
1. It provides each kind of client with a specific API.
2. It decreases the errors at the same time.
3. It increases the number of round trips between the client and the application.
4. It simplifies the client code.
Choices
1, 2, and 3
2, 3, and 4
1, 3, and 4
In the microservice architecture, which of the following represents the advantage of scaling?
Choices
Performance
Reuse
Load distribution
Choices
The node must not be the only disc node in the cluster.
This command can be used both locally and remotely.--- Correct answer
Which of the following mechanism of the Hystrix server microservice component is used to avoid the
failure of an application?
Choices
In RabbitMQ, which of the following is used to monitor and handle a server from a web browser?
Choices
AMQP protocol
Exchange
Broker
In the microservice architecture, which of the following composite patterns is used to build one extra
layer by providing a dump layer?
Choices
Aggregator pattern
Chained pattern
Statement:
1. The client can directly communicate with the service.
2. One service can communicate with one service at a time.
3. The developer is allowed to configure service calls dynamically.
Choices
1 and 2
2 and 3
All of these
In the microservice architecture, which of the following components is used to provide the HTTP
resource-based API for the external configuration in the distributed system?
Choices
Netflix Ribbon
Statements:
Choices
1
2 --Correct answer
Both of these
None of these
Which of the following tools about the monitoring microservices are correct:
1. Hystrix dashboard
2. Metasploit admin dashboard
3. Eureka admin dashboard
4. Spring boot admin dashboard
Choices
1, 2, and 3
2, 3, and 4
1, 2, and 4
In the microservice architecture, which of the following statements about the server-based load
balancing are correct:
1. It accepts the incoming network, application traffic, and distributes the traffic across the multiple
backend servers by using different methods.
2. The client chooses an IP from the list and forwards the request to the server.
3. The middle component is responsible for distributing the client requests to the server.
Choices
1 and 2
2 and 3
All of these
System virtualization
Application virtualization
Cloud virtualization
You are developing a microservice. If all the business models need to be sub-divided into the smallest
business part as much as possible, then which of the following principles is represented in this
scenario?
Choices
Observable principle
Automation principle
Choices
SSL/TLS
Queued
Channel--Correct answer
Vhost
Choices
All of these
In RabbitMQ, which of the following entities is used to route messages to different queues?
Choices
Exchange
Routing key
Binding--Correct answer
Topic
In the microservice architecture, if an application uses a Zipkin distributed tracing server, then
determine its port number.
Choices
8761
8888
9411--Correct answer
8765
Alice is required to prevent security problems in her organization. If she has worked closely with
different teams and fixed the issues caused during the detective control phase, then which of the
following defensive mechanisms is represented in this scenario?
Choices
Deterrent control
Preventive control
Detective control
Problem statement
Which of the following systems is used by the Service-Oriented Architecture (SOA) for
communication?
Choices
Both of these
None of these
Y-axis scaling
Z-axis scaling
None of these
In the microservice architecture, which of the following statements about the Netflix Eureka Naming
server are correct?
Statements:
1. It provides the REST interface internally that can be used for communication.
2. Eureka client interacts with the Eureka server for service discovery.
Choices
1
2--Correct answer
Both of these
None of these
In the microservice architecture, which of the following statements about the API gateway are
correct:
Statements:
1. It is a server of multiple entry points into a system and is used to encapsulate the internal
system architecture.
Choices
1 and 2
1 and 3
All of these
In the microservice architecture, the security issue is associated with all kinds of services in the
market. If you are required to ensure the security protection for the service providers, then which of
the following actions must be performed?
Choices
Background verification of the services that have direct access to the core part of the cloud.
Background verification of the servers that have direct access to the core part of the cloud.
Background verification of the clients that have direct access to the core part of the cloud.---
Correct answer
Both 2 and 3
In the microservice architecture, which of the following modules of the Netflix Ribbon component
supports HTTP that uses the RxNetty library with the load balancing capacity?
Choices
ribbon-eureka
ribbon-loadbalancer
ribbon-httpclient
Statements:
1. The client is allowed to communicate directly with the services.
2. The specific services are connected such that the output of one service will be the input of the
next service.
3. The client is blocked until the entire process is complete.
Choices
1 and 2
2 and 3
All of these
In RabbitMQ, which of the following actions is performed by the rabbitmqctl stop_app command?
Choices
Stops a RabbitMQ application--Correct answer
Ben is working on a project in Java language. He used 'X' Framework in his project.'X' implements all
the basic features of a core spring framework like Inversion of Control, and Dependency Injection,
and provides an elegant solution to use it in the 'X' framework with the help
of [Link] among the following annotation doesn't include in it?
Choices
@RequestParam
@Controller
@Component
Correct answer
In Spring, you have developed a banking-based web application for which users need to sign-up their
information to log in to the website. Now, you are working on the Spring MVC validation to restrict
the input provided by the user. You are required to apply constraints on the object model by using
various annotations. For this, you wanted to implement the Bean validation API. Now, which of the
following statements about these annotations from this API are correct in this scenario:
Statements
2. The annotation @Size determines that the size must be equal to the specified value.
3. The annotation @Max determines that the number must be equal to or less than the
specified value.
4. The annotation @RegExp determines that the sequence follows the specified regular
expression.
Choices
1, 2, and 3
Correct answer
2, 3, and 4
1, 3, and 4
All of these
Bob is working on a project in Java language. He used 'X' Framework in his project.'X' implements all
the basic features of a core spring framework like Inversion of Control, and Dependency Injection and
provides an elegant solution to use it in the 'X' framework with the help of [Link]
among the following form tag does it include?
Choices
submit
table
password
Correct answer
Spring AOP –
Which of the following AOP framework objects can be used to execute aspect contracts in the Spring
framework?
1. JDK dynamic proxy
2. CGLIB proxy
Choices
Only 1
Only 2
Both 1 and 2
Correct answer
Neither 1 nor 2
You are working on developing a spring boot application. You are working with AOP which you know
is one of the key components of Spring Framework. How would you go about declaring an aspect?
Choices
@AspectJ
@[Link]
@Declare
@Aspect
Correct answer
You want to enable AspectJ support in your Spring application. Which of the following code snippets
should you use to achieve this?
Options
1.
2.
3.
Choices
1
2--Correct answer
3
Both 1 and 3
Choices
Weaving is the process of linking an aspect with other application types or objects to create
an advised object--Correct answer
It is an expression that is matched with join points to determine whether advice needs to be
executed or not
It is the process of creating an object after applying advice to the target object.
None of these
Suppose Bob is working on developing a spring boot application. He is working with AOP which you
know is one of the key components of Spring Framework. He know AOP can work with 5 types of
advices, so when he see 6 types of advices, he know something is wrong. Determine the faulty type.
1. before
2. after
3. during
4. after-returning
5. after-throwing
6. around
Choices
3----Correct answer
4
5
6
-----
Choices
Correct answer
Choices
None of these
Both of these
Correct answer
Alice is developing a spring boot application. She is currently working with AOP which she knows is
one of the key components of Spring Framework. She has a Pointcut signature and a Pointcut
Expression, then which of the following option is correct?
A - @Pointcut("execution(* name(..))")
Options:
1. A - Expression
2. B - Signature
3. A - Signature
4. B - Expression
Choices
1--Correct answer
2
Options:
1. <aop:advisor>
2. <aop:around>
3. <aop:aspect>
4. <aop:after-returning>
Choices
1, 2 and 3
1, 2 and 4
1, 3 and 4
[Link] [Link];
import [Link].*;
[Link] = val;
Map < String, Integer > map1 = new HashMap < String, Integer > ();
Map < MyString, Integer > map2 = new HashMap < MyString, Integer > ();
[Link]([Link](str1));
[Link]([Link](str3));
}
}
Options:
1 – 10
20
2 – 20
10
3 –10
10 --Correct
4 –20
20
2. During the development of a web application using Spring Boot framework, Alice comes across the
following code written by his colleague. Which of the following is true about this code?
Code:
@RestController
@RequestMapping("/home")
}
}
1. A request to /home will be handled by the default() method as the annotation does not
specify any value.
Choices
1
2
3
4 Correct answer
Code:
class HackerEarth {
int getValue() {
try {
String[] Languages = {
"Try block",
};
[Link](Languages[1]);
} catch (Exception e) {
return returnValue;
} finally {
returnValue += 10;
return returnValue;
HackerEarth
[Link]("Main Block:" +
[Link]());
Options:
Main Block:20
Main Block:10
Option C:
Main Block:20
Choices
1Correct answer
2
3
4
4.
[Link]([Link]());
[Link]([Link]());
interface Shape {
double getArea();
double radius;
Circle(double radius) {
[Link] = radius;
@Override
[Link] = width;
[Link] = height;
@Override
interface AbstractFactory {
Shape createShape();
@Override
@Override
Option:
A: 1.0
2.0
B: 0.0
1.0
C: 0.0
2.0
D: 0
Correct option – C
[Link]();
class Wheel {
void rotate() {
[Link]("Wheel rotated");
}
class Car {
Wheel wheel;
Car(Wheel w) {
wheel = w;
void move() {
[Link]();
[Link]("Car moving");
Options:
Car moving
2 -- Car moving
Wheel rotated
3 -- No Output
Correct – Option 1
6 . Alice is working on developing a spring boot application. She wants to use Spring Cloud bus as it
links nodes of a distributed system. She and her colleague know that as long as Spring Cloud Bus
AMQP and RabbitMQ are on the classpath any Spring Boot application will try to contact a RabbitMQ
server on the default value of [Link]. There is however a small hitch in
execution. Her colleague seems to have forgotten the address. What is the default value of
[Link]?
Choices
localhost:3448
localhost:6572
import [Link];
import [Link];
try {
[Link]();
} catch (IOException e) {
[Link]("IOException caught");
class Parent {
[Link]("Parent");
[Link]("Child");
Options:
Parent
Child-------Correct answer
IOException caught
Compilation Error
8. A Twilio Voice application built with Java sends a request to the server using the Twilio Voice API.
Unfortunately, the server is either unreachable or encountering issues, as indicated by the response
"Bad Gateway." To address this, the Java developer handling the Twilio Voice API needs to adeptly
handle this situation and identify the appropriate exception code to effectively manage it within their
application's logic. What is the suitable exception code to address the scenario mentioned?
Choices
• EXCEPTION_BAD_GATEWAY---Correct answer
• EXCEPTION_BAD_GATEWAY_TIMEOUT
• EXCEPTION_FORBIDDEN
• EXCEPTION_FORBIDDEN_TIMEOUT
Expression
int x = 3;
int y = 4;
double z = 2.5;
double result = x * y + z;
Options
• 19.5
• 20
10 .
Ben is using the following code snippet in his application when working with List in java.
What will be the output ??
Option
2. Prints “1.2.4”
3. Prints “[Link]”
4. Prints “2.4,6,8”
MCQ:
[Link] [Link];
import [Link].*;
[Link] = val;
Map < String, Integer > map1 = new HashMap < String, Integer > ();
[Link]([Link](str1));
[Link]([Link](str3));
Options:
1 – 10
20
2 – 20
10
3 –10
10 --Correct
4 –20
20
2. During the development of a web application using Spring Boot framework, Alice comes across the
following code written by his colleague. Which of the following is true about this code?
Code:
@RestController
@RequestMapping("/home")
1. A request to /home will be handled by the default() method as the annotation does not
specify any value.
Choices
1
2
3
4 Correct answer
Code:
class HackerEarth {
int getValue() {
try {
String[] Languages = {
"Try block",
};
[Link](Languages[1]);
} catch (Exception e) {
return returnValue;
} finally {
returnValue += 10;
return returnValue;
HackerEarth
[Link]("Main Block:" +
[Link]());
Options:
Main Block:20
Main Block:10
Option C:
Main Block:20
Choices
1Correct answer
2
3
4
4.
[Link]([Link]());
[Link]([Link]());
interface Shape {
double getArea();
double radius;
Circle(double radius) {
[Link] = radius;
@Override
[Link] = width;
[Link] = height;
@Override
interface AbstractFactory {
Shape createShape();
@Override
public Shape createShape() {
@Override
Option:
A: 1.0
2.0
B: 0.0
1.0
C: 0.0
2.0
D: 0
Correct option – C
class Wheel {
void rotate() {
[Link]("Wheel rotated");
class Car {
Wheel wheel;
Car(Wheel w) {
wheel = w;
void move() {
[Link]();
[Link]("Car moving");
Options:
Car moving
2 -- Car moving
Wheel rotated
3 -- No Output
Correct – Option 1
6 . Alice is working on developing a spring boot application. She wants to use Spring Cloud bus as it
links nodes of a distributed system. She and her colleague know that as long as Spring Cloud Bus
AMQP and RabbitMQ are on the classpath any Spring Boot application will try to contact a RabbitMQ
server on the default value of [Link]. There is however a small hitch in
execution. Her colleague seems to have forgotten the address. What is the default value of
[Link]?
Choices
localhost:3448
localhost:6572
localhost:8000
import [Link];
import [Link];
try {
[Link]();
} catch (IOException e) {
[Link]("IOException caught");
class Parent {
[Link]("Parent");
[Link]("Child");
}
}
Options:
Parent
Child-------Correct answer
IOException caught
Compilation Error
8. A Twilio Voice application built with Java sends a request to the server using the Twilio Voice API.
Unfortunately, the server is either unreachable or encountering issues, as indicated by the response
"Bad Gateway." To address this, the Java developer handling the Twilio Voice API needs to adeptly
handle this situation and identify the appropriate exception code to effectively manage it within their
application's logic. What is the suitable exception code to address the scenario mentioned?
Choices
• EXCEPTION_BAD_GATEWAY---Correct answer
• EXCEPTION_BAD_GATEWAY_TIMEOUT
• EXCEPTION_FORBIDDEN
• EXCEPTION_FORBIDDEN_TIMEOUT
Expression
int x = 3;
int y = 4;
double z = 2.5;
double result = x * y + z;
Options
• 19.5
• 20
• None of the above
10 .
Ben is using the following code snippet in his application when working with List in java.
Option
2. Prints “1.2.4”
3. Prints “[Link]”
4. Prints “2.4,6,8”