Posts

Showing posts with the label Java Interview

Go Language - Program to Check Krishnamurthy Number

Image
Hello everyone, today we will create a Go program to check if the given number is an Krishnamurthy number or not. Krishnamurthy number is also referred to as a Strong number. A number is said to be Krishnamurthy if the factorial sum of all its digits is equal to that number. For example, Number = 40585   = 4! + 0! + 5! + 8! + 5!   = 1 * 2 * 3 * 4 + 1 + 1 * 2 * 3 * 4 * 5 +  1 * 2 * 3 * 4 * 5 * 6 * 7 * 8 +  1 * 2 * 3 * 4 * 5   = 24 + 1 + 120 +  40320 + 120   =  40585 Example 1: Go program that checks if the given number is a Krishnamurthy number or not. /*Go program to check whether the given * number is a Krishnamurthy number or not. */ package main import "fmt" // Main function func main() { //sample 1 number1 := 40585 KrishnamurthyNumber(number1) //sample 2 number2 := 13789 KrishnamurthyNumber(number2) //sample 3 number3 := 1009 KrishnamurthyNumber(number3) } func KrishnamurthyNumber(number int ) { //initialize sum to 0 sum

Top Mockito Interview Questions and Answers

Image
1. What is Unit Testing? Unit Testing is a method of testing the smallest piece of code called a unit. The main aim is to isolate each unit of the system to identify, analyze and fine-tune the defects.  2. What are the Benefits of Unit Testing?   Reduces bugs when transmuting the existing functionality.  Reduces the Cost of Testing as defects are captured in the very early phase.  Ameliorates design and sanctions better refactoring of code. 3. What is the Mockito framework?   Mockito is a mocking framework. It is a Java-based library used to engender simple and basic test APIs for performing unit testing of Java applications. It can additionally be utilized with other frameworks such as JUnit and TestNG.  4. What is mocking? Mocking is primarily utilized in unit testing. An object under test may have dependencies on other objects. To isolate the behaviour of the object we optate to supersede the other objects by mocks that simulate the behaviour of the real objects. This is utilizable

Top Spring Cloud Interview Questions

Image
More Java interview questions and answers... Spring Boot actuator interview questions and answers Spring Webflux Interview Questions and Answers Spring Core - Interview Questions Top Spring Cloud Interview Questions Spring Security Interview Questions Spring MVC - Interview Questions Spring Webflux Interview Questions Top Spring Boot Interview Questions Spring Data JPA Interview Questions and Answers Top Mockito Interview Questions and Answers Java Collections Interview Questions Java Stream API Interview Questions and Answers - Frequently asked Quarkus - Interview questions and answers   Spring Interview questions and answers What is Spring Cloud? Spring Cloud provides implements to expeditiously build common patterns in distributed systems such as:  Configuration management Service discovery Circuit breaker Intelligent routing Micro-proxy A control bus  Global locks etc... Coordination of these systems leads to boilerplate patterns and utilizing Spring Cloud we can expeditiously enge

Spring Data JPA Interview Questions and Answers

1. What does JPA stand for? Java Persistence API 2. What's the difference between JPA and Spring Data JPA? JPA is a specification that standardizes the way Java Objects are mapped to a relational database system. Being just a specification, JPA consists of a set of interfaces, like EntityManagerFactory, EntityManager, and annotations that avail you to map a Java entity object to a database table. There are several JPA providers, like Hibernate, EclipseLink, or Open JPA which you can utilize. Spring Data JPA is not an implementation or JPA provider, it's just an abstraction used to significantly minimize the quantity of boilerplate code required to implement data access layers for various persistence stores. 3. What Is the Difference Between Hibernate and Spring Data JPA? Hibernate is a JPA implementation, while Spring Data JPA is a JPA Data Access Abstraction. Spring Data offers a solution to GenericDao custom implementations. It can withal engender JPA queries on your behalf t