HTML

How to Check if an Array contains a Number or String in Java [ Linear Search vs Binary Search]

Hello guys, one of the common coding questions from Java interviews is how to test if an Array contains a certain value or not? This is a simple question, but sometimes interview pressure makes candidates nervous. In this article, you'll learn how to solve this problem using different approaches. Since an array in Java doesn't have any inbuilt method for searching values, interviewers prefer to ask this question, to see how a candidate deals with such a situation. If you have good knowledge of Java API, then you will immediately come to know that there are alternatives available like using the binarySearch() method of Java Java .util.Arrays class or taking advantage of ArrayList contains method by first converting your array to ArrayList.

How to Check if Given Number is Prime in Java - With Example

Hello guys, today, we are going to discuss one of the most common programming exercises for beginners is, write a program to check if a given number is prime or not? There are many ways to check if a number is prime or not, but the most common of them is the trial division, which is what we will see in this tutorial. In my opinion, these kinds of programs are their first steps towards algorithmic understanding. You first come up with a solution, which is driven by the fact that prime numbers are natural numbers, that are not divisible by any positive number other than 1 and themselves. Then, you write a for loop to check every number, starting from 1 to a given number, to see if the given number is divisible by any positive number or not. This leads you to the solution.

Top 8 Websites to Learn JavaScript Coding for FREE in 2021 - Best of Lot

Hello guys, if you want to learn JavaScript and looking for the best websites to learn JavaScript programming for FREE then you have come to the right place. Earlier, I have shared the best free JavaScript courses and paid JavaScript courses and in this article, I am going to list down the best websites to learn JavaScript for FREE. We live in a world of the internet, which is full of resources. You can learn whatever you want and that too, without spending too much money. If you're going to learn JavaScript, there are plenty of websites where you can learn JavaScript online for FREE

