Disclosure: This article may contain affiliate links. When you purchase, we may earn a small commission.

Difference between @Mock and @MockBean in Spring Boot? Example Tutorial

Hello guys, if you are writing test for your your Spring Boot application then Sooner or later, you'll come across @Mock and @MockBean annotations while testing your Spring Boot application. Both annotations generate fake or Mock  objects, but for different reasons and its important for Java and Spring Boot developer to know the correct difference and when to use @Mock and @MockBean while writing tests. It's possible that this will seem perplexing at first, in face I was confused for a long time until I did my research and cleared it up. But, you don't need to scan through internet, In this blog article, I'll clear up any misunderstandings and clarify the difference between @Mock and @MockBean when testing Spring Boot apps.

Top 25 DevOps Interview Questions and Answers for Experienced Developers

Hello guys, if you re preparing for DevOps Engineer interviews and looking for frequently asked DevOps Interview questions then you have come to the right place. Earlier, I have shared the DevOps RoadMapbest DevOps Courses, and DevOps books and in this article, I will share the frequently asked DevOps Interview Questions and their Answers. But, before we get to the most frequently asked DevOps interview questions, let me tell you what DevOps actually is. DevOps is basically a way of thinking or a collective approach to all the tasks that a company's application development and IT operation teams perform but it has taken the IT software development world by storm.

How to test a Spring Boot Application using JUnit, Mockito, and @SpringBootTest? Example Tutorial

Hello guys, if you are wondering how to test your Spring Boot application then you are at the right place. In the past, I have shared several Spring and Spring Boot resources like best Spring boot coursesbest Spring Boot booksSpring Boot Interview questions and even Spring Boot projects and in this article, I am going to share how to test your Spring Boot application using @SpringBoot annotation. This article will teach you essential concept for testing Spring Boot applications. It's expected that you are know about essentially the fundamentals of Java, Maven and Spring Boot (Controllers, Dependencies, Database Repository, and so on).

Top 20 Spring Data JPA Interview Questions with Answers for 3 to 5 Years Experienced Java Programmers

Hello guys, if you are preparing for Spring and Java developer job interview and looking for common Spring Data JPA interview questions then you have come to the right place. Earlier, I have shared spring boot questions, spring cloud questions, spring security questions, and spring MVC questions and in this article, I am going to share 20 common Spring Data JPA questions with answers. These are simple questions focused on key Spring Data JPA concepts like finder methods, query methods, pros and cons of Spring Data JPA, how to implement Spring Data JPA repository interface etc. If you have done work or used Spring Data JPA in your project then most likely you will be familiar with those concepts but if not then don't worry, you can also checkout these Spring Data JPA courses to learn them in detail. 

Top 20 Maven Interview Questions with Answers for Java Programmers

Hello guys, if you are preparing for Java developer interviews then you should not ignore Maven as its on of the important build tool for Java developers. Most of the Java projects you are going to work will use Maven for building artifacts and deploying into both Physical machine and cloud. If you already know the importance of Maven and looking for frequently asked Maven interview questions then you have come to the right place. Earlier, I have shared 130+ core Java questions, Spring Boot questions, Hibernate Questions, and even JUnit questions for thorough preparation and in this article, I am going to share 20 common Maven questions from Java interviews with answers. 

Top 20 Linux Interview Questions with Answers for 1 to 3 Years Experienced Developers

Hello guys, if you are preparing for Developer and DevOps interview and looking for Linux questions for interviews then you have come to the right place. Earlier, I have shared popular UNIX Interview questions and DevOps Interview Questions and in this article, I am going to share 20 common Linux questions from interviews with Answers. These questions covers essential Linux commands like Linux file system, permission model, Linux commands, shell and kernels etc. If you have worked in Linux then you can easily answer these questions but if you have forgot them then you can always join these best Linux courses to learn and revise key Linux concepts before interviews. 

Top 20 Docker Container Interview Questions Answers for Developers and DevOps

Hello guys, if you are preparing for DevOps Engineer interview or a Software developer job interviews like Java developer then preparing about Docker is a good idea. Docker has become an essential tool for packaging and deploying Software, particularly Microservices, and you can expect a couple of questions about Docker during Interview to check your knowledge. Having absolutely no idea of Docker before going into interview can be detrimental to your prospect considering the importance of container on deploying apps and services on Cloud. That's why I always programmers and developers to prepare Docker interview questions and revise key Docker concepts before interview. 

Top 40 Java HashMap Interview Questions and Answers for 3 to 5 Years Experienced

The HashMap and ArrayList is two of the most useful classes from JDK and every Java programmer should be familiar with them. Because of their usefulness, they are also very popular on Java interviews. You will always find a couple of questions on HashMap, ArrayList and its close cousins like Hashtable and ConcurrentHashMap on various Java interviews, ranging from freshers to experienced, junior to senior programmers, and telephonic to face-to-face interviews. To help my readers to better prepare for Java interviews, I have shared some of the essential ArrayList interview questions in my last article and today I am going to share  frequently asked questions on Java HashMap. 

Difference between State and Strategy Design Pattern in Java

Hello guys, if you are wondering what is difference between State and Strategy pattern in Java then you are at the right place. In order to make proper use of State and Strategy design Patterns in any Java application, it's important for a Java developer to clearly understand the difference between them. Though both State and Strategy design patterns have a similar structure, and both of them are based upon the Open closed design principle, which represents 'O' from SOLID design principles, they are totally different on their intent. The strategy design pattern in Java is used to encapsulate a related set of algorithms to provide runtime flexibility to the client. 

Decorator Design Pattern in Java with Example Java Tutorial

Hello guys, if you want to learn about Decorator design pattern in Java then you are at the right place. I was thinking to write on decorator design pattern in Java when I first wrote 10 interview questions on Singleton Pattern in Java. Since design patterns are quite important while building software and it’s equally important on any Core Java Interview, It’s always good to have a clear understanding of various design patterns in Java. In this article, we will explore and learn the Decorator Design pattern in Java which is a prominent core Java design pattern and you can see a lot of its examples in JDK itself. 

