Thursday, March 30, 2023

Top 5 Spring Cloud Annotations for Java Microservices

Hello guys, If you are developing a Java application for Cloud, then you should learn Spring Cloud, a great framework and extension of the popular Spring framework, which can help you to develop a cloud-native Java application. Spring Cloud provides several necessary services required for a cloud-based Java application and Microservices like configuration management, service discovery, circuit breakers, intelligent routing, micro-proxy, a control bus, one-time tokens, global locks, leadership election, distributed sessions, cluster state, etc.

Top 40 Java and Linux Interview Questions Answers for IT Support Engineers

Hello guys, if you are going for a Java support engineer interview and looking for some frequently asked questions then you have come to the right place. I have shared many posts about Java interview questions in the past but nothing, particularly from the support engineer perspective. Since there are a lot of L1 and L2 support job that exists in BFSI (Banking, Finance, and Insurance Industry) and they are also for the longer term, I decided to write this post. In this article, I will share questions to help with technical aspects like the essential skills you need to clear a support engineer interview.

How to Print SQL Statements in Spring Boot Application Log File? Example Tutorial

Hello guys if you are working on a Spring Boot application which loads and save data from database but you are not sure which queries are run on backend and you want to see them then you have come to the right place. Earlier, I have showed you how to set logging level in Spring Boot and In this article we are going to have a look at another very interesting topic from Spring Boot on how to log SQL statements in spring boot app. I know you might be wondering why I’m calling a very boring topic an interesting one? A proper logging is among one of the features that sets intermediate or experienced developers apart from beginners. 

Wednesday, March 29, 2023

Top 15 Spring Boot Interview Questions with Answers for Java/JEE Programmers

Hello guys, if you are preparing for your next Java interview and Job description mentioned about the Spring framework, then you should also prepare some Spring Boot interview questions to avoid disappointment. Spring Boot is now the standard way to use the Spring framework for Java development and almost all the companies are moving from the traditional way of using Spring Framework to a more modern Spring Boot way. Gone are the days, where questions like have you used Spring Boot " were asked to the developer. Nowadays interview expects more knowledge of Spring Boot from candidates and there are reasons for it, which we'll explore in this article.

Tuesday, March 28, 2023

10 Examples of New HttpClient + HttpRequest + HttpResponse In Java 11 (REST Client]

Hello guys, one of the notable addition in recent Java release is the full fledged HttpClient from Java. This is one of the class or utility which was much needed in Java. It was quite surprising that JDK doesn't have any fully functional HTTP client to connect to REST APIs in this world of API Integration. Until Java 11, Java developer rely on classes like RestTemplate and WebClient from Spring Framework to make HTTP class to REST APIs, but now you don't need to include Spring Framework in your project just for that. You can now use HttpClient class and its support classes like HttpRequest and HttpResponse to make both synchronous and asynchronous HTTP calls in Java. 

Monday, March 27, 2023

How to setup Request timeout in Spring Boot REST API? Example Tutorial

Hello guys, if you are wondering how to setup request timeout in your REST API using Spring boot then you have come to the right place. First thing first, when you make a request to another API in production, you must add timeout as there is no guarantee that you will receive response in time. Today we are going to take a look at setting up request timeout in Spring Boot Rest API. Before making it into the topic. Let’s first understand a few terms here. What is a Request timeout? A Request timeout is a deadline for services to respond to requests. It ended up returning an error with status 504 if the request fail to respond within the specified time. Request timeouts can help prevent a bad user experience, especially when a request is taking a long to respond to. There are various ways to set request timeout in Spring Boot

Top 40 Core Java Interview Questions Answers from Telephonic Round [UPDATED]

Hello guys, here is another post about preparing for Java Interviews, this time we will take a look at 40 core Java questions from the telephonic round of Java Programming interviews. Phone interviews are usually the first step to screen a candidate after selecting his resume. Since it's easy to call a candidate than to schedule a face-to-face interview, book rooms, and arrange for a meeting, a telephonic round of interviews is quite popular nowadays. There were days only one telephonic round of interviews was enough but nowadays, it's almost two and three rounds of phone interviews with different team members before you get a chance for face-to-face interviews. 

Difference between Abstraction and Encapsulation in Java and Object Oriented Programming? [Answer]

