HTML

Friday, January 21, 2022

Producer Consumer Problem with Wait and Notify - Thread Example Tutorial

The Producer-Consumer Problem is a classical concurrency problem and in fact, it is one of the most powerful concurrency design patterns which is used in most multithreaded Java applications. In the last article, I have shown you how to solve the Producer-Consumer problem in Java using blocking Queue but one of my readers emailed me and requested a code example and explanation of solving the Producer-Consumer problem in Java with the wait and notify method as well Since it's often asked as one of the top coding questions in Java. In this Java tutorial, I have put the code example of the wait notify version of the earlier producer-consumer concurrency design pattern. 

How to Create and Start Multiple Threads in Java? - Example Tutorial

Hello guys, Multithreading is one of the biggest strengths of Java, which allows you to divide a task and execute faster by using more than one thread. In order to use multiple threads in Java, you need to first define the task which will be executed by those threads. In order to create those tasks, you can either use the Runnable or Callable interface. If you are just learning Java chose the Runnable interface, it's a simpler one, but if you are familiar with Java multithreading and want to leverage additional features offered by Callable like it can throw an exception and it can also return value, then go ahead and use the Callable interface. Once you have the task ready, you need to create an instance of the Thread class.

Thursday, January 20, 2022

How to Find Lowest Common Ancestor of a Binary Tree in Java? Example Tutorial

To find the lowest common ancestor of a binary tree in java requires that we run through a binary search tree and how it operates.  

What then is a binary search tree? A Binary tree is a data structure in which each node can have at most two children. That is, each node in the binary tree will have data, left child and right child. The first node of the tree is called the Root.

Below is the image of the Binary search tree, the first circle with 15 is called the root node and it has two children, left and right nodes with the values,10 and 20 respectively. Node 10 has two children too with 5 and 13 as values. The left child of node 10 does not have any child but, the right node with value 13 has two children nodes 12 and 14 respectively.

Top 10 Java Interview Questions for 2 to 3 years experience - Answered

Java Interview Questions 2 to 4 years of experience
If you are a Java programmer with 2 to 3 years experience of working in Java and looking for a job change then it's better to know what is expected from 2 to 3 years experienced Java programmer in a typical core Java or J2EE interview. Since 2 to 3 years is not a vast experience and you still fall under beginner to the intermediate category, it's not expected from you to have done profiling, Garbage collection tuning, designing complex Java applications, or even creating concurrent Java design patterns

Java 8 - Map and Reduce Example Tutorial

Hello folks, the map-reduce concept is one of the powerful concepts in computer programming, particularly on functional programming which utilizes the power of distributed and parallel processing to solve a big and heavy problem in a quick time. From Java 8 onwards, Java also got this powerful feature from the functional programming world. Many of the services provided on the internet like Google Search are based on the concept of the map and reduce. In map-reduce, a job is usually split from the input data-set into independent chunks which are processed by the map tasks in a completely parallel manner. The framework then sorts the outputs of the map operation, which are then supplied to the reduce tasks.

Wednesday, January 19, 2022

How to use PreparedStatement in Java - JDBC Example Tutorial

PreparedStatement is used to execute specific queries that are supposed to run repeatedly, for example, SELECT * from Employees WHERE EMP_ID=?. This query can be run multiple times to fetch details of different employees. If you use PreparedStatement like above then the database assists in query preparation, which is faster and more secure. Such kinds of queries are compiled, and their query plans are cached at the database side every time you execute it, you will get a faster response as opposed to using simple queries via Statement object, like SELECT * from Employees WHERE EMP_ID + emp_id.

Is it Possible to add static or private methods in Java interface?

Can you add a static or private method in an interface in Java? or is it possible to add a private or static method in Java interface? or can you add a non-abstract method on an interface in Java? are a couple of popular Java interview questions which often pop up during telephonic interviews. Well, prior to Java 8, it wasn't possible to add non-abstract methods in Java but nowadays you can add non-abstract static, default, and private methods in the Java interface. The static and default methods were supported as part of interface evolution in Java 8 and you can add private methods on an interface from Java 9 onwards.