Data Access Object (DAO) design pattern in Java - Tutorial Example

Data Access Object or DAO design pattern is a popular design pattern to implement the persistence layer of Java application. DAO pattern is based on abstraction and encapsulation design principles and shields the rest of the application from any change in the persistence layer e.g. change of database from Oracle to MySQL, change of persistence technology e.g. from File System to Database. For example, if you are authenticating the user using a relational database and later your company wants to use LDAP to perform authentication. If you are using the DAO design pattern to access the database, it would be relatively safe as you only need to make a change on Data Access Layer. DAO design pattern also keeps the coupling low between different parts of an application.

How to use for loop in Linux? Looping through List, values, and range in Bash with Example

If you know how to use for loop in bash shell or Linux, you can speed up a lot of task, saving precious time while doing support or troubleshooting in Linux. One of my favorite use of for loop is repeating same task among multiple host. For example, If I have to clean up some files from 10 hosts in the network, instead of manually going and removing files from individual host, you can use for loop and ssh command to automatically remove old log files from all the host, without manually logging into them. This is a tremendous time saving trick if you are working for an application which is running on more than one host. It's a life-saver if your application is running on 30 to 40 hosts. 

What is SRP of SOLID Design Principle? Single Responsibility Principle Example in Java

Hello guys, if you want to learn about SRP or the Single Responsibility principle and wondering how to write code that follows SRP and what are pros and cons of following this design principle then you have come to the right place. Earlier, I have shared the best object-oriented programming and design courses and books and in this article, I am going to talk about SPR. The Single Responsibility Principles, popularly known as SRP is part of 5 Object-oriented design principles, introduced by Robert C. Martin, popularly known as Uncle Bob. The Single Responsibility principle says that "there should be one reason to change a class". This means a class should do only one thing, and do it perfectly.

Top 5 Online Courses to Learn Kubernetes in 2022 - Best of Lot

Hello guys, Kubernetes has become a very popular tool and skill today in the container management community, and it's one of the most in-demand skills and a must-learn tool for both DevOps engineers and Developers. It is a tool written in Golang and it is created by Google. There are many things you need to take care of when working in production environments with microservice patterns and containers. These include version control, health check, rollback mechanism, and scaling. Kubernetes provides the management and orchestration capabilities to deploy containers in accordance with all the necessary mentioned things.

How to Convert a Map to a List in Java - Example Tutorial

Hello guys, if you are wondering how to convert a Map like HashMap or TreeMap to a List like ArrayList or LinkedList in Java then you are at the right place. Earlier, I have shared 10 examples of converting a List to Map in Java and this article, I am going to share my tip to convert a given Map to a List in Java. Map and List are two common data structures available in Java and in this article, we will see how can we convert Map values or Map keys into List in Java. The primary difference between Map (HashMap, ConcurrentHashMap, or TreeMap) and List is that Map holds two objects key and value while List just holds one object which itself is a value. 

How to design Trade Position Calculator or Risk Engine in Java? Software Design Problem Solution Example

Hello guys, it's been a long since I shared object-oriented design and system design questions in this blog. It was almost 7 to 8 years when I last blogged about how to solve vending machine design problems in Java. Actually, I had ideas for lots of such design questions at that time, but because of the lengthy nature of these kinds of posts and the amount of time they take, they just sit on my list of drafts. I thought to take them out and publish then slowly improve on them instead of publishing the perfect post for the first time, and today, I am excited to share one of such problems, how to design a trade position aggregator in Java. This program is like portfolio management software that monitors your risk and exposure in real-time based on trades. 

Top 20 Kubernetes Interview Questions with Answers

Hello guys, if you are preparing for DevOps Engineer interview or a Developer interview, knowledge of Kubernetes is very important given the rise of Cloud computing and cloud native development. If you are looking for frequently asked Kubernetes interview questions to quickly revise key Kubernetes concepts then you have come to the right place. Earlier, I have shared 20 Docker Interview Questions and in this article, I am going to share frequently asked Kubernetes Interview questions with Answers. But, before we get to the 20 most important Kubernetes interview questions, let me tell you more about Kubernetes. In the most simple terms, Kubernetes is actually a bundle of software solutions that allow developers and engineers to scale and service server setups.

How to display full argument list of a Running Process in Linux and Solaris? Example

One of the problems with ps command, which is a popular tool to find any processes along with the grep command in the Solaris operating system is that it doesn't show full command-line argument of process. This means if you are doing grep on any text which appears at the tail end of the long command line, you will likely not able to capture that process by using ps and grep. This is dangerous because it may lead you to assume that certain process is not running and you may restart it again, despite its being running and only because you didn't find the process.

How to add element at the head and tail of a LinkedList in Java? Example

Hello guys, if you are wondering how to add an element at the start and at the end of a linked list in Java then you are at the right place. LinkedList is an implementation of linked list data structure in Java and whenever you need a linked list you can use this. It also provides convenient methods to add elements like addFirst() to add any element at the fist position and addLast() to add element at the last position or tail of the linked list. Since LinkedList also implement List and Queue interface in Java, you can also use the common methods defined in the List and Queue interface to interact with LinkedList object in Java. In the past, I have also shared how to sort a LinkedList in Java and in this article, I will teach how you can use LinkedList in Java and how you can add object at the head and tail position of a linked list in Java. 

10 Linux Commands and Options Every Developer should Learn

Hello guys, you might have read many articles about popular Linux commands on the internet but this article is a bit different. In this article, I am going to share some lesser-known options of essential Linux commands like find, grep, mkdir, etc, which many Linux users, including programmers, don't know, even after using the command for quite some time. For example, cp -p is an option that I discovered quite late but ever since I discovered it I have been using it regularly as it preserve timestamp and I can see when this file was originally created. I am going to share 10 such Linux command examples in this post, which I am sure you will love it and if you already know them, then there is a good chance that you have something similar to share with us in the comments section. 

