Java encompasses nearly all the benefits provided by its OOP predecessor C++ and at the same time provides an all new clean, usable, pragmatic approach to objects. The three OOP pillars – 1) encapsulation, 2) polymorphism and 3) inheritance together with new features like Interfaces, Exception-handling, Multithreading, Generics, etc. have made Java the modern programmers’ first choice. A striking difference that Java has with C/C++ is that it does not allow the use of pointers. This feature single-handedly makes Java immensely secure as programmers can never directly access the memory. Java is also extremely dynamic as almost all the Java code (except the “static” parts) are late-binded, i.e., dynamically linked at run-time by the JVM.
Another distinguishing feature of Java is that there are no Header files or Libraries – instead there are Packages that are imported. In Java, everything encapsulated in classes and packages are nothing but containers of classes with similar functionalities. This feature allows us to create two classes with the same name if they are in different packages. The java.lang package is imported in all programs by default; other packages need to be imported explicitly when they are required. Java also relieves the programmer from the burden of memory management. In Java, memory is dynamically allocated with the “new” operator and automatically reallocated with the help of the “Garbage Collector” that automatically runs from time to time and frees objects that do not have any references pointing to them, thus preventing “Memory Leak” to a huge extent.