How to Find Greatest Common Divisor of two numbers in Java - [ Euclid's algorithm GCD Example]

How to find the Greatest Common Divisor of two numbers in Java
Simple Java program to find GCD (Greatest Common Divisor) or GCF  (Greatest Common Factor) or HCF (Highest common factor). The GCD of two numbers is the largest positive integer that divides both the numbers fully i.e. without any remainder. There are multiple methods to find GCD, GDF, or HCF of two numbers but  Euclid's algorithm is very popular and easy to understand, of course, only if you understand how recursion works. Euclid's algorithm is an efficient way to find the GCD of two numbers and it's pretty easy to implement using recursion in the Java program. According to Euclid's method GCD of two numbers, a, b is equal to GCD(b, a mod b) and GCD(a, 0) = a.

How to Print Prime Numbers from 1 to 100 in Java [Solved]

Hello guys, today, I'll share with you a simple problem of writing a Java program to print prime numbers up to a given number like saying prime numbers from 1 to 100. It's one of the most common coding exercises for programmers learning in Java, as it gives you an opportunity to learn more about the essential operators in Java Programming. The key here is that you cannot use a library function which can simplify your job, you need to devise the algorithm for checking prime number by yourself. One of the most popular algorithms for generating prime is Sieve of Eratosthenes,  which we have discussed earlier, but in this post, we will take a simpler approach.

How to Find Duplicate Characters in String [Java Coding Problems]

Hello guys, today's programming exercise is to write a program to find repeated characters in a String. For example, if given input to your program is "Java", it should print all duplicates characters, i.e. characters appear more than once in String and their count like a = 2 because of character 'a' has appeared twice in String "Java". This is also a very popular coding question on the various level of Java interviews and written tests, where you need to write code. On the difficulty level, this question is at par with the prime numbers or Fibonacci series, which are also very popular on junior level Java programming interviews and it's expected from every programmer to know how to solve them.

How to Find Missing Number in a Sorted Array in Java [Solved]

Today's coding problem is not very new, it's an age-old classic Programming interview Question. You have a sorted array containing n - 1 unique number starting from 0 to n - 1. There is only one number missing in this range and you need to find that out. I mean you need to write a Java method to find the missing number and print its value in the console. Some of you might have seen this question before, but if you have not been asked this question before, what is the first approach comes into your mind to solve this question? Since only one number is missing, many programmers come up with the approach of iterating over the array, and comparing each element with the expected one like the first element should be 0, the second element should be 1, and so on.

2 Ways to Find Duplicate Elements in a given Array in Java [Solution]

Hello guys, today, you will learn how to solve another popular coding problem. You have given an array of objects, which could be an array of integers and or an array of Strings or any object which implements the Comparable interface. How would you find duplicate elements from an array? Can you solve this problem in O(n) complexity? This is actually one of the frequently asked coding questions from Java interviews. There are multiple ways to solve this problem, and you will learn two popular ways here, first the brute force way, which involves comparing each element with every other element, and other which uses a hash table-like data structure to reduce the time complexity of the problem from quadratic to linear, of course by trading off some space complexity.

Top 5 AWS Cloud Practitioner Certification (CLF-C01) Courses, Practice Tests, and Exam Dumps in 2021 - Best of Lot

Hello guys, If you are preparing for AWS Certified Cloud Practitioner and looking for some affordable awesome online training courses and practice tests to start your preparation then you have come to the right place. Earlier, I have shared free AWS Cloud Practitioner courses, and in this article, I am going to share the best AWS Certified Cloud Practitioner certification online training courses for beginners and anyone who want to learn about AWS and Cloud Computing and also want to earn a certification. In this list, I have selected some of the finest courses from Udemy, Whizlabs, and other places that are both tried and trusted and helped thousands of people to pass these prestigious AWS and Cloud certifications. They are also very affordable and you can take all these AWS Cloud practitioner training tests online.

40+ Java IO and Files Interview Questions with Answers

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

A Simple Example to Check if File is Empty in Java

One of the readers of my blog Javarevisited emailed me yesterday about how to check if a file is empty in Java and that's why I am writing this post to show that using an example. The common approach for checking if a file is empty or not is to first check if the file exists or not and then check if it contains any content, but Java has done that hard work for you. Well, it's pretty easy to check emptiness for a file in Java by using the length() method of the java.io.File class. This method returns zero if the file is empty, but the good thing is it also returns zero if the file doesn't exist. This means you don't need to check if the file exists or not.

Top 25 Examples of ConcurrentHashMap in Java [Tutorial]

The java.util.ConcurrentHashMap is one of the most important classes of JDK. It was introduced in JDK 1.5 along with other concurrent collection classes like CopyOnWriteArrayList and BlockingQueue. Ever since then, it has been a workhorse in concurrent Java applications. It won't be an exaggeration If I say there is hardly any concurrent Java application that has not used ConcurrentHashMap yet. The class was another implementation of Java .util.Map and a popular hash table data structure with concurrency inbuilt. This means you can also pass a ConcurrentHashMap to a method that is expecting a java.util.Map object. It was made scalable by dividing the whole map into a different segment, known as concurrency level, and then allowing threads to modify segments concurrently.

Polymorphism, Overloading, and Overriding in Java and Object Oriented Programming?

Polymorphism vs Overloading vs Overriding
Someone asked me the other day,  what are the difference between Polymorphism and Overriding in Java and the similar difference between Polymorphism and Overloading. After explaining to him personally, I thought to write a blog post about it and here we are. Well, they are not two different things, Polymorphism is an object-oriented or OOP concept much like Abstraction, Encapsulation, or Inheritance which facilitates the use of the interface and allows Java program to take advantage of dynamic binding in Java. Polymorphism adds flexibility to your code which makes it more extensible and maintainable. 

Default Methods and Multiple Inheritance in Java 8

Ever since Java 8 introduced default and static methods in JDK 8, it's become possible to define non-abstract methods in interfaces. Since Java, one class can implement multiple interfaces and because there can be concrete methods in interfaces, the diamond problem has surfaced again. What will happen if two interfaces have methods o the same name and a Java class inherit from it? Many Java programmer also asks me the question that, is Java 8 is also supporting multiple inheritances of classes? Well, it's not but the doubt is genuine because the interface with methods is similar to an abstract class or in that any Class in Java.

Top 5 Free Data Science and Data Analysis Courses for Beginners in 2021 - Best of Lot

Hello folks, Data Science and Data Analysis are two of the most in-demand skills in the current technology world and all kinds of companies need them to improve their sales, profit, and overall business process. If you want to learn Data Science and Data Analysis and looking for some free online training courses to start your career then you have come to the right place. Earlier, I have shared the best Data Science courses and In this article, I am going to share free Data Science courses from Udemy and Coursera for both beginners and experienced programmers. You can join these courses to learn Data Science from scratch. They are also good to fill gaps in your knowledge if you already doing Data Analysis, and the big point, they are completely FREE.

Difference between Set, List and Map in Java - Interview question

Set, List and Map are three important interfaces of the Java collection framework, and the difference between Set, List, and Map in Java is one of the most frequently asked Java Collection interview questions. Sometimes this question is asked as When to use List, Set and Map in Java. Clearly, the interviewer is looking to know that whether you are familiar with the fundamentals of the Java collection framework or not. In order to decide when to use List, Set or Map, you need to know what are these interfaces and what functionality they provide. List in Java provides ordered and indexed collection which may contain duplicates. 

3 Examples of for loop in Linux and Bash Script [Tutorial]

Hello guys, if you want to learn how to use for loop in bash or Linux then you have come to the right place. Earlier, I have shared free Linux courses and free bash scripting courses, and today, I am going to share three simple examples of using for loop in Linux.  If you are a Programmer, Software Engineer, or System Administrator working in a UNIX or Linux environment, then you will probably find the shell 'for' loop to be a handy tool for automating simple command-line tasks. This is the single command which has helped me a lot while doing production support and performing operational tasks. 

Right way to check if String is empty in Java

What do most of us Java Programmers do while using String in Java? checking 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. 

12 Advanced Java programming Books for Experienced Programmers - Part 2

This is the second part of 12 must-reads advanced Java programming books for intermediate and experienced Java programmers. In the first part, I have shared books to learn and master concurrency, performance, design patterns, and Java collection framework, which is essential for every Java developer irrespective of experience. On the other hand, In this article, I will talk about more advanced concepts, like security, Java 8, best practices, etc., which are more important for senior Java developers. As an experienced Java developer, a lot is expected of you. Junior developers look at you for guidance, and project managers look at you to solve problems and bail them out at critical junctures.

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.

Top 10 Cloud Certification (AWS, Azure, and GCP) You can Aim in 2021 - Best of Lot

Hello guys, if you are aiming for cloud certifications in 2021 but not sure which cloud certification should you go for then you have come to the right place. Earlier, I have shared a list of the best IT certifications for Java developers, and today, I am going to talk about the best cloud certification to aim for in 2021. You can go through this list of cloud certifications and choose the best one depending upon your skills and experience. I have shared the best cloud certifications for beginners, developers, system admins, and solution architects from Amazon AWS, Microsoft Azure, and Google Cloud Platform. 

70+ Java Interview Questions for Beginners [1 to 2 Years Experienced]

Java Developer Interviews are very different than traditional software developer interviews. You can clear a Java interview without even writing a single line of code, Yes, this is true, you can become a Java developer without someone asking you to write a function in a Java interview. Though it's not the case everywhere and many companies are increasingly including a coding test in their Java developer interview process, but there are many companies and start-ups where you can get a Java job without writing a single line of code. All you need to do is learn those popular Java questions, which have been asked for ages, and mostly test whether a candidate is familiar with essential Java concepts or not like abstract class and interface. 

13 Best Java Serialization Interview Questions and Answers for Beginners

There is no doubt that Java is vast and there are some Java topics which many Java developers rarely explore in work but they are important from a Java interview point of view. Serialization is one of them which is rarely used in practice but quite popular during Java interviews. It's also one of the difficult topics to master and that's why I am going to share some frequently asked Java Serialization interview questions in this article.  I don't know why people ask so many questions from Selrization if not everyone uses it but I have always seen some questions from Java realization. These are also the toughest and confusing questions to answer and more likely cannot be answered by an average Java developer.

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 developer remember while using Serializable and Externalizable interface in Java. This encouraged me to write this post where I have put together 10 important points related to Serializing an Object in Java. This is a to-the-point article that is full of information and I have also shared a core example to demonstrate the point I have mentioned in this article.

How to use DROP command to remove tables in Oracle, MySQL and SQL Server

Hello guys, if you want to learn about DROP command in SQL then you have come to the right place. Earlier, I have shared the best free SQL and Database courses and several tutorials to learn SELECT, GROUP BY, and other important commands, and in this article, I will show you to use the DROP command in SQL. DROP is one of the basic SQL commands, which is used to DROP database objects. Since it's part of ANSI SQL, the DROP command is supported by all major database vendors, including Oracle, MySQL, and Microsoft SQL Server. A SQL DROP TABLE statement is used to delete a table definition and all data from a table, but DROP can also be used to drop index, view, trigger, or any other database object. 

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.