10 Example of find command in UNIX and Linux

The find command is one of the most versatile commands in UNIX and Linux, and I used it a lot in my day-to-day work. I believe having a good knowledge of find command in UNIX and understanding of its different options and usage will increase your productivity a lot in UNIX based operating systems, e.g. Redhat Linux or Solaris. If you are a QA, support personnel, and your works involve lots of searching text on Linux machine or if you are a Java or C++ programmer and your code resides in UNIX, find command can significantly help you to look for any word inside your source file in the absence of an IDE.

How to use mkdir command to make directories in Linux and UNIX? mkdir -p Example

One of the most common tasks in any Linux is creating directories, and most of us spend a lot of time creating complex directory structures in UNIX and Linux.  I am sure you know about the mkdir command, we have been using this command in almost every operating system like DOS, Windows, Linux, OS/2, Solaris, or any other *NIX operating system. It is one of the basic commands but as important as find, grep or chmod.  mkdir stands for "make directory" and this command is literally used to create directories. Suppose, you need to create a directory tree-like /opt/software/java/app/config, how are you going to create these directories? One by one right? Well, yes you can use mkdir and command to create these directories one by one as shown in below example :

Top 5 Software Design Courses for Programmers in 2022 - Best of Lot

Hello guys, if you are preparing for technical interviews for Software Engineering job then you may be aware of  Software Design or System design. It is one of the most important but at the same time very tough topic to master and many programmers even experienced developer struggle to solve System design problems during interview, particularly while interviewing with top tech companies like Google, Meta, Amazon, Apple, Microsoft, Netflix etc, popularly known as FAANG. If you are also preparing for programming job interview and looking for best System design and Software design resources then you are at the right place. Earlier, I have shared best System Design Books, System Design Questions and best Places to learn System Design and in this article, I am going to share best System Design Interview courses from Udemy, one of my favorite place to learn programming and technical stuff. 

How hostname to IP address Conversion works in Linux? nslookup Example

One of my favorite Linux Interview questions is about how to convert hostname to IP address in Linux? These questions not just test the candidate's basic Linux command skills but also shows his understanding of how name resolution works in UNIX or Linux? Many developers, software engineers, and support professionals don't really know how Linux converts a hostname into IP address or what happens when they type http://www.amazon.com in their browser in UNIX? They are not really familiar with how the name amazon.com is resolved to an IP address.

How to Delete Empty Files and Directories in UNIX or Linux Host? find Command Example

Deleting empty file and directory in Unix
Hello guys, if you are wondering how to find and remove all empty files and directories from a Linux host then you are at the right place. Earlier, I have shared Linux command to free disk space by removing big files and directories and in this article, I will share find command you can use to remove empty files and directories. Many times we need to find and delete empty files or directories in UNIX/Linux. Since there is no single command in Unix/Linux which allows you to remove empty files or empty directories rather we need to rely on find command and xargs command

How to find big directories and files to free space in Linux? find + du + sort + head command Example

Hello guys, 100% full disk space is a common problem and as a programmer or Linux user, you often need to free disk space by deleting biggest files and directories. In order to do that, you need to know some Linux find command examples to list and delete some biggest files and directories and that's what you will learn in this tutorial. As a Java developer, you also need to also support your application, most of which mostly run on Linux machines. Though production is monitored by the dedicated support teams and they receive regular alerts on the status of file system space, they often come running to you or the developer responsible about what to do when disk space is almost full or reaching 100%.

How and when to use var to declare local variables in Java? Example Tutorial

Hello guys, In this series of new features of Java 10 articles, today, I am going to talk about probably the most popular and most useful, the introduction of var keyword (well, it's not really a keyword but I'll you later about it) in Java. If I am not wrong, this feature was supposed to come on Java 9 but dropped later. Finally, Java also has a var keyword to declare local variables which allows you to declare a variable without their type like instead of doing String str = "Java" you can now just say var str = "Java". This may not sound much gain when declaring String or an int variable but consider complex types with generics, this will surely save a lot of typing and also improves the readability of code.

How to merge two sorted array in Java? Example Tutorial

Hello guys, if you want to learn how to merge two sorted arrays in Java then you have come to the right place. Earlier, I have shown you how to sort arrays in Javaand in this article, I will show you how to merge two sorted arrays in Java. Btw, if you are a complete beginner then Firstly, you need to know what an array is before going about solving this problem about sorted array.  An array is a data structure in java that holds values of the same type with its length specified right from creation time. Think of a container, like a crate of eggs or coke, where number of places are fixed and you cannot change once you created it.

How to convert an Array to HashSet in Java? Example Tutorial

The array was there in Java before the Collection framework makes its entry in JDK 1.4, hence, you will find several legacy codes, which accept an array then the Collection or Set. Due to this, we often need to convert an array to different types of collection e.g. List or Set. Earlier, I have told you the trick to convert an array to a list and today I'll teach you how to convert an array to HashSet by using the same technique. The concept you need to know is that Collection provides a copy constructor i.e. you can pass a collection to create another collection. We'll leverage the same fact and to create a HashSet, we'll pass an ArrayList.

List.of(), Set.of() and Map.of() Example in Java - How to create Immutable Map, List, and Set in Java

Hello guys, this is my first article in Java 9 features on this blog, and today you'll learn about my favorite feature "factory methods for collection", which is introduced as part of JEP 269. The JEP stands for the JDK enhancement proposal. If you have worked in Groovy or Kotlin then you know that how easy is to create the list with elements using collection literals e.g. to create a list of 1, 2, 3 you can simply write val items = listOf(1, 2, 3). Unfortunately, Java doesn't support that yet but things have been improved with the factory methods for collection in JDK 9 and it's almost like that. JDK has added static factory methods like of() on to basic Collection interfaces which you can use to create a list of items.