How to convert Date to LocalDateTime in Java 8 - Example Tutorial

The LocalDateTime class has been introduced in Java 8 to represent both date and time values. It's local, so date and time are always in your local time zone. Since the java.util.Date has been widely used everywhere in many Java applications, you will often find yourself converting java.util.Date to LocalDate, LocalTime, and LocalDateTime classes of the java.time package. Earlier I have shown you how to convert Date to LocalDate and today, I am going to teach you how to convert Date to LocalDateTime in Java 8. The approach is the same. Since the equivalent class of java.util.Date in new Date and Time API in java.time.Instant, we first convert Date to Instance and then create LocalDateTime instance from that Instant using System's default timezone.

Tuesday, January 18, 2022

Top 35 Java String Interview Questions with Answers

Hello Java Programmers, if you are preparing for a Java developer interview and want to refresh your knowledge about  String in Java then you have come to the right place. The  String class and concept is a very important class in Java. There is not a single Java program out there which is not use String objects and that's why it's very important from the interview point of view as well. In this article, I am going to share 35 String-based questions from different Java interviews. It includes questions on java.lang.String class as well as a string as data structure like. some coding questions something like I have shared in my earlier article about 75 Coding questions to Crack any Programming Job interviews

Top 10 Tricky Java interview questions and Answers

What is a tricky question? Well, tricky Java interview questions are those questions that have some surprise element on them. If you try to answer a tricky question with common sense, you will most likely fail because they require some specific knowledge. Most of the tricky Java questions come from confusing concepts like method overloading and overriding, Multi-threading which is really tricky to master character encoding, checked vs unchecked exceptions, and subtle Java programming details like Integer overflow. The most important thing to answer a tricky Java question is attitude and analytical thinking, which helps even if you don't know the answer. 

Monday, January 17, 2022

Right way to check if String is empty in Java with Example

What do most of us Java Programmers do while using String in Java? Check whether String is null or empty right? I am sure you know a couple of ways to test whether String is empty or not, but do you know the right way to do it? When we talk about Strings in Java, we can imagine them as arrays of characters, and they are, but in Java, they also object. An empty Java String is considered as the not null String that contains zero characters, meaning its length is 0. However, a Java String that might only contain the white-space character is not considered empty, it is considered to contain one character and its length is equal to 1. 

Sunday, January 16, 2022

Top 50 JavaScript Interview Questions for Beginners [ 1 to 2 Years Experienced]

Hello guys, you may know that JavaScript is one of the most popular programming languages, having ranking #1 for a couple of years in the StackOverflow survey. There is no doubt that JavaScript is the most popular language or web development. The best thing is that you can use JavaScript to develop both frontend and backend using the same programming language and tech stack. You have so many popular frameworks like React.js, Angular, Node.js, Vue.js to implement sophisticated web applications for different domains. That's why the demand for JavaScript developers is very high, especially full-stack JavaScript developers who can create front-end and back-end applications independently.

Saturday, January 15, 2022

Top 6 Courses to Learn Dynamic Programming for Coding Interviews in 2022 - Best of Lot

Hello guys, if you are preparing for a coding interview but struggling to solve Dynamic programing based coding problems and looking for the best resource to improve your Dynamic programming skill then you have come to the right place. Earlier, I have shared the best coding interview courses as well as common Dynamic programming problems from interviews, and today I am going to share the best online courses to learn Dynamic programming in depth.  Dynamic programming simply means that plain recursion can be optimized when there are repeated calls for some inputs.

Thursday, January 13, 2022

Top 5 Free & Paid Spring Certification Courses and Practice Tests

Many Java developers don't know that, similar to Oracle's Java certification, there is also a Spring certification program, which certifies yourself for your Spring framework skill. There are three Spring certifications currently available, the Spring Professional certification exam, also known as the Vmware Certified Spring Professional exam (VMware EDU-1202) which certifies on your general knowledge about Spring framework, Spring MVC skill, Spring Boot, Spring Data JPA, Testing with Spring and Spring Boot, and other advanced Spring skills. Earlier, SpringSource provides these certifications, but now they are provided by Vmware, the company behind the Spring framework.

