Why convert from a list to a map? Maps allow you to store and access data by a “KEY”. Lists only allow you to access data by either index or by looping through the whole list to find a value that you are interested in. … Read more ›...
Why convert from a list to a map? Maps allow you to store and access data by a “KEY”. Lists only allow you to access data by either index or by looping through the whole list to find a value that you are interested in. … Read more ›...
Q1. What do you understand by the terms merging and rebasing? Can you explain both with a daiagram? A1. Both of these commands are designed to integrate changes from one branch into another branch—they just do it in very different ways. … Read more ›...
A very popular open-ended question to judge your Java/JEE experience. Q. How would you go about designing a medium sized JEE application? A. Don’t start with 3-tier architecture, logical layers, Spring/Hibernate framework etc. The phases of designing any systems are: Requirements Gathering => … Read more ›...
Q01: What is a data class?
A01: A data class refers to a class that contains only fields and methods for accessing them via getters and setters. These are simply containers for data used by other classes.
Q02: What exactly makes creating data classes in Java so tedious?
…
This extends 01: JMockit interview Q&As on @Injectable Vs @Mocked Vs @Tested. The purpose of mocking objects is to return an expected value to test the logic of the class under test. This can be achieved with JMockit Expectations. Q1. … Read more ›...
Q01. What is the difference between Docker & Kubernetes Volumes? A01. Docker Volume and Kubernetes Persistent Volume serve similar purposes, but they differ in a number of ways. a) Docker Volumes are used in Docker environments, … Read more ›...
This extends 03: Microservices Architecture design patterns & considerations interview Q&As – Part 2. 4. Cross-cutting concern patterns Microservices require various cross-cutting concerns such as metrics, reporting exceptions to an exception tracker, logging, distributed tracing, health checks, externalized configuration, and security. Additionally, a service may need to handle service discovery...
Let’s look at step by step to understand how to mock private & static methods with PowerMock & JUnit. pom.xml Step 1: The pom.xml file should have Mockito & Powermock libraries.
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
... <dependency> <groupId>org.junit.jupiter</groupId> <artifactId>junit-jupiter-engine</artifactId> <version>5.9.2</version> <scope>test</scope> </dependency> <dependency> <groupId>org.junit.platform</groupId> <artifactId>junit-platform-runner</artifactId> <version>1.9.2</version> <scope>test</scope> </dependency> <dependency> <groupId>org.mockito</groupId> <artifactId>mockito-core</artifactId> <version>3.10.0</version> <scope>test</scope> </dependency> <dependency> <groupId>org.powermock</groupId> <artifactId>powermock-module-junit4</artifactId> <version>2.0.2</version> <scope>test</scope> </dependency> <!-- PowerMock Mockito2 API --> <dependency> <groupId>org.powermock</groupId> <artifactId>powermock-api-mockito2</artifactId> <version>2.0.2</version> <scope>test</scope> </dependency> ... |
Config & Service classes to test Step 2: The implementation classes that need to be tested. … Read...
This extends Part 2: Mockito to fully mock the DAO layer by modifying the service layer to demonstrate partial mocking with “Mockito.spy”. In the “SimpleServiceImpl” we are interested in only testing the method “processUser(int id)” and want to mock the method “getUserById(int id)” by always returning “Sam”. So, … Read...
This extends Networking basics interview Q&As on Protocols. What is an OSI model? Q1. What is an OSI model? A1. The OSI model can be seen as a universal language for computer networking. It is based on the concept of splitting up a communication system into seven abstract layers as...
Q18. Given code:
|
1 2 3 |
List<String> list = new ArrayList<>(); list.add("Java"); list.add("JEE"); |
A18. Firstly, let’s take abstraction and encapsulation as the difference is subtle. Abstraction is often not possible without encapsulation because if a class exposes its internal state, it can’t change its inner workings.
…
Project structure
pom.xml to bring-in Thymeleaf & Spring jars
Step 1: Add “Thymeleaf“jar dependency, and also override default “maven-war-plugin” by explicitly adding the”failOnMissingWebXml” to false to not have web.xml as we will be using JavaConfigs and AbstractAnnotationConfigDispatcherServletInitializer.
…
Q. Write code to traverse a tree and get the largest “root-to-leaf sum”? A “root-to-leaf sum” is a sum of the node values in a root-to-leaf path.
|
1 2 3 4 5 6 7 8 |
package tree; import java.util.List; public interface Node<E> { E getValue(); List<Node<E>> getChildren(); } |
A. Let’s have a basic implementation of the above Node interface. … Read more ›...
I have a good news, I got job offer. I like to share with you from my bottom of my heart feeling thankful to you.