Difference between HashMap, LinkedHashMap and TreeMap in Java with Example

Hello guys, if you are wondering what is difference between HashMap, TreeMap, and LinkedHashMap in Java and when to use them then you are at the right place. In past, I have shared frequently asked HashMap Interview questions and ConcurrentHashMAp Interview questions and today, I Will answer this question in detail. The java.util.Map is one of the most important interfaces from the Java Collection Framework.  It provides hash table data structure functionality by its implementations like HashMap, Hashtable, LinkedHashMap, and a little bit of sorting with the TreeMap. So if you are looking to store key-value pairs in the Java program,  you have a wide range of choices available depending upon your requirement. The main difference between LinkedHashMap, TreeMap, and HashMap comes in their internal implementation and specific features, which a Java programmer should know to use them effectively. 

How to use @RequestBody and @ResponseBody Annotations in Spring? Example Tutorial

Hello Java programmers, if you are wondering how and when to use use the @RequestBody and @ResponseBody annotation in Java then you are at the right place. Earlier, I have shared how to create RESTful Web Service using Spring Boot and today I will teach you how and when to use these two crucial annotations @RequestBody and @ResponseBody. While developing client server Java application using Spring Framework you may need to connect the HTTP request and response body with the domain object while working on the REST API. The annotations @RequestBody and @ResponseBody in Spring were used to bind these HTTP requests and responses. In simple words, these are teh annotations which converts JSON to your Java object and your data to JSON while sending to client. Let's look at these two Spring annotations in more detail.

Why use @Override annotation in Java? Coding Best Practice Example

@Override annotation was added in JDK 1.5 and it is used to instruct the compiler that method annotated with @Override is an overridden method from super class or interface. Though it may look trivial @Override is particularly useful while overriding methods that accept Object as a parameter just like equals, compareTo or compare() method of Comparator interface. @Override is one of the three built-in annotations provided by Java 1.5, the other two are @SuppressWarnings and @Deprecated

4 Example to Iterate over Map, HashMap, Hashtable or TreeMap in Java

There are multiple ways to iterate, traverse or loop through Map, HashMap, or TreeMap in Java and we are all familiar with either all of those or some of those. But to my surprise, one of my friends was asked in his interview (he has more than 6 years of experience in Java programming) to write code for getting values from HashMap, Hashtable, ConcurrentHashMap, or TreeMap in Java in at least 4 ways. Just like me he was also surprised by this question but written it. I don't know why exactly someone asks this kind of java interview question to a relatively senior java programmer. Though my closest guess is to verify that whether he is still hands-on with coding in java. 

Java HashMap ContainsKey and ContainsValue Example - How to check if a Key Exists in Map?

Hello guys, one of the common problems many Java developers working with HashMap face is how to check if the Map contains a particular key or value? You can use this to check duplicate keys or just to ensure that you are not overriding the current value because if you insert a key that already exists in the HashMap, then you end up overriding its value. Since HashMap also allows duplicate values, it's also possible that the same value may be paired against multiple keys, so just removing a mapping may not be enough to remove that particular value. Not paying attention to these details has actually caused issues in the Java applications.

How to get Key From Value in Hashtable, HashMap in Java? Example

It's not easy to get key from the value in Hashtable or HashMap, as compared to getting value from key because HashMap or Hashtable doesn't enforce one to one mapping between key and value inside Map in Java. in fact, Map allows the same value to be mapped to multiple keys inside HashMap, Hashtable, or any other Map implementation. What you have in your kitty is Hashtable.containsValue(String value) or Hashtable.containsKey(String key) to check whether key or value exists in HashMap or not, but sometimes we want to retrieve a value from Map corresponding to any key and there is no API method to do in Map.

How to Sort a List in Reverse Order in Java? ArrayList Example

Java Collection Framework provides a convenient reverse comparator, to sort a List of objects in reverse order.  You can obtain reverse Comparator, by calling Collections.reverseOrder(), which by default sort List of Integer in reverse numeric order and List of String in reverse alphabetic order. It actually reverses the natural ordering of objects imposed by the Comparable interface. Apart from this method, Collections class also provides an overloaded method Collections.reverseOrder(Comparator cmp), which takes a Comparator, and sorts List on reverse order of that Comparator.

10 Examples of HashSet in Java - Tutorial

HashSet in Java is a collection that implements the Set interface and is backed by a HashMap. Since HashSet uses HashMap internally it provides constant-time performance for operations like add, remove, contains and size give HashMap has distributed elements properly among the buckets. Java HashSet does not guarantee any insertion orders of the set but it allows null elements. HashSet can be used in place of ArrayList to store the object if you require no duplicate and don't care about insertion order.

Java 8 ParallelStream Example - Sequential vs Parallel Sorting in Java

Hello guys, If you have been coding in Java for a long time then you know that how hard it is to make an algorithm run parallel. You need to create multiple threads, make sure that they are properly synchronized and then need to co-ordinate between them to make it faster. But from Java 8, you can use parallel streams to improver performance of your CPU intensive algorithms. Stream API allows you to run the stream operation in parallel by just calling parallelStream() method. This is as simple as it can be to make your code take advantage of CPU power and run faster. You don't need to worry about creating or starting threads or coordinating between them. Just call this method and everything is done for you.

Difference between HashMap and IdentityHashMap in Java? Example

Hello guys, if you are wondering what is differnece between an HashMap and IdentiyHashMap in Java then you are at right place. IdentityHashMap in Java was added in Java 1.4 but still, it's one of those lesser-known classes in Java. The main difference between IdentityHashMap and HashMap in Java is that IdentityHashMap is a special implementation of Map interface which doesn't use equals() and hashCode() method for comparing objects unlike other implementations of Map e.g. HashMap. Instead, IdentityHashMap uses the equality operator "=="  to compare keys and values in Java which makes it faster compared to HashMap and suitable where you need reference equality check and instead of logical equality.

