Friday, May 31, 2024

Top 50 Free Spring Certification Practice Questions Answers for Java Developers

Hello guys, if you are preparing for Spring Professional certification in 2024 and looking for free Practice questions then you have come to the right place. I have an excellent update to share with you from 5th April 2024 onward, you don't need to complete any mandatory training or Spring Pro courses to become eligible for Spring certification, its free like it was before VMware acquired and now you just need to buy voucher to give this exam.  Earlier, I have shared best spring books and courses and today, I am going to share 50+ spring boot practice questions for this certification. To be honest, preparing for IT certification like Oracle's Java certification or VMware's Spring Certification required a lot of hard-work. I have seen many experienced Java developers failing these certifications and losing money and time due to overconfidence and lack of preparation. 

Difference between Setter vs Constructor Injection in Spring

Spring Setter vs. Constructor Injection
Spring supports two types of dependency Injection, using a setter method, e.g. setXXX(), where XXX is a dependency or via a constructor argument. The first way of dependency injection is known as setter injection while later is known as constructor injection. Both approaches of Injecting dependency on Spring bean has there pros and cons, which we will see in this Spring framework article. The difference between Setter Injection and Constructor Injection in Spring is also a popular Spring framework interview question

Thursday, May 30, 2024

How to sort a HashMap in Java 8 by keys and values using Stream and Lambda Expressions

Technically, you cannot sort a HashMap in Java because it doesn't guarantee any order. So, even if you add entries in sorted order they will be placed randomly and you won't be able to iterate over map in sorted order of keys or values. Though, if you want to process keys, values or entries of an HashMap in sorted order, you can get the data from the HashMap and then potentially use a TreeMap (when you want to sort a HashMap by key) or LinkedHashMap (when you want to sort a HashMap by value) to store entries in sorted order. This is also the way, we used to sort HashMap before Java 8. 

Wednesday, May 29, 2024

3 ways to Find First Non Repeated Character in a String - Java Programming Problem Example

Write a Java program to find the first non-repeated character in a String is a common question on coding tests. Since String is a popular topic in various programming interviews, It's better to prepare well with some well-known questions like reversing String using recursion, or checking if a String is a palindrome or not. This question is also in the same league. Before jumping into the solution, let's first understand this question. You need to write a function, which will accept a String and return first non-repeated character, for example in the world "hello", except 'l' all are non-repeated, but 'h' is the first non-repeated character.

Tuesday, May 28, 2024

Can you take Spring Professional Certification without Training Course? [Yes]

Hello guys, I have a big news to share with you now. Since 5th April 2024, you can take Spring certification without any mandatory training or Spring Pro content. So after a flip flop of making training mandatory, Spring certification is free again. Vmware, the company behind Spring, after acquiring Pivotal has reversed the earlier decision announced on 10th May 2017 by Pivotal, the previous owner of Spring Framework, that "Spring Certification Exams are now available for individual purchase, without enrolling in the course". This was one of the most discouraging changes in the Spring certification program since it's launched 10 years back. The cost of Spring certification was the single, biggest obstacle for many experienced Java and Spring developers to get certified for their Spring framework skills.

Top 25 Apache Kafka Interview Questions Answers for Java Developers

Hello, guys if you are preparing for the Java Developer or Apache Kafka interview and looking for frequently asked Apache Kafka interview questions and answers then you have come to the right place. Earlier, I have shared the best Kafka courses and popular interview questions on JavaJMSSpring Boot, and Hibernate and in this article, I Am going to share 20 frequently asked Apache Kafka interview questions with answers. Over the years, Kafka which is developed by Apache Software Foundation has gained popularity because of its immense capability of data processing and become a standard tool for high-speed and reliable messaging. 

Monday, May 27, 2024

Top 30 Programming questions asked in Interview - Java C C++ Answers

Programming questions are an integral part of any Java or C++ programmer or software analyst interview. No matter which language you have the expertise it’s expected that you are familiar with the fundamentals of programming and can solve problems without taking the help of API. Programming questions like reversing String using recursion or how to find if Array contains duplicates are some popular examples of programming question in Java. Programming questions present a lot of challenges Especially to Java developers as compared to C++ programmer and I think, One reason for this is powerful Java API; Which has a method for almost every need and you rarely need to write by your own or there are lots of third-party library from Apache, Spring, Google and other open sources.

Saturday, May 25, 2024

