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

How to Implement Double Checked Locking Singleton Pattern in Java? Example Tutorial

Double-checked locking pattern is one of the interesting topics in Java Interviews. Earlier, it was asked to see if a Java developer can write code using a synchronized block or not, and now it asks to gauge the candidate's understanding of concurrency, volatile, and synchronization in Java. One of the simplest ways to write thread-safe Singleton was to make the getInstance() method synchronized but prior to JDK 1.6, a simple uncontented synchronization block was expensive, and that lead many developers to write the getInstance() method of the Singleton class using double-checked locking idiom

How to Pass AWS Certified Solutions Architect: Associate SAA-C01 & SAA-C02 Exams [Resources]

Hello guys, If you are preparing for the AWS Certified Solutions Architect Associate Exam then you can find several articles online about the AWS Solutions Architect Associate exam and preparation. But it's not easy to keep all the good content or bookmark them all. However, it takes time to find all the right content and keep it safe for reading and learning more. We understand the value of your time and effort at the time of the exam, so here we present all the content related to the Associate AWS Solutions Architect exam in one place so that you can start your preparation in a structured way. 

Java Serialization Example and Tutorial for Beginners [Guide]

Serializing an object in Java is never easy and many Java developers often get confused. There are so many rules, interfaces to implement, and then always a chance of data loss or an error during the Serialization or deserialization process.  In the past, I have posted a detailed guide of Serliazing Object in Java which is very liked by my readers and they asked for more information like what should Java developers remember while using the Serializable and Externalizable interface in Java. 

Can You Override Static Method in Java? Method Hiding Example

Can we override the static method in Java?
This is one of the most popular Java interview questions. The answer to this question is No, you cannot override the static method in Java because the method overriding is based upon dynamic binding at runtime and static methods are bonded using static binding at compile time. This means static methods are resolved even before objects are created, that's why it's not possible to override static methods in Java. Though you can declare a method with the same name and method signature in the subclass which does look like you can override static methods in Java but in reality that is method hiding. 

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. 

7 Difference between extends Thread vs implements Runnable in Java [Answer]

Hello guys, the difference between Thread vs Runnable in Java is a common Java multithreading interview question that is often asked by junior Java developers with 2 to 4 years of experience. If you are doing Java programming then you may know that Java provides multithreading to parallelize the execution of tasks (code) and you need multiple threads to run multiple things in parallel like downloading a file in the background and showing the progress bar at the front-end. There are two ways to create a Thread in Java, first by extending java.lang.Thread class and second by implementing the java.lang.Runnable interface. 

Java CountDownLatch Example for Beginners - [Multithreading Tutorial]

Hello Java programmers, the CountDownLatch is an important concurrency utility class that was added in JDK 1.5 to facilitate inter-thread communication without using wait and notify methods, but unfortunately, many Java developers still struggle to understand and use this powerful tool. In this article, you will learn what is CountDownLatch and how to use it to write better concurrent applications in Java. You can use the CountDownLatch if you are spawning multiple threads to do different jobs and want to know when exactly all tasks are finished so that you can move to the next stage. In other words, you can block a thread until other threads complete their task

Difference between View and Materialized View in Database or SQL? [Answer]

The difference between View and Materialized view is one of the popular SQL interview questions, much like truncate vs delete, correlated vs noncorrelated subquery, or primary key vs unique key. This is one of the classic questions which keeps appearing in SQL interviews now and then and you simply can’t afford to learn about them. Doesn’t matter if you are a programmer, developer, or DBA, these SQL questions are common to all. Views are a concept which not every programmer is familiar with, it is simply not in the category of CRUD operation or database transactions or SELECT query, its little advanced concept for the average programmer.

How to find symbolic link or soft link in Linux? ls + find command Example Tutorial

There are two ways you can find a symbolic link or soft link in UNIX based operating systems like Linux, Solaris, BSD, or IBM AIX. The first way is by using the ls command in UNIX which displays files, directories, and links in any directory and the other way is by using UNIX find command which has the ability to search any kind of file e.g. file, directory, or link. In this UNIX command tutorial, we will see examples of both of these UNIX commands for finding a soft link in any directory. If you are new to UNIX operating system and not familiar with the concept of the soft link and hard link, I would recommend getting a good hand on it, as it is one of the most powerful features of UNIX based system.