Difference between bitwise and logical AND, OR Operators in Java? Examples

Java beginners often ask the same type of questions, and of them is what is the difference between & and && operator in Java or the difference between | and || operators? The standard answer to this question is well, the main difference between & and && is that the former is a bitwise operator, and && is a logical operator in Java. That's academic until you clearly explain the difference in working of & and && or | and ||. For absolute beginners, & is used to represent AND logic operation in Java and | is used to represent OR logic operation.

What is NavigableMap in Java ? TreeMap, headMap, tailMap, and subMap Examples

Hello guys, if you are wondering what is NavigableMap and why should Java developer know about it you are at right place. NavigableMap in Java is an extension of SortedMap  like TreeMap which provides convenient navigation methods like lowerKey, floorKey, ceilingKey, and higherKey. NavigableMap is added on Java 1.6 and along with these popular navigation methods it also provides ways to create a Sub Map from existing Map in Java, like headMap whose keys are less than the specified key, tailMap whose keys are greater than specified key and a subMap which strictly contains keys that falls between toKey and fromKey

Is Java Compiled or Interpreted Programming language? Answer

One of the first question a graduate C or C++ programmer, who has just started learning Java ask is, whether Java is a compiled language or an interpreted one? On academic courses or during college, students learn a lot of languages like VB, C, C++ and they happily categories them as either compiled or interpreted, but with Java it's tricky. It's not clear whether Java is compiled or interpreted, because it neither generates machine language code after compiling a source file,  neither interpreted source file to execute instruction line by line. 

Why use SerialVersionUID inside Serializable class in Java? Example

Serialization and SerialVersionUID always remain a puzzle for many Java developers. I often see questions like what is this SerialVersionUID, or what will happen if I don't declare SerialVersionUID in my Serializable class? Apart from the complexity involved and rare use, one more reason for these questions is Eclipse IDE's warning against the absence of SerialVersionUID e.g. "The Serializable class Customer does not declare a static final SerialVersionUID field of type long". In this article, you will not only learn the basics of Java SerialVersionUID but also its effect during the serialization and de-serialization process. 

Is it possible to have an abstract method in a final class? Example

This is one of the interesting core Java questions which was asked to one of my readers recently during a telephonic interview for a Java developer job interview. Even though he knows that you cannot make an abstract class final in Java, he got confused by the wording of the methods. The answer is simple, No, it's not possible to have an abstract method in a final class in Java. Why? because as soon as you declare an abstract method in a Java class, the class automatically becomes an abstract class and you cannot make an abstract class final in Java as discussed before, hence it's not possible to have an abstract method in a final class in Java.

How to send POST Request with JSON Payload using Curl Command in Linux to Test RESTful Web Services?

There are many ways to test your RESTful Web services developed using Spring MVC e.g. you can use RESTAssured for automation testing or you can use Postman to manually test your RESTful Web service but nothing beats the elegant, comfort, power, and simplicity of using curl command to test RESTful web service. It is my favorite tool to test any RESTful web service and I have used in past to test various aspect of Spring REST application e.g. testing headers, testing authentication and authorization, testing different content types like JSON and XML, testing cookies, and testing different HTTP methods to perform CRUD operations. 

How to use ConcurrentLinkedDeque in Java? Example Tutorial

Hello guys, ConcurrentLinkedDeque is another amazing class from Java's concurrent collection package which can be used as high-performance, thread-safe and non-blocking data structure. As the name suggest, its a Deque which means its allows you to operate at both ends of queue. You can insert at one end and consume from other end. It's also concurrent and thread-safe which means multiple threads can operate on same queue at the same time. You can have multiple producer threads which are inserting data into the queue and multiple consumer threads which are consuming data from this data structure.  

Object Oriented Programming Example in Java? Tutorial

I remember when I was doing my engineering, the OOPS concept was in the first semester. Back then it looks like some alien things to me, because I have never done programming and even the smallest program we get to write like checking whether the number is palindrome or not, or printing the Fibonacci series, we never really needed to use OOPS. When needed, I just memorize things and write them down in exams :). That worked, I passed the exam but effectively I didn't learn OOP or Object Oriented Programming on those days.

Difference between Class, Instance and Local variables in Java? Example

There are a lot of differences between instance variable, class variable, and local variable in Java, and knowing them will help you to write correct and bug-free Java programs. Java is a full-featured programming language and provides different kinds of variables like static variables also called Class variable since it belongs to whole Class, non-static also called instance variable and local variables which vary in scope and value. Thank god Java doesn't have any register variable or auto scope like C Programming language, otherwise it would have so much detail to remember. static variables are a common source of error in may multi-threaded java program and does require a bit of carefulness while using it. On the other hand instance, the variable and the local variable have less sharing visibility than a static variable.

Method Overloading in Java and Object Oriented Programming?

Many programmers, including Java and C++ developer, knows about the object oriented programming concepts like method overloading or function overloading, but if you ask them why you should overload a method? Many of them become clueless. This is a common problem of half learning i.e. you know the concept but you don't know the application. If you neither know what problem it solves nor what benefit it provides, then just knowing the concept is not enough. You won't be able to reap all benefits if you just know the concept and never use that in practice. If you are wondering what is the real use of method overloading then don't worry, I will share the answer in this article. Btw, this is also one of the popular object oriented programming interview question and its good to know about it. 

Can you declare Abstract Class or Method Final in Java? If not, why?

If you are wondering whether you can use both abstract and final modifier together with a class or method in Java then you are not alone. This is one of the frequently asked, theory based Java questions which is sometime tricky to answer, particularly if you don't have complete knowledge of Java fundamentals. The answer of this question is No, you can not declare abstract class or method final in Java because both abstract and final keywords are mutual exclusive. Anything which is abstract cannot be final and vice-versa. It's like a person cannot be living and dead at the same time.