12 Intermediate Database Administrator and Developer Interview Questions on Indexing

A good understanding of Index is very important for any programmer working with database and SQL. It doesn't matter whether you are working as DBA or Application developer, working in Oracle, MySQL, or Microsoft SQL Server or any other database, you must have good understanding of how index works in general. You should know different types of index and their pros and cons, how your database or Query engine chooses indexes and the impact of table scan, index scan, and index seek. You should also be able to build upon your knowledge to optimize your SQL queries as well as troubleshoot a production issue involving long running queries or poor performing queries. This is also a great skill for experience developers with 5 to 6 years of experience under his belt. 

How to Manage Distributed Transaction in Microservices? SAGA and 2 Phase Commit Example Tutorial

Hello guys, managing transaction in a distributed system like Microservices is very challenging and if you don't have a proper approach then you may face production issues and end of with data lose, data corruption and app failure. That's why managing distributed transaction is also an important topic on Microservice interviews. If you are working in Microservices architecture then you may have already heard about the SAGA and 2 Phase Commit etc. and there is also a chance that you may have been asked about those on Java developer interviews. If not, don't worry, in this article, I will tell you about those Microservices design patterns while showing how to manage distributed transactions in Microservices architectures in Java.  

Friday, May 24, 2024

Top 10 System Design and Software Analysis and Design Books in 2024 - Best of Lot

Hello guys, System design and Software design are two important topic for coding interviews and also two important skill for Software developers. Without knowing how to design System you cannot create new software and it will also be difficult to learn and understand existing software and system. That's why big technical companies like FAANG pays special attention to System design skill and test candidates thoroughly. If you want to learn System design and looking for best resources like best System design books and courses then you have come to the right place. Earlier, I have shared best System design online courses, as well as Software architecture courses,  and common System design questions and in this article, I am going to share with you best System design books to learn Software design. 

Monday, May 20, 2024

100+ System Design Interview Questions and Problems for Software Engineers

Hello guys, if you are preparing for System Design interviews then you may know that you have to prepare for theory questions as well as System design problems where you need to design a real world system like WhatsApp, YouTube or DropBox. Theory questions are mostly based upon System design basics and core concepts like Scalability, Caching, database sharding, load balancer, API gateway, security, proxies, messaging queues and software architecture, particularly Microservices. I have been sharing a lot of system design preparation material from last few years, in for example, in the past, I have shared System Design Interview Prep Guide as well as best System design interview books, courses, cheat sheets, and websites and in this article, I am target to share 100+ System Design Interview questions as well as System Design Problems.

Friday, May 17, 2024

Top 10 Microservices Design Patterns and Principles - Examples

Hello guys, if you are using Microservice architecture and want to learn about different Microservice design patterns and principles to better architect your application then you have come to the right place. Earlier, I have shared the best Java Microservices courses and books for Java developers, and in this article, I am going to share the essential Microservice design principle and patterns. We will cover patterns like Event Sourcing, Circuit Breaker, SAGA, CQRS, Strangler, Database per Microservices, Backend for Frontend (BFF), Service Discovery,  and API Gateway and principles like Scalability, Flexibility, Resiliency, etc. When you developing an enterprise application, it is good to move with micro-services rather than move with a monolithic architecture. 

Wednesday, May 15, 2024

Difference between @Autowired and @Inject annotation in Spring?

What is the difference between @Autowired and @Inject annotation in Spring is one of the frequently asked Spring questions on Java interviews? Since everybody is now moved or moving to annotation-driven and Java configuration in Spring, this question has become even more important for prospective candidates looking for a Java web development job using the Spring framework. The @Autowired annotation is used for auto-wiring in the Spring framework. If you don't know, autowiring is a process on which the Spring framework figure out the dependencies of a Spring bean, instead of you, a developer, explicitly specifying them in the application context file. You can annotate fields and constructor using @Autowired to tell Spring framework to find dependencies for you.

Tuesday, May 14, 2024

Top 20 Spring and REST Interview Questions Answers for Java/JEE Programmers

Hello guys, I have been sharing a lot of REST with Spring tutorials from last a couple of weeks and today, I am going to share some of the frequently asked Spring and REST interview questions to Java developers applying for Web developer roles. Since Spring Framework is the most popular and the standard framework for developing Java web application and RESTful Web Services, a solid knowledge of Spring core and Spring MVC is expected from any senior Java developer, but if the job description mention about REST and Web Services, you also need to be aware of how to develop RESTful Web Services using Spring Framework?.