The difference between Abstraction and Encapsulation in Java is a common question in Java interviews for Beginners to check their understanding of Object-Oriented Programming and their ability to use them. Abstraction and Encapsulation in Java are two important Object-oriented programming concepts and they are completely different from each other. The only similarity between Abstraction and Encapsulation is that they are OOP concepts, other than that they mean two different things, but there is a confusing thing, both hide details to simplify things but for different reasons. 

Saturday, March 25, 2023

Top 40 Binary Tree Coding Interview Questions for Programmers

Hello guys, if you are preparing for coding interviews and want to master tree-based questions then you have come to the right place. A tree is one of the most important data structures because it allows you to store hierarchical data as opposed to an array and linked list which allows storing linear data. That's why knowledge of tree data structure is very important from an interview point of view. A lot of programmers and my readers have been asking me to share some binary tree-based coding interview questions, just like I have done for the array, linked list, string, software design, patterns, hash table, and data structure in general. 

Differences Between JPA, Hibernate, and MyBatis

Hello guys Are you tired of using plain old SQL to access your database? Are you looking for a better way to manage your database interactions in Java? Well, you're in luck because JPA, Hibernate, and MyBatis are here to save the day! If you're a Java developer, you've likely come across the terms JPA, Hibernate, and MyBatis when working with databases. While they all deal with object-relational mapping (ORM), they have their own distinct approaches and features. Understanding the differences between them can help you make informed decisions when choosing which one to use for your projects.

Top 30 OOP (Object Oriented Programming) Interview Questions Answers in Java

Java is an object-oriented programming language and you will see a lot of object-oriented programming concept questions in Java interviews. The classic questions like the difference between an interface and abstract class are always there but from the last couple of years more sophisticated questions based upon advanced design principles and patterns are also asked to check the OOP knowledge of the candidate. Though, Object-oriented programming questions are more popular on Java interviews for 1 to 3 years experienced programmers. 

Friday, March 24, 2023

Top 10 Object Oriented Programming Concepts Every Programmer Should Learn

Object-oriented programming (OOP) is a programming style that is used to solve the problem by thinking in terms of real-world objects like Car, Bag, Animal, etc. It also helps you to organize code, which makes it easier to understand and solve complex programs. Objects hold information about state and behavior. States are the characteristics of the object, or the words you would use to describe it, and usually, take the form of is or has descriptors. A computer is either on or off, a chair has four legs, and you have a name. Behaviors are the things the object can do, or the actions the purpose can perform and are usually verbs that end in ing like You are sitting, using a computer, and reading this article.

Can You Override Private Method in Java? Inner Class?

No, you cannot override private methods in Java, private methods are non-virtual in Java and access differently than non-private one. Since method overriding can only be done on derived class and private methods are not accessible in a subclass, you just can not override them. By the way, one more possibility of overriding private methods in an inner class, since private methods are accessible in an inner class, and that’s why it is one of the tricky java interview questions. Anyway, this will also not work because private methods are bonded during compile time and only Type (or Class) is used to locate a private method.

Wednesday, March 22, 2023

How to Fix Consider defining a bean of type 'package' in your configuration [Solved]

Hello and welcome to another blog post. Today we are going to take a look at one of the most frequently appearing errors in the Spring Boot application. I’m sure most of us have faced a similar issue while working with the Spring Boot application, and the error is ‘consider defining a bean of type package in your configuration’. In general, The error "Consider defining a bean of type 'package' in your configuration" occurs when Spring Boot is unable to find a bean of a specific type that is required by your application. In this article, we will take an in-depth look at why this error appears in the first place. Moving ahead we will learn how to fix this issue. So without further ado let’s jump into it.

How to use Spring Boot and Thymyleaf in Java Web Application? Example Tutorial

Hello guys, if you are looking for a Spring Boot and Thymyleaf example, tutorial, or a project then you have come to the right place. Thymyleaf is one of the most popular, modern, server-side Java template engine to generate HTML and XHTML content. Earlier, I have shared Spring Boot + Reactjs project, as well a complete project to create Spring Boot + REST and Spring Boot + Microservices and in this tutorial, you will learn about how to create a spring boot and thyme leaf application using the h2 database.  So before moving to an example, let's discuss what is thymyleaf? Thymeleaf is a web application development library based on Java. It offers excellent support for providing XHTML/HTML5 in web applications.