Top 40 Object Oriented Programming [OOP] Interview Questions Answers in Java

OOP Interview questions or Object-oriented programming and design interview question are an integral part of any programming job interviews like Java, C++, or C#. Since Java is an Object-oriented programming language, it's expected from Java developers that he is good at Object-oriented analysis and design and familiar with essential OOP concepts like Abstraction, Encapsulation, and Polymorphism. Object-Oriented Programming Interview question in Java is mainly based around fundamental OOP concept and how those are implemented in Java, like Abstraction OOP concept is implemented using an interface and abstract class, Encapsulation is using private keyword, etc.

Top 20 Stack and Queue Data Structure Interview Questions for 1 to 3 years Experienced

Both Stack and Queue are two of the crucial data structure which is very useful in solving a lot of problems. They are not as fundamental data structures as an array or linked lists but they offer some unique advantages in terms of how you store and access elements. Stack is commonly known as LIFO data structure because the last element you put is the first one to come out while Queue is known as FIFO data structure. The elements are retrieved from the queue in the order they were inserted. Both of these data structure has several usages and are used to solve many common problems and to implement algorithms. 

Top 10 Hibernate Interview Questions and Answers for Java Developers - 3 to 5 Years Experienced

Hibernate Interview Questions are asked on Java J2EE Interviews, mostly for web-based enterprise application development roles. The success and acceptability of Hibernate framework on the Java world have made it one of the most popular Objects Relational Mapping (ORM) solutions in the Java technology stack. Hibernate frees you from database-specific coding and allows you to focus more on utilizing powerful object-oriented design principles to implement core business logic. By using Hibernate you can switch between databases rather easily and also take advantage of out-of-box caching facilities provided by Hibernate, in terms of second-level cache and query cache.

50+ Java Collections and Generics Interview Questions with Answers

Hello guys, If you are preparing for Java interviews then you may know that Java Generics and Collections are two of the most important topics, particularly Generics where some of the trickiest Java questions can be asked. They are also used to gauge your experience and depth of your Java knowledge, hence it's imperative for both beginners and experienced Java programmers to prepare this topic well. While the Java Collection framework provides an implementation of some command data structures like ListSetArray, Hash table, Queue, Stack, PriorityQueue, etc, Generics provides Type safety.

How to Iterate Over Rows and Cells of Excel file in Java - Example

Hello guys, if want to iterate over all the rows in a excel sheet inside your Java program to process data row by row for example copying from Excel file to Database and you are looking for a pure Java solution then you have come to the right place. Earlier, I have shared how to read from excel file and how to write into Excel file in Java and today, I will show you how to go over all the rows in a Excel file one by one. We will use Apache POI, a popular core Java library to work with Excel files. It support XLS, XLSX and other open office Excel file formats. The library is also open source so you don't need to buy any license or pay for it. All, you need is to include the JAR file in your application's classpath.

10 Free Courses to Learn System Design and Software Design in 2022 - Best of Lot

Hello guys, if you are preparing for System Design Interview or just want to improve your Software design skills and looking for best free resources like tutorials and free online courses then you have come to the right place. In the past, I have shared best System design coursesbookswebsites, and popular System design questions but a lot of you asked for free resources and that's why I am going to share best free System design courses I found online. These online courses are completely free and provides a diverse knowledge about different System design concepts and process. They are also created by experienced trainers and teacher who has gone through the same process and available on trusted online platforms like Udemy and YouTube. You can join one or more of these free System design courses to not only improve your Software design skill but also to prepare for your next System Design Interview. 

Top 5 Websites to Learn System Design and Software Design in 2022

Hello guys, if you are preparing for System design Interview and looking for best resources to master Software design and System design then you have come to the right place. Earlier, I have shred best System Courses, Books, and System Interview Questions and in this article, I am going to share best places to learn System design in 2022. Before we get to the best websites that will teach you everything you need to know about system design, let me tell you a little bit about what it really is. Systems design is basically the process of defining elements of a system including modules, architecture, components, interface, and data for a system based on a specific set of requirements. It can also refer to the process of defining, developing, and designing systems. These designs have to satisfy the specific needs of a company or an organization.

How to Learn Kubernetes, AWS, Azure, and Google Cloud using Whizlabs Hands-on Labs ?

Hello guys, Cloud computing is rapidly becoming one of the essential skill for all kind of developers and no matter what you will need to learn Cloud Computing if you want to remain marketable. I learned this truth couple of years ago and since then spent a lot of time learning AWS, Azure, Kubernetes, Docker, and Google Cloud Platform. The big problem with learning Cloud computing and different cloud platform like AWS and Azure is that you cannot learn them by reading books or watching course. You need real, hands-on practice which can only be possible by either using the free tier of respective platform or using hands-on labs like the one provided by Whizlabs and QwikLabs.  In this article, I am going to review Whizlab's comprehensive offering of hands-on labs to learn Cloud related technologies like Kubernetes, AWS, Azure, Openshift, Google Cloud Platform and Snowflake better.

Difference between Checked vs Unchecked Exception in Java? Example

Checked and Unchecked Exception is two types of Exception exist in Java. Though there is no difference in functionality and you can very achieve the same thing with either checked Exception or Unchecked Exception, there is some difference on exception handling part. In this Java tutorial we will see what is checked and Unchecked Exception in Java, Examples of Checked and Unchecked Exception and most importantly we will learn when to use Checked Exception and when to use Unchecked Exception in Java and lastly we will see the difference between checked and unchecked exception to understand things better. 

[Solved] How to solve java.lang.UnsatisfiedLinkError: no ocijdbc11 in Java with Oracle 11g, 12c, 19c and 21c