Wednesday, January 12, 2022

Top 5 Spring Boot Courses for Beginners in 2022 [UPDATED] - Best of Lot

Hello guys, if one of your goals is to learn Spring Boot in 2022, and I have started working towards it. As I have talked about my 3 point action plan to learn new technology, the first step is to attend some online courses and start building from that. If you are not sure what is Spring Boot and why should you learn Spring Boot, then let me tell you that it should be the first Java framework you should learn in 2022. The Spring Boot makes it really easy to work with the Spring framework by removing all the starting hurdles concerning setup and configuration. In one word, it makes it possible to write a Spring-based Java application and run them like core Java applications, like from the primary method.

What is objects in JavaScript? Example Tutorial

JavaScript is a dynamically typed programming language. In JavaScript, it is not required to define the data type of a variable but that does not mean JavaScript does not have data types. Data types in JavaScript are divided into two categories - primitive and non-primitive.


Primitive data types such as numbers and strings can hold only a single value. But non-primitive types can hold more than one value. Objects in JavaScript are non-primitive. 


If you have ever done programming, you may be familiar with the concept of objects because objects are one of the most important parts of programming. The reason is simple. Objects can hold multiple values. In this article, we will discuss objects in JavaScript. 

Tuesday, January 11, 2022

5 Best Online Courses to Learn Linux and UNIX in 2022 [UPDATED]

Hello guys, if you want to learn Linux operating systems and command lines and look for the best Linux courses, you have chosen the right place. In the past, I have shared some free Linux courses and bash scripting courses for programmers and developers, and many of you asked for more comprehensive online Linux courses to learn Linux in-depth, which motivates me to write this article. In this article, you will find the best Linux online training classes, online paths, and tutorials from Udemy, Pluralsight, Coursera, and edX, my favorite online learning platforms.  

How to Pass Spring Professional 5.0 Certification (VMware EDU-1202) in 2022 [UPDATED]

Hello guys, if one of your new year goals is to pass the Spring Developer Certification this year and wondering where to start then you have come to the right place. In this, article, I'll tell you how to prepare for Spring Professional v 5.0 certification (VMware EDU-1202)  and useful resources to pass the exam on the first attempt. If you have been self-preparing for Spring Professional 5.0 exam, then you might have struggled with which topics to prepare and which topics to leave out. I often receive questions like does Spring Boot is part of Core Spring certification? Will there be any questions from Spring Security and Spring Data? Does Spring Cloud also part of this exam or not? Unfortunately, there is no detailed, semester syllabus for Vmware's Core Spring certification (VMware EDU-1202) 

Monday, January 10, 2022

5 Best books to Learn JDBC for Java Programmers

The JDBC (Java Database connectivity) is one of the vital API in the Java programming language which allows a Java program to connect to any database, like Oracle, Microsoft SQL Server, MySQL, PostgreSQL, SQL Lite, Sybase or any other relational database. It's an essential API to learn and master for both core Java and Java EE professionals, given the ubiquitous nature of Databases in real-world applications. Despite its importance, many Java developer lacks essential JDBC skills, like they are not familiar with Connection, Statement, connection pool, calling stored procedures, and executing a transaction in JDBC.

Top 5 Free Java Microservices Courses with Spring Boot and RxJava in 2022 - Best of Lot

Hello Java programmers, if you want to learn Microservice architecture and look for free Microservice resources like free online courses, you have come to the right place. Earlier, I have shared the best Microservice courses for Java programmers to build Microservice using Java and the Spring framework, and today, I will share some free courses to learn Microservice in Java using Spring Boot and the Spring Cloud framework. If you don't know, Microservices is a modern architecture that goes along nicely with cloud computing and makes deployment, scaling, and even development easier.