Monday, May 13, 2024

Top 5 Books to Learn Spring framework and Spring MVC for Java Programmers

Spring and Spring MVC is one of the most popular Java frameworks, and most of the new Java projects use Spring these days. Java programmer often asks questions like which books are good to learn Spring MVC or the best book to learn Spring framework etc. If you are looking for the best Spring Framework books, then you have come to the right place. Earlier, I shared the best Spring Framework courses and best Spring Boot courses, and in this article, I will share the best books to learn Spring Framework for Java developers. There are many books to learn Spring and Spring MVC, but only certain books can be considered good because of their content, examples, or how they explained the concept involved in the Spring framework. 

Sunday, May 12, 2024

How to POST JSON request from Linux to test RESTful Web Services? Example

Even though, Postman is a great tool and chrome plugin to test RESTful Web services for Java developers, I often find myself using "curl" or "cURL" command in Linux for testing RESTful Web Services, particularly Java web services built using Spring or Spring Boot framework. The curl command is easily available on most of Linux hosts and you just need to type a command to sent various types of HTTP requests to your application from Linux command line, as shown here. Though, many RESTful web developer and tester knows this trick, they mainly use GET request to access data from web service and  many of them struggle to send HTTP POST request containing JSON data to create new resources. 

Saturday, May 11, 2024

Role based Access control using Spring Security and MVC, Mapping LDAP Groups to Authorities for Authorization

Authentication and Authorization is an integral part of any Java enterprise or web application. Since most of the company uses LDAP Active directory for authentication, authorization, and Role-based access control (RBAC), it's good to know How to implement Role-based access control using Spring MVC and Spring Security. This is the second part of my articles on using Spring Security for authentication and authorization in Spring MVC based Java application. In the last part, we have learned about doing LDAP authentication against Windows active directory, and in this Spring Security tutorial, we will learn How to map LDAP groups to authorities for implementing Role-based access control or authorization.

Friday, May 10, 2024

3 ways to solve java.lang.NoClassDefFoundError in Java J2EE

I know how frustrating is to see "Exception in thread "main" java.lang.NoClassDefFoundError" while running your Java application. This is one of the dreaded problem in Java  which is also a manifestation of NoClassDefFoundError in Java. I have seen it a couple of times and spent quite a lot of time initially to figure out what is wrong, which class is missing etc. The first mistake I did was mingling java.lang.ClassNotfoundException and NoClassDefFoundError, in reality, are totally different, and my second mistake was using the trial and error method to solve this java.lang.NoClassDefFoundError instead of understanding why NoClassDefFoundError is coming, what is the real reason behind NoClassDefFoundError and how to resolve this.

10 Examples of JdbcTemplate in Spring Framework

Hello Java programmers, If you have been using the Spring framework then you may know that the JdbcTempalte is one of the most useful classes of the Spring framework. The JdbcTempalte class provides lots of convenient methods for performing database-related tasks that take the pain away from using the JDBC API. If you have worked in any real-life Java project which connects to a Database using JDBC then you know that JDBC API is not very convenient to use as it requires a lot of boilerplate code. For example, to execute a simple SELECT query, you first need to create a Connection and Statement object to execute the query and iterate through a ResultSet Object to get the result of the query. Finally, you need to close all of these resources to prevent resource leaks in Java.

How to Solve java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener in Spring? [Example]

If you have worked in Spring MVC then you may be familiar with  
java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener
which is common problem during deployment. Spring MVC throws  java.lang.ClassNotFoundException:                           org.springframework.web.context.ContextLoaderListener ,
when its not able to find org.springframework.web.context.ContextLoaderListener class which is used to load spring MVC configuration files like application-context.xml and other Spring Framework configuration files defined in context-param element of web.xml in an Spring MVC web application as:

Thursday, May 9, 2024

How to Consume JSON from RESTful Web Service and Convert to Java Object - Spring RestTemplate Example

So far, I have not written much about REST and RESTful web service, barring some interview questions like REST vs. SOAP, which is thankfully very much appreciated by my readers, and some general suggestions about the best books to learn REST and best REST courses in the past. Today I am going to write something about how to consume JSON from a RESTful Web Service in Java using Spring Framework? I will also talk about how to convert the JSON to Java objects using Jackson. You will also learn about the RESTTemplate class from the Spring MVC framework, and how you can use it to create a REST client in Java in just a few lines of code.