"java.lang.unsatisfiedlinkerror no ocijdbc11 in java.library.path" error comes when you try to connect to Oracle 11g database using OCI (thick) driver by using tns name, but the ocijdbc11.dll file is not available in PATH or java.library.path environment variable. ocijdbc11.dll is a native library and if you know Java searches native library in PATH or a location specified by java.library.path system property, if it doesn't find the dll, then it throws java.lang.unsatisfiedlinkerror no ocijdbc11 in java.library.path error. This dll is usually found in C:\Programs\Oracle\ora11g\bin\ocijdbc11.dll, but it could vary depending upon your Oracle installation.

How to deal with NullPointerException in Java with Examples - java.lang.NullPointerException Guide

The java.lang.NullPointerException or NullPointerException in Java is probably the first error or exception you will face in Java. It is a true nightmare for beginners in Java but pretty easy to solve once you get familiar with Exception handling in Java. What makes NullPointerException a little bit tricky to solve is its name which has a pointer in itself and Java does not support pointers like C++ or C, just like you don't have multiple inheritances in Java. As a Java developer with 20 years of experience, I have solved countless amount of NullPointerException and now I have developed a coding and debugging sense through which I can spot what causing a particular NullPointerException and how to fix it. 

How to use @EnableTransactionManagement in Spring Framework and Spring Boot? Example Tutorial

Spring Boot has a lot many annotations within its framework that a person can use. If you are searching for one, you have come to the right place. Needless to say, these annotations are essential for building a Spring Boot web application. Today we will look at an annotation that is widely used for transaction management in spring. So, what's the wait?! Let's start! But, before jumping into the sea of spring, let's first understand what a transaction means in spring and what it signifies. A transaction is used in Spring JPA which communicates to the database. we all know what a transaction represents on a database level. If not, no worries! let us all recall.

How to Fix 'javac' is not recognized as an internal or external command in Windows and Linux? Example

Hello guys, if you are trying to compile your Java source file and getting "'javac' is not recognized as an internal or external command" in Windows or Linux machine like Windows 10 or Redhat 8 but not sure what to do then you have come to the right place. This is a common Java related error and can occur to an operating system like Windows, Mac or Linux if java is not installed properly like only JRE is installed and JDK is not installed or javac is not added on PATH environment variable. In this article, I will explain what this error is and how you can fix it by following step by step guide I share, but if you still cannot solve this problem on your own then just ask for help in comments. But don't forget to check your PATH environment variable because that's where JDK/bin directory needs to be present, which contains all Java related commands including "javac" and "java" which are used to compile and run Java applications.

[Solved] How to fix VirtualBox - /sbin/mount.vboxsf: mounting failed with the error: Protocol error

Virtual box is a great tool for Java developer to run Docker and Linux on Windows Machine, especiall for them who need to develop and debug Java program in Linux environment. I use Oracle's virtual machine, VirtualBox to run the Linux operating system from my Windows machine. It's the most simple way to have two operating systems on your laptop or PC. Since I run most of the Java programs in Linux, VirtualBox gives me a nice interface to run UNIX commands right from the Windows box. This blog post is about the mounting of a shared folder failed error in Oracle's Virtualbox VM. It was working fine the day before yesterday and now, after I restarted my virtual box and tried to mount my shared folder, I was greeted by this error: "/sbin/mount.vboxsf: mounting failed with the error: Protocol error"

How to fix java.lang.UnsupportedClassVersionError: Bad version number in .class files? Example

How to fix Bad version number in the .class file
"java.lang.UnsupportedClassVersionError: Bad version number in .class file" is a common error in Java programming language which comes when you try to run a Java class file which was compiled by different version of Java compiler than then JRE version you are using to run it. In our last article, we discussed that how to resolve Java.lang.UnSupportedClassVersionError and found that it comes when a major and minor version of the class is not supported by Java virtual machine or JRE running the program. Though "java.lang.UnsupportedClassVersionError: Bad version number in .class file" is a little different than that of its manifestation and Cause, both are related to the mismatch in compiler javac and runtime java version. 

How to Fix Must Override a Superclass Method Error Eclipse IDE Java | @Override annotation with interface methods

One of the annoying error while overriding Java method in Eclipse IDE is must override a superclass method error, This error is quite frequent when importing Java projects and after so long, still I haven't seen any permanent solution to it. Must override a superclass method the error comes in Eclipse if you have Java Class that implements interface and overrides a method from interface and uses @Override annotation. Unfortunately, Eclipse defaults to Java 1.5, which only recognize @Override annotation for the overriding method from the superclass and not from the interface.

How to fix "No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK" in Eclipse & Maven?

If you are like many Java developer who uses Maven and Eclipse to build Java project using M2Eclipse plugin, you might have seen this error before. I ran into it recently when I ran the Maven Install command for one of the Java projects, configured as Maven project,  only to realize that Maven builds failed after throwing this error. The main reason for this error is that Maven is not able to find javac (the Java compiler) which is required to compile Java source files. If you remember, the javac command comes in the bin directory of JDK, hence, you need a JDK installation in your local machine to compile the Java project.

How to fix java.sql.SQLException: Invalid column index? Example

"java.sql.SQLException: Invalid column index" is a frequent error while working in Java Database Connectivity (JDBC). As the name suggests "Invalid column index" its related to accessing or setting column in your SQL Query using prepared statement in Java. I have seen "java.sql.SQLException: Invalid column index" coming mostly due to two reason:

1) Setting column data using setXXXX(int coloumIndex) e.g. setInt(0) setString(0)
2) Getting column data using getXXX(int columnIndex) e.g. getInt(0) getString(0)

The most common cause of "java.sql.SQLException: Invalid column index" is a misconception that column index started with "0" like array or String index but that's not true instead column index starts with "1" so whenever you try to get or Set column data with column index "0" you will get "java.sql.SQLException: Invalid column index".

FIX Session is not connecting how to diagnose it? Example Tutorial

In this blog post of the FIX protocol tutorial series I would like to share my experience with connectivity issues around Fix Engines. to exchange messages or say to trade electronically clients connect to the broker using FIX protocol and for that, they use FIX Engine. In FIX protocol connection between two FIX Engines is refereed as FIX Session and we normally say whether FIX Session is connected or not connected. FIX Session normally has their start time, end time, and EOD time (End of day time) also called TradingSession start time, Trading Session End Time, and Trading Session EOD time.

How to fix java.lang.ClassNotFoundException: com.sun.jersey.spi.container.servlet.ServletContainer? [Solution]

The error message clearly says that the Java runtime is not able to find a class called ServletContainer for the Jersey library. This is the Servlet class you have specified in the deployment descriptor of your application. It's similar to DispatcherServlet of Spring MVC and this error is similar to the error you get when DisplayServlet was not in the classpath.
Anyway, java.lang.ClassNotFoundException: com.sun.jersey.spi.container.servlet.ServletContainer comes when you are trying to use Jersey but have not added required dependency on your classpath e.g. those JAR files which contain the class "com.sun.jersey.spi.container.servlet.ServletContainer".

How to Fix java.net.SocketException: Failed to read from SocketChannel: Connection reset by peer? Example

You might have seen the java.net.SocketException: Failed to read from SocketChannel: Connection reset by peer error while working with Java NIO based server which is using SocketChannel instead of InputStream for reading data from the network. In general, this can come at both client and server end of a client-server Java application which is using TCP/IP to connect each other. Though this exception usually comes at the server end and the client was complaining that they are not able to connect. 

How to Fix java.lang.OutOfMemoryError: GC overhead limit exceeded Error in JVM [Solution]

Hello guys, if you are getting  java.lang.OutOfMemoryError: GC overhead limit exceeded Error in your Java application and wondering how to solve this then read on. As suggested by Java virtual machine, java.lang.OutOfMemoryError: GC overhead limit exceeded error comes when JVM breached GG overhead limit; which means your application is spending too much of garbage collection time without freeing any meaningful space. Currently Java's HotSpot virtual machine throws "java.lang.OutOfMemoryError: GC overhead limit exceeded" when 98% of total time is spent in the garbage collection and less than 2% of heap memory is recovered. Now let's find out what are symptoms of this error? Before this out of memory error comes you will see very slow or hung Java application with high CPU usage, because your application is only doing GC. 

16 Essential Java ArrayList Examples for Beginners - Tutorial

Most of the Java interview questions on ArrayList asked freshers or Java developers with 1 to 2 years experience is just simply how to do tasks like how to sort ArrayList in Java, How to sort ArrayList in ascending and descending order, how to sort ArrayList on reverse order, how to search elements, how to remove an element using iterator etc. Since, I have written lots of Java tutorials on ArrayList, covering many general-purpose tasks like how to create an object of ArrayList and initialize to how to sort ArrayList in ascending and descending order, etc. 

How to empty an ArrayList in Java? clear() vs removeAll() method Example Tutorial

Many times we want to reset an ArrayList for the reusing purpose, by resetting we mean clearing it or removing all elements. There are two ways to reset an ArrayList in Java, by using the clear() method or calling removeAll(). If your ArrayList is small enough like it contains only 10 or 100 elements then you can use any of these two methods without worrying too much, but, if you have a huge list of lots of objects like an ArrayList containing 10M entries, then the choice of clear() vs removeAll() can make a huge difference in the performance of your Java application.

How to loop or Iterate over ArrayList in Java? Iterator, ListItreator, for loop and Enhanced foreach example

Looping ArrayList in Java or Iteration over ArrayList is very similar to a looping Map in Java. In order to loop ArrayList in Java, we can use either foreach loop, simple for loop, or Java Iterator from ArrayList. We have already touched iterating ArrayList in 10 Example of ArrayList in Java and we will see here in detail. We are going to see examples of all three approaches in this ArrayList tutorial and find out which one is clean and the best method of looping ArrayList in Java. Before start writing an example for loop in ArrayList let's think about why do we need to iterate, traverse or loop an ArrayList if it’s based on the index and backed by Array.

Coursera Review - Is the Meta Frontend and Backend Developer Certificates Worth It?

Hello guys, if you want to become a frontend or backend developer in 2022 and looking for a well structured, reputed, and completely online program then Meta's Frontend and Backend developer certificates on Coursera are great place to start with. The Certifications will come from Meta, parent company of Facebook (similar to how the Certificates come from Google in the Google Professional Certificates) and they are taught by expert Software engineers of Meta. This means you will not only learn the latest tech skills which are highly looked after by employers but also you will get a chance to learn from best people in the world. But, what separate this professional certificate on Coursera form others is the access to Meta Job board

Difference between a List and Array in Java? ArrayList vs Array Example

Hello there, if you are wondering what is the difference between a list and an array, or particularly an ArrayList and an Array in Java then you have come to the right place. Earlier, I have shared the best data structure and algorithm courses and in this article, I will explain to you the differences and similarities between a list and an array in Java.  Both array and ArrayList are two important data structures in Java and frequently used in Java programs. Even though ArrayList is internally backed by an array, knowing the difference between an array and an ArrayList in Java is critical for becoming a good Java developer. If you know the similarity and differences, you can judiciously decide when to use an array over an ArrayList or vice-versa. 

Top 20 JSON Interview Questions with Answers for Beginners and Experienced Developers

Hello guys, if you are doing for a web developer interview or a Java web developer interview where you need to write server side application or backend code which uses HTTP to send and receive data then you should prepare about JSON. It's one of the most popular way to exchange data between two systems or between frontend and backend, client and server and most of the top programming language has API to create and parse JSON like Java has Jackson and JavaScript can by default support JSON because its nothing but JavaScript Object Notation.  JSON is also the default data format for REST API  and even GraphQL uses JSON to send request and receive response.