Monday, March 20, 2023

Top 5 Object Oriented Analysis and Design Interview Questions for Programmers, Software Engineers

Testing the design skill of a candidate is quite common in programming job interviews. Questions like, how do you design a vending machine or a traffic control system are very popular in object-oriented programming language interviews, like Java and C++. Designing a software System requires good experience and knowledge of tools of object-oriented design and analysis. You should not only be good at OOP fundamentals like Abstraction, Inheritance, Polymorphism, Encapsulation, Coupling, Cohesion, Association, Aggregation, or Composition but also on several crucial object-oriented design principles like SOLID Principles of Object-Oriented Design, which is the building block for writing flexible and maintainable code.

Thursday, March 16, 2023

What is ContextLoaderListener in Spring MVC? Example Tutorial

The ContextLoaderListner is one of the essential components of the Spring MVC framework, probably the most important after the DispatcherServlet itself. It is used to create the root context and responsible for loading beans, which are shared by multiple DispatcherServlet like beans related to the service layer and data access layer. In general, When you develop Spring MVC based web applications and also using Spring in the services layer, you need to provide two application-contexts. The first one is configured using ContextLoaderListener, and the other is set using DispatcherServlet. The DispatcherServlet is responsible for loading web component-specific beans like controllers, view resolvers, and handler mappings while, as I said before, ContextLoaderListener is accountable for loading middle-tier and data-tier beans which forms the back end of Spring applications.

How to enable HTTP Caching in Java Web application with Spring MVC? Cache-Control Header Example

One of the standard requirement in a secure Java web application is to disallow the back button of the browser or invalid the session if the user hit the back button of the browser. You might have seen this behavior while doing online banking or net banking, almost all the banks don't allow you to use the browser's back button. Your session gets terminated as soon as you hit the back button, and you have to log in again to do any transaction. Btw, have you ever checked some situations on your Servlet and JSP-based Java web application, like, if you pressed the back button of your browser after logging in, what happened? You will find that the browser takes you to the previous page.

Wednesday, March 15, 2023

What is @PropertySource Annotation in Java and Spring? PropertySource Example Spring Boot

Hello Java developers, if you are using Spring Framework or Spring Boot in your new project and wondering what is property source in Spring Framework and how to use @PropertySource annotation then you have come to the right place. Earlier, I have shared the best books and online courses to learn Spring Framework and in this article, I will teach you how to use @PropertySource annotation in Spring to read Environment variables and inject properties using @Value annotation. In the Spring application, one of the files that are needed to provide properties to the Spring environment is the @Configuration classes. 

Friday, March 10, 2023

How @Configuration, @Component, and @ComponentScan annotations works in Spring Framework? Component Scanning Example

Hello guys, if you are wondering how to does autowiring work in Spring Framework and how does Spring Framework find dependency in runtime then you have come to the right place. Earlier, I have explained How Spring MVC works and how Spring Security works, and In this tutorial, I will tell you how component scanning and auto-wiring works in Spring. You will also learn how to enable component scanning in a Spring application. When you develop a software application using spring, you need to tell the Spring framework where to look for Spring components. Using component scanning it is very much easier as this enables auto-detection of beans by spring container and smoothly.

Wednesday, March 8, 2023

What is YAML? How to define List and Map in YAML? Example Tutorial

Hello everyone, in this article we are going to take a look at how to use List and Map in YAML file. But before we jump into the topic. We start by defining the YAML document and why it is used. What advantages does it offer compared to the properties file?  But before that let's learn what is YAML? and how different it is from JSON and XML, two popular technology for configuration declaration. YAML stands for yet another markup language. YAML is a well-known programming language because it is simple to grasp and human-readable. Additionally, it can be combined with other programming languages. YAML is most extensively used in Ansible for declaring and defining playbooks.

Top 20 Python Interview Questions and Answers for 1 to 2 Years Experienced

Hello guys, if you are preparing for Python developer interview and looking for common and frequently asked Python Interview Question then you have come to the right place. Earlier, I have shared best Python courses, books, and projects and today, I am going to share best Python Interview questions with answer to get you the Python developer job you always wanted. Understanding python is easy if you choose to. What is needed is more and more practice. In this article you will find the questions that are frequently asked during python interviews. You have to take your time and go through the questions with answers and you will be more than prepared as far as python interview is concerned. 

