Preparing for Java and Spring Boot Interview?

Join my Newsletter, its FREE

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

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. 

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. 

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.

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 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

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.

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

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.

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 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.