core java

Introduction to Functional Interface – Java8

What is Functional Interface? A functional interface is any interface which contains only one abstract method. A functional interface can have one or more default and static methods. Also, there is an annotation in Java @FunctionalInterface which is used to annotate the functional interfaces. It is not a mandate for functional interfaces to carry this annotation. There are many predefined functional interfaces in Java which belong to the package java.util.function What is the significance of these interfaces? These interfaces as we know declare a method which can be implemented and us...
Read More

Explaining the ThreadLocal

Introduction to ThreadLocal Java supports multi threading and provides many high level APIs to avoid running into the issues associated with multi threading. One of the concepts we discussed previously is called synchronization. You can read about synchronization in this blog post. Here are few scenarios I would like to draw your attention: Thread Safety - classic case for using ThreadLocal Not all the classes in the Java library are thread safe, also the user defined classes are mostly not thread safe. At many places on the web you will find posts related ThreadLocal  with one example o...
Read More

What are the advantages of Java Programming Language?

The most basic question asked to a beginner in a Java Interview is "What are the advantages of Java Programming Language?". Here is a detailed answer to this question. Java is a relatively high level language. It provides lot of features out of the box, which makes it easy to learn for today’s developers and focus on the real business implementation rather than worrying about the system level infrastructure management. Few of the advantages of Java Programming Language are: Platform Independence : Java is platform independent, which means that if a program is written and compiled in Ja...
Read More

Details of Class Loading in JVM

Have you ever seen a ClassNotFoundException or a NoClassDefFoundError? Did you ever face a situation where you are trying to cast and assign it to a compatible reference but it throws a ClassCastException ? Or did you face issues where you never understood where to put the jars in your application? Ever did any hot deployment on a running Application Server and wondered how the new changes get reflected without a server restart? Ever got confused with the process of Class Loading in JVM? If you didn't face any of these, then you are extremely lucky or you are yet to start development :)...
Read More

Java Virtual Machine Startup

In the last post we had a brief idea about the memory model of the Java Virtual Machine. We also came across certain terms like the Creation, Linking, Loading and Initialization of classes. In this post we will try to improve our understanding of all these terms. At the Java Virtual Machine Startup The JVM starts up by creating an initial class and loads it using the bootstrap class loader (we will learn about the class loader in another post). Some implementation of the JVM allow us to pass the name of the initial class using the command line. The JVM then links this initial class. L...
Read More