Wednesday, May 8, 2024

Spring Boot + Kafka Example (Single and Multiple Consumer) in Java

Hello guys, if you want to use Apache Kafka with Spring Framework or Spring Boot and looking for an example then you have come to the right place. In the past, I have shared the best Spring Boot courses as well as best Apache Kafka courses for Java developers, and in this article, I am going to share how to use Apache Kafka with Spring Boot. You will learn both, to publish and consume messages from Apache Kafka topics in your Spring boot application. By the way, if you don't know, Apache Kafka is an open-source stream-processing software platform developed by LinkedIn and later they donated to Apache software foundation, king of open source development in Java world. 

Monday, May 6, 2024

How to set an "Accept:" header on Spring RestTemplate request? Example Tutorial

Hello Java programmers, if you have been using Spring for REST API development, both creation and consumption then you know that RestTemplate is one of the most commonly used tools for REST service invocations. So one of the major problems you might have in this RestTemplate is that how to set an "Accept" header on Spring RestTemplate request.  In the last article, I have shown you how to POST and Consume JSON using RestTemplate in a Spring Based Java application and In this tutorial, we will go through some important points on how to add headers to RestTemplate and fix the errors related to them. 

Saturday, May 4, 2024

Top 133 Java Interview Questions Answers for 2 to 5 Years Experienced Programmers

Time is changing and so is Java interviews. Gone are the days, when knowing the difference between String and StringBuffer can help you to go through the second round of interview, questions are becoming more advanced and interviewers are asking more deep questions. When I started my career, questions like Vector vs Array and HashMap vs Hashtable were the most popular ones and just memorizing them gives you a good chance to do well in interviews, but not anymore. Nowadays, you will get questions from the areas where not many Java programmer looks e.g. NIO, patterns, sophisticated unit testing or those which are hard to master e.g. concurrency, algorithms, data structures and coding.

Top 22 Spring Interview Questions Answers for Java Programmers [UPDATED]

Hey Java Programmers, if you are preparing for a Java developer interview then you should pay special attention to Spring framework-related questions. Spring framework interview questions are on the rise on Java web development and core Java interviews.  This is obvious given Spring Framework is the best most popular framework available for Java application development and now Spring IOC container and Spring MVC framework are used as a de-facto framework for all new Java development. Because of its popularity,  interview questions from the spring framework are top on any list of Java Interview questions and you should also prepare different Spring topics like Spring Boot, Spring Data JPA, Spring Security, Testing and Spring Cloud, etc to do well on Java developer interviews. 

How to fix @Autowired - No qualifying bean of type found for dependency in Spring Boot? [Solved]

Hello guys, if you are working in a Java and Spring Boot project and you are getting errors like "@Autowired - No qualifying bean of the type found for dependency " then you have come to the right place. Earlier, I have shared how to solve error creating bean with name in Spring framework and In this tutorial, we are going to discuss how to fix @Autowired - No qualifying bean of the type found for dependency. When we come across the org.springframework.beans.factory, we need to be careful. Whether there isn't a qualifying bean of type XXXX accessible, we should see if there is a spring bean called XXXX in the runtime. In most cases, we simply try to inject a bean that isn't defined.

Friday, May 3, 2024

Difference between @Component, @Service, @Controller, and @Repository in Spring

Before you learn the difference between @Component, @Service, @Controller, and @Repository annotations in the Spring framework, it's important to understand the role of @Component annotation in Spring. During the initial release of Spring, all beans are used to be declared in an XML file. For a large project, this quickly becomes a massive task, and Spring guys recognize the problem rather quickly. In later versions, they provide annotation-based dependency injection and Java-based configuration. From Spring 2.5 annotation-based dependency injection was introduced, which automatically scans and registers classes as Spring bean which is annotated using @Component annotation.

Wednesday, May 1, 2024

Top 20 Spring Framework Annotations Java Developers Should Know

Hello guys, annotations are quite important when working in modern Java application as almost all frameworks and libraries nowadays use annotations, including Spring Framework. There was time when we need to remember classes and methods to make effective use of JDK or any open source library but now we also need to remember annotations. For example, to use JUnit you must know about annotations like @Test, @BeforeEach, @AfterEach, @Disabled and so on. Similarly for Spring framework you need to know annotations like @Configuration, @Bean, @Component, @Service, @Value, @Autowired, @Repository, @Qualifier, @Required and more.