Top 27 Dynamic Programming Interview Questions for Interviews

Hello guys, if you are preparing for tech interview or any Java developer interview then apart from preparing for Data Structure and Algorithms, and System Design, you should also prepare for Dynamic Programming questions. Dynamic programming or DP is a technique to solve a problem by breaking a big program into small sub-problem and then combining the result. It's very similar to Recursion and that's why Recursion also plays an important role in solving Dynamic programming questions.  When it comes to Interview, DP is one of the toughest topic to master.

Top 25 Linked List Coding Interview Questions for Java Programmers

Hello guys, if you are preparing for Software Development interview or want to become a Software Engineer then you must pay full attention to two important topics: first is Data Structure and Algorithms, and second is System Design. These two topics are very essential and you will always find questions from these in any coding interview. They are also the most difficult to crack as they are very vast, no matter how much you will prepare there will be certain questions which you don't know but if you have solid knowledge of fundamental data structure like array, linked list, binary tree, hash table, heap, and graphs as well sorting and searching algorithms like quicksort, merge sort, selection sort, insertion sort, binary tree as well advanced String and graph algorithms then you can still do well.

Saturday, March 4, 2023

How to read files from the resources folder in Spring Boot? Example Tutorial

Hello everyone, welcome to the blog post. In this article, we are going to take a look at a frequently asked question in spring boot on how to read files from the resources folder. A resource is any file that contains information relevant to your project, including configuration files, picture files, data files, or other types of files. In this article, we will look at various methods and techniques that both spring boot and ordinary Java code allow us to read a file from the resources directory. Our goal is not simply to list these approaches; rather, we will describe each strategy with the help of an example so that, everyone can easily grasp the topic. Without further ado, let's get started. 

Friday, March 3, 2023

Top 20 Advanced Java Questions on Anonymous Class, Nested Static and Inner Class for Interviews

Hello guys, static class and nested classes are one of the tricky topic to master in Java and that's why they are quite popular on Java Interviews. Not many Java developer knows about Anonymous class or how Lambda is compiled into Anonymous class by JVM etc. If you are going for Java Interview, I highly recommend you to prepare nested class topic well in Java. Just like in the past, I have shared many Java in-depth questions on different topics like Lambda Expression, Stream API, Generics, Collections, Multithreading, String, array, Design Patterns, OOP, Spring Framework, Hibernate etc,

Wednesday, March 1, 2023

8 Difference between TCP and UDP Protocol in Java? Networking Question

What is the difference between TCP and UDP is a popular networking question from Java interviews? Though TCP or UDP is Java independent concept and very likely to be asked in other programming language interviews as well, many programmers do not really understand them clearly. They sure have heard them because TCP and UDP are two of the most important transport protocol of the internet, but when it comes to listing down the difference between them, they fail to mention key differences in terms of ordering, guaranteed delivery, speed, and usage. 

Top 43 Java IO and File System Interview Questions with Answers for 1 to 3 Years Experienced

Good knowledge of Java IO API is important for any Java developer but many of them barely pay attention to Java IO and NIO API, and that's why they often struggle during Java interviews when a question related to Input-Output operation is asked. In the past, I have shared many Java interview questions on topics like Collections, Concurrency, JVM internals, Garbage Collection, OOP, Design Patterns, and Data structure based coding problems, which received good feedback and helped many Java developer on their Java Interview preparation. Consequently, many of my readers were also asking about Java IO and File-based interview questions and this was one of the pending items on my TODO list for quite some time.

Top 24 Java Date, Time, and Calendar Interview Questions Answers

The Date and Time API is a significant one for day-to-day Java development work, but many interviewers don't ask enough questions on this topic. Most of the questions are based on either Java Collection framework like  HashMap, ConcurrentHashMap, or ArrayList or multi-threading concepts like volatile, synchronized, and atomic variables. This is not good, and many interviewers have realized that a good understanding of date and time API is also important for a good Java developer. That's the main reason for increasing date, time, and calendar-based Java interview questions in recent times, particularly in the last couple of years.