- Advantages and disadvantages of Java
Java is an object oriented programming (OOP) language. It’s a WORA application, write once, run anywhere, which means that a compiled Java code can be run in any platform supporting Java, without any need to recompile the original code. Due to Java’s automatic memory management and type checking, which are Java’s built-in security features, this language is one of the most secure platforms for app development, though it always needs to be updated. Another good thing about this programming language is that it’s robust and reliable, that is, it’s able to detect errors which might be challenging for other programming languages to detect, also, Java detects them fast. The features making Java robust are garbage collection, Exception Handling, and memory allocation.
Along with numerous advantages, Java also has some drawbacks. For example, because of the garbage collection, which other programming languages don’t have, Java consumes a lot of memory, which will later lead to unpredictable pauses. Writing some codes in Java might be time consuming as everything needs to be typed manually. Thus, making mistakes in Java is not a difficult task.
Despite these drawbacks, Java remains as one of the most widely used programming languages.
- Java Platform
There are three components which combined together are called “Java Platform”. It’s an environment for developing and running Java applications on different platforms. The three components are JDK, JRE, and JVM.
JDK (Java Development Kit)
JDK provides an environment to develop and run a Java program. This kit includes two things: development tools and JRE, one provides an environment to develop and, the latter, to run the program.
Some components of JDK in Java are:
- java: loads the class files and clarifies the source code compiled by the javac compiler.
- javac: tells the computer to convert the Java code into bytecode.
- javadoc: document generator
- jar: archiver
- jps: manages the active JVMs for the running program ,etc.
JRE (Java Runtime Environment)
For a running environment it’s nice to use JRE, which stands for Java Runtime Environment. JRE does not contain any development tools and debuggers as it’s only used for running Java applications.
JVM
Previously it was mentioned that Java is able to run in any application supporting Java. It’s thanks to JVM, Java Virtual Machine. JVM is able to execute any compiled Java code, which is executed into a bytecode, on any device with a compatible JVM. This is what makes Java into a write once, run anywhere application, which is one of the main strengths of Java.
JVM helps in creating secure Java applications, provides a secure running/execution environment by applying different security features (classloader architecture, access control).
JVM also makes Java a memory-safe programming language as JVM manages garbage collection and memory allocation.
- OOP and its Pillars
OOP , or Object Oriented Programming, is a programming style which uses "objects" for writing a code. It helps us to model the structure and behavior of our program by using objects, classes and the 4 pillars of OOP. It assists in creating an organized code, which is not difficult to understand and impliment in various parts of a program.
4 Pillars of OOP
OOP is based on four main principles, which are also called the 4 pillars of OOP. The pillars are Encapsulation, Inheritance, Polymorphism, Abstraction. Let's have a basic understanding of these pillars.
Encapsulation
Encapsulation is similar to putting things in a box or a room, we build data and action in that box/room. The area where we build the code is called a class. Encapsulation restricts and hides the access to its data.
Inheritance
The name "inheritance" hints to what this pillar is. It's like passing on something, in this case the traits. Once you have a class with a certain trait then create a new class, which can inherit the traits of the first class. The purpose of this pillar is establishing a hierarchical relationship between classes.
Polymorphism
Polymorphism means "many forms", basically, it allows us to use classes or objects in a connected way. A good example is shapes like square, triangle and so on. These are different shapes, but they're still shapes; therefore, you can treat those various shapes as one.
Abstraction
Abstraction is something like focusing on the vital parts, it only shows the necessary parts. It manages complexity by focusing on what's important and hiding the other unnecessary parts. This helps us to make our code more comprehensible for others.
Top comments (0)