10 Examples of forEach() method in Java 8

From Java 8 onward, you can iterate over a List or any Collection without using any loop in Java. The new Stream class provides a forEach() method, which can be used to loop over all or selected elements of the list and map. The forEach() method provides several advantages over the traditional for loop e.g. you can execute it in parallel by just using a parallel Stream instead of a regular stream. Since you are operating on stream, it also allows you to filter and map elements. Once you are done with filtering and mapping, you can use forEach() to operate over them. You can even use the method reference and lambda expression inside the forEach() method, resulting in a more clear and concise code.

3 Ways to return different content types from Spring MVC Controller? @RequestMapping and ResponseEntity Example Tutorial

Hello guys, if you want to provide different types from a Controller in Spring MVC and wondering how to do that then you have come to the right place. In the past, I have shared the free Spring MVC courses, books, and interview questions and in this article, I am going to show you three ways to send different content types from Spring Controller. There are various content types for a controller and we are going to discuss them in this tutorial. So we are going to discuss how to interpret the data present in the request and response. JSON is one of the media formats that may be consumed/produced using this request-response architecture.

Fibonacci Series in Java Using Recursion

Fibonacci series in Java
Write a Java program to print the Fibonacci series up to a given number or create a simple Java program to calculate Fibonacci number is common Java questions on fresher interviews and homework. Fibonacci series is also a popular topic on various programming exercises in schools and colleges. Fibonacci series is a series of natural numbers where the next number is equivalent to the sum of the previous two numbers like fn = fn-1 + fn-2. The first two numbers of the Fibonacci series are always 1, 1. In this Java program example for the Fibonacci series, we create a function to calculate Fibonacci numbers and then print those numbers on the Java console.

How to sort an Array in descending order in Java? Example Tutorial

Sorting an array is one of the common tasks in Programming and you have many algorithms to sort an array, like QuickSort, MergeSort which provides O(NLogN) time performance, and Bucket Sort, Counting Sort, and Radix Sort algorithms which can even sort some array in O(N) time. But, you hardly need to code these algorithms by hand when it comes to writing real code. The Programming language you will use already has tried and tested implementation for those algorithms and that's what you will learn in this article. In Java Programming language, it's easy to sort an array, you just need to call the Arrays.sort() method with a Comparator which can sort the array in the order you want but it highly depends upon which type of object is stored in the array.

How to implement Radix Sort in Java - Algorithm Example [Solved]

The Radix sort, like counting sort and bucket sort, is an integer-based algorithm (I mean the values of the input array are assumed to be integers). Hence radix sort is among the fastest sorting algorithms around, in theory. It is also one of the few O(n) or linear time sorting algorithms along with the Bucket and Counting sort. The particular distinction for radix sort is that it creates a bucket for each cipher (i.e. digit); as such, similar to bucket sort, each bucket in radix sort must be a growable list that may admit different keys.

How to pause a Thread in Java? Thread.sleep and TimeUnit.sleep Example

There are multiple ways to pause or stop the execution of the currently running thread in Java, but putting the thread into a sleep state using the Thread.sleep() method is the right way to introduce a controlled pause. Some Java programmers would say, why not use the wait and notify? Using those methods just for pausing a thread is not a good coding practice in Java. Those are the tools for a conditional wait and they don't depend on time. A thread blocked using wait() will remain to wait until the condition on which it is waiting is changed. Yes, you can put timeout there but the purpose of the wait() method is different, they are designed for inter-thread communication in Java

Top 10 Frequently asked SQL Query Interview Questions

In this article, I am giving some examples of SQL queries which is frequently asked when you go for a programming interview, having one or two year experience in this field. Whether you go for a Java developer position, QA, BA, support professional, project manager, or any other technical position, may interviewer expects you to answer basic questions from Database and SQL. It's also obvious that if you are working for one or two years on any project there is a good chance that you come across to handle databases, writing SQL queries to insert, update, delete and select records. 

Top 6 books to learn Java Virtual Machine, Garbage Collection, and Performance [UPDATED]

In the last couple of years, I have seen a trend of many Java developers wants to learn more and more about JVM internals and how Java Virtual Machine and its different component works. This trend was not so strong in the last decade, but with more and more focus on concurrency, performance, and scalability, Java developer is exploring JVM internals, Garbage collection, and Performance tuning in more detail. Unfortunately, there are not many good books to learn about JVM internals and their different components, but fortunately, we have an excellent Java Virtual Machine specification to learn fundamentals. It is also the most up-to-date reference because Java and JVM are kept changing, especially after Java 10.

10 Examples of ALTER Table Command in SQL

In this SQL tutorial, you will learn how to use ALTER command in the table on the database. ALTER command is mainly used to add, modify and drop columns, indexes, and constraints on the table in relational databases e.g. MySQL, Oracle, Sybase, and SQL Server.  Though ALTER is not part of classical CRUD operation but it’s one of the important DDL commands. One of the most frequent uses of ALTER command in SQL is adding and removing indexes to improve the performance of SQL SELECT queries.

What is Method Overloading in Java? An Example

What is method overloading in Java?
Method overloading in Java is an object-oriented programming concept that allows a programmer to declare two methods of the same name but with different method signatures, like a change in the argument list or a change in the type of argument. Method overloading is a powerful Java programming technique to declare a method that does a similar job but with a different kind of input. One of the most popular examples of method overloading is the System.out.println() method whose job is to print data on the console. This method is overloaded to accept all kinds of data types in Java. 

Counting Sort in Java - Example

The Counting sort algorithm, like Radix sort and Bucket sort, is an integer-based algorithm (i.e. the values of the input array are assumed to be integers), non-comparison, and linear sorting algorithm. Hence counting sort is among the fastest sorting algorithms around, in theory. It is also one of the few linear sorting algorithms or O(n) sorting algorithms. It's quite common in Java interviews nowadays to ask, whether do you know any O(n) sorting algorithm or not. If you face this question in the future, you can mention Radix sort, Bucket sort, or Counting sort algorithms.

How to Implement a Power Function in Java? Example Tutorial [Solved]

If you are preparing for a coding interview and wondering how to implement a function to calculate the power of x to y then you have come to the right place. Earlier, I have shared the best books, websites, and courses for coding interviews and in this article, I will show you how to solve this common coding problem from interviews with companies like Amazon, Flipkart, Google, and startups, and in this article  Even though the Java library has a power function Math.pow() to calculate the power of a given number in Java, it's a regular programming exercise for Java programmers to implement a power function. 

The Ultimate guide of Array for Java Programmers - Example Tutorial

Without any doubt, the array is one of the most used data structures in all programming languages, including Java. Pick up any programming language be it functional, object-oriented, imperative, or even scripting languages like Python, Bash, and Perl, you will always find an array. That's why it's important for any programmer to have a good understanding of the array data structure. Like any other data structure, the array also provides a way to organize and store objects, but the way it does makes all the difference. An array is used to store elements in the contiguous memory location and many C, C++ programmers can take advantage of a pointer to work with an array.

5 Difference between Interface and Abstract class in Java? [Answer]

What is abstract class and interface in Java?
The difference between abstract class and interface in Java is one of the tricky Java interview questions and mostly appears in core Java interviews. It has become now even trickier after Java 8 introduced default methods and allowed interfaces to have both default and static methods. Even though both interface and abstract class are a way to achieve abstraction in Java, there are significant differences between them, which you will learn in this article. Some time interviewer also not just focuses on key differences between abstract class and interface in Java but he is also interested in some practical experience e.g. when to use interface in Java and when to use an abstract class in Java.

Top 100 Angular Interview Questions for 1 to 2 Years Experienced Developers

Angular is one of the popular JavaScript frameworks, I think most popular after jQuery, with the core goal of simplification. It allows building dynamic, single-page web apps (SPAs) using JavaScript and supports the Model View Controller (MVC) programming structure. It has been used widely and even big companies like Google, Virgin America, and HBO are using Angular to build their site. The demand for web developers is at an all-time high and there is a huge demand for developers who understand modern JavaScript frameworks like Angular, jQuery, Facebook's React JS, etc. Angular is an Open-source, front-end JavaScript framework which is developed by Google, it mainly competes with Facebook's ReactJS framework

Top 30 Spring Core, Spring MVC and Spring Security Interview Questions Answers

Spring Interview Questions Answers 
Spring Interview Question is one of the first things Java programmers should prepare before appearing on any Java or Spring interview. With the immense popularity of Spring frameworks like Spring MVC and Spring Boot in the Java world, the focus on Spring skills on interviews increases daily. For those who don't know, the Spring framework is one of the most famous structures for Java applications, which aims to simplify Java development. It revolutionized the Java development when it initially came with concepts of  Dependency Injection and Inversion of Control, which made writing a testable and maintainable Java application

OCMJEA 6 FAQs - Oracle Certified Master - Java EE 6 Enterprise Architect (1Z0-807, 1Z0-865 and 1Z0-866) - Frequently asked Questions

The OCMJEA (Oracle Certified Master Java EE Enterprise Architect) is one of the toughest Java certifications to crack, even for experienced Java developers. It requires architectural decision skills for the given business problem. Step 1 multiple-choice tests your skills by scenario-based business problems to choose the best design solution. The exam not only covers the Java EE platform but also tests your security, hardware architecture, and design pattern skills.

9 Tips to become a better Software Developer

Many of my readers, students, and programmers often asked me how to improve their programming skills, coding skills, or design skills. I know it's not easy to be a professional programmer. Apart from programming and coding, you have to be good at communicating ideas, designing solutions and, more importantly, convincing peers and stakeholders. Ideally, you learn all these qualities at your workplace by working with more experienced and smarter people than yourself, but that's just an ideal scenario. Many programmers don't get lucky enough to work with a fellow programmer who helps them to grasp these skills; often, it's your own hard work.

Top 75 Programming Interview Questions Answers to Crack Any Coding Job Interview

Hello guys, if you are preparing for your next Programming Job interview and looking for some frequently asked Coding or Programming questions to practice then you have come to the right place. In this article, I am going to share some of the most commonly asked Coding questions from Programming Job interviews. In order to do well on the Coding interview you need practice, you just can't go there and try to solve the coding problems in a limited time, that's actually one of the most common reasons to fail your programming Job interviews.  Sometimes, the interviewer also asks a little bit easier coding questions on a telephonic interview like revering array in place or reversing a string in place.

Difference between UNION vs UNION ALL in SQL? Example

Hello guys, what is the difference between UNION vs UNION ALL is one of the most popular SQL interview questions and often asked programmers during a telephonic round of interviews. Though both UNION and UNION ALL is used to combine results of two SELECT queries, the main difference between them is that UNION doesn't include duplicate record but UNION ALL does. Another difference between them is that UNION ALL is faster than UNION but may look slow because it returns more data which takes more time to travel via the network. The difference between UNION and UNION ALL can be a tricky SQL question, especially for developers, who have not used this useful keyword ever. 

Java 8 Stream + FlatMap Example for Beginners | How to flat a list of list in Java?

In order to understand the flatMap() method, you first need to understand the map() function of Java 8. The map() function is declared in  the java.util.stream.Stream class and uses to transform one Stream into another, for example, it can convert a stream of integer numbers into another stream of ints where each element is the square of the corresponding element in the source stream. In the map() operation, a function is applied to each element of the source Stream and return values are inserted into a new Stream which is returned to the caller. The key point to note here is that the function used by the map() operation returns a single value.

How to get and set Value of a text field using jQuery? Example Tutorial

Hello guys, In the last jQuery tutorial, you learn how to dynamically add a text file into a form, and in this tutorial, I will show you how to get and set the value of the text field using jQuery. This is a common task and there is a good chance that you have already done something similar in your project. Our requirement is simple, the text field initially contains the value "username" and as soon as the user clicks on it to enter a username, it should become clear. After the user has entered the username of the user id, he can click on the submit button, and then your program should print the username and text field again becomes clear.