<p>This category contains all the posts under core java and ways to program in Java</p>

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

Explain Exception Handling in Java

This is one of the hottest Java Interview Questions for entry level and mid level software developers in Java. The question is mostly asked as "Explain Exception Handling in Java" but the wordings may change. Defining an Exception An exception indicates a problem that a reasonable application may wish to recover from. On a more formal note, "When a program violates the semantic constraints of the Java Programming Language, the JVM signals error to the program as an Exception. Many programming languages abruptly terminates programs in such scenarios but Java has a cleaner way of handling t...
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

Memory Layout of Java Virtual Machine

The Java Virtual Machine is an abstract computing machine. It is responsible for most of the features which made Java a great technology. Few of the major selling points of Java was: Platform Independence Hardware Independence Operating System Independence Security from malicious programs It is said to be abstract computing machine because it offers all the specification which if implemented properly can act as a machine to execute instructions. Sun Microsystems (now acquired by Oracle) offers an implementation of the JVM. The JVM understands a particular binary forma...
Read More