Difference between ISNULL() and COALESCE() function in SQL

Even though both ISNULL() and COALESCE() function provides alternate values to NULL in T-SQL and Microsoft SQL Server e.g. replacing NULL values with empty String, there are some key differences between them, which is often the topic of SQL Server interview. In this article, you will not only learn the answer to this question but also learn how to use COALESCE and ISNULL function properly. One the main difference between them is that  COALESCE() is a standard SQL function but ISNULL() is a Microsoft SQL Server specific, which means it's not guaranteed to be supported by other database vendors like Oracle, MySQL or PostgreSQL.

Java - Convert String to Short Example

In last a couple of examples, I have taught you how to convert String to Integer, Long, Double, Float, Boolean, and Byte in Java and today I will show you how to convert String to Short in Java, but before that let's revise what is short data type in Java. The short is an integral data type similar to the int but it only takes 2 bytes to store data as compared to 4 bytes required by an int variable. Since it takes only 2 bytes or 16 bits to store data, the range of short is also shorter than int. It ranges from -32,768 to 32767 (inclusive) or -2^15 to 2^15 -1. You might be wondering why upper bound is 255 and lower bound is -256 but that's because we have included zero in between.

Linux Crontab Command Example - How to backup and load Cron Jobs from a File in UNIX

If you have been using Linux for some time then you might know about cron jobs. They are the scheduler which can be used to automatically start processes in a Linux box. I have worked on many projects which used cron jobs to start the Java process and environment daily or weekly basis. They are similar to Autosys when it comes to scheduling job but cron is a Linux command as opposed to Autosys which is separate application altogether. In Linux, crontab command is used for scheduling and automating jobs or process. You can also use it for loading cron jobs from a file, listing existing cron entries, and editing them. It manages the cron table that is used by the cron daemon in Linux to execute the cron jobs.

Top 20 Hibernate Interview Questions for Java J2EE Programmers

Hibernate is one of the most popular persistent frameworks in the Java world. Hibernate offers an object to relational (ORM) solution which frees Java developers from writing tedious, hard to read and cluttered JDBC code converting SQL columns into Object properties. Apart from freeing Java developer from writing JDBC and database interaction code, Hibernate also offers the out-of-box solution on caching, proxying and lazy loading which drastically improves the performance of your Java Web application. Given it's important in Java Web application development field Hibernate has become of one of the most sought-after skill and goes hand in hand with Spring framework. That's why Spring and Hibernate interview questions are also very popular in Java interviews, particularly for web development positions.

When and How to use the wait() and notify(), nofityAll() methods in Java? - Example Tutorial

When should you use the wait() and notify method in Java is one of the many popular questions about the wait and notify methods from Java multithreading interview questions. One of the reasons for its popularity is that still a lot of Java programmer struggle to explain and write code using wait-notify methods.  Many Java developer only knows some facts about the wait and notify methods like that wait() and notify() are defined in the java.lang.Object class or you cannot call wait() without synchronization, means without a synchronized block or synchronized method but doesn't really know when and how to use them.

Decorator Design Pattern in Java with Example

The Decorator design Pattern is one of the famous Gang of Four (GOF) structural design pattern, which provides a dynamic way of extending an object's functionality. It's different than the traditional way of adding new functionality into an object using Inheritance, instead, it uses Composition which makes it flexible and allows to add new functionalities at the run time, as opposite to Inheritance, which adds new functionality at compile time. Because of this flexibility, Decorator is one of the darling patterns for many Java developer. Btw, like many others object-oriented design patterns, the decorator design pattern is introduced by the famous Gang of Four design pattern book, almost 2 decades ago. This means it's a time-tested way of adding new functionalities into an object.

Top 35 Java String Interview Questions with Answers

The  String class and concept is a very important class in Java. There is not a single Java program out there which is not using 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

10 Example of LocalDate, LocalTime, and LocalDateTime in Java 8

It's been almost 5 years since Java SE 8 was released on 17th March 2014 and Java 8 adoption has come a long way. Java programmers around the world have accepted with both ends, many companies have switched their development on Java 8 and several others are migrating to Java 8 platform. At this time, its extremely important for a Java developer to learn and share his Java 8 skill, and that just not include lambdas, stream, method reference, functional interface, and other more glamorous stuff, you also need to learn the new Date and Time API, which you would find using more regularly in your day to day life.

How to Convert Hostname to IP Address in Java - InetAddress Example

Hello guys, today, I am going to teach you about one interesting class from package, the InetAddress. If you have never used this class before, let me tell you that it's an abstraction to represent an Internet address and it encapsulates both hostname and IP address. Since converting an IP address to hostname or hostname to IP address is a very common requirement, Java developer should know about this class, and, in general about package, which contains much other useful class for networking and client-server applications. So, what is the best way to learn new APIs like Well, by writing small programs like this, which has a small focus and let you explore things. They are super useful and that's how I have learned the majority of Java API.

How to Find the Largest and Smallest of Three Numbers in Java

Hello guys, today, I am going to share with you another interesting coding problem for beginners, how to find the largest and smallest of three numbers. If you are learning how to program or looking to improve your problem-solving and coding skill then these kind of small problems are good to start with. They not only provide you an opportunity to think how to solve a problem using basic programming constructs like conditionals (if, else, if-else, switch), loops (for, while, do-while), operators like arithmetic, bitwise and logical operator as well as teach you how to write functions, class and create a program which you can run.

Why wait() and notify() method should be called inside a loop in Java?

If you have used wait() and notify() method in Java then you know that the standard idiom of calling wait() method uses a loop, but have you ever thought why? This is even advised by none other than Joshua Bloch, a Java guru and author of popular Effective Java book, must read for any Java programmer. When I first started using this method, I was puzzled why not just use the if block because ultimately we are testing for a condition and then either waiting or going for further processing. An if block is more readable for the testing condition than a while loop like for the classic producer-consumer problem, the waiting condition for producer thread could be written as :

How to Check if a Key Object Exists in HashMap Java? containsKey() Example

Hello guys, you might know that one of the common programming tasks while using HashMap in Java is to check if a given key exists in the map or not. This is supposed to be easy, right? Yes, it is easy if you know your API well, all you need to is call the containsKey() method, it returns true if given key exists in HashMap, otherwise false; but I have seen many programmers write code like below which is not correct, which inspired me to write this blog post.

if(map.get(key) !=  null){
    System.out.println("key exits in Map");

This code is fragile, it will not work if you have added null values into HashMap because HashMap does allow null values.

How to convert a Stream to List, Set, and Map in Java

In Java 8, Stream is one of the most important classes as it allows a lot of useful functional operations like filter, map, flatmap, etc on a collection of objects. Hence, going forward converting a Collection to Stream, performing operations, and then converting the result back to different Collection classes like List, Set, and Map will be a common task. The first problem of converting Stream to Collection is solved by Java designer by directly adding a stream() method on Collection interface, which means all other interfaces and classes which derived from Stream also have this method. Though the second problem of converting a Stream to List, Set, and Map requires some understanding of Stream API of JDK 8 and that's what you will learn in this article.