Intermediate Java

Java Immutable Object

Immutable Objects in Java

Immutable objects are objects that cannot be changed once created. For instance, String is an immutable class in Java. Consider the code below, in the first...
Java Inheritance

Java Inheritance and Composition

Inheritance and composition are the two common methods to reuse code in Java. Inheritance is also known as "IS-A Relationship", composition is known as...
Java Finalize Method

Java Finalize Method

Garbage Collector (GC) reclaims memory occupied by objects that are no longer in use by the program. GC calls object's finalize() method to perform...
Java Equals Hashcode

Equals and Hashcode Methods in Java

Many Java classes including collection classes (like HashMap, HashTable, HashSet) use hashCode() and equals() methods to compare objects. If two objects are equal, they should...

Checked/Unchecked Exceptions

There are two types of exceptions in Java: Checked Exceptions, Unchecked Exceptions Any exception extended from Error or RuntimeException is an Unchecked Exception.Any exception extended...