Java is a high-level object-oriented programming language.
It is platform independent, robust, secure, and multithreaded programming language which makes it popular among other OOP languages.
It is widely used for application software, web and mobile application development.
Features:
Platform Independent-
Java is the first programming language that is Platform Independent. Once we have written program in Windows then we are able run it on multiple platforms, for example, Windows, Linux, Sun Solaris, Mac, Unix, etc. In other words, WORA- Write once Run anywhere. Java code can be executed anywhere on any system.
Simple-
Java is easy to learn. The syntax of Java is based on C++ which makes easier to write the program in it.
Secondly, the concept of pointers has been completely removed from Java which leads to confusion for a programmer and pointers are also vulnerable to security.
Secure-
Java is best known for its security. With Java, we can develop virus-free systems. In today’s world everybody needs safety and security. Because of to the threat of hackers, people feel unsafe while using application over the Internet. To overcome such fears, Java provides safety and security features. Java provides these securities by default. Some security can also be provided by an application developer explicitly through SSL, JAAS, Oauth, JWT, Cryptography, etc.
Object-Oriented-
In Java everything with in class and object. Oops have 4 pillars- Abstraction, Encapsulation, Polymorphism and Inheritance.
Robust-
Robust simply means strong. Java is robust because:
a) It uses strong memory management.
b) There is a lack of pointers that avoids security problems.
Dynamic-
Java is a dynamic language. It supports dynamic loading of classes. It means classes are loaded on demand. It allows to do runtime changes.
Distributed-
Java is distributed because it facilitates users to create distributed applications in Java, example- Facebook, LinkedIn, Amazon, etc. This feature of Java makes us able to access files by calling
the methods from any machine on the internet.
Java supports to distributed cloud platform like AWS, Azure, OpenShift, GCP, etc.
High Performance-
Java enables high performance with the use of just-in-time compiler. JVM can execute byte codes (highly optimized) very fast with the help of Just in time (JIT). Java application always give us good performance as compared to other programming languages.
There are 4 Pillars-
A] Abstraction
B] Encapsulation
C] Polymorphism
D] Inheritance
Abstraction: Abstraction means hiding internal details and showing functionality.
For example- phone call, we don't know the internal processing, but we know how to make call.
Note- In java, we use abstract class and interface to achieve abstraction.
Encapsulation: The wrapping up of a data into a single unit.
Encapsulation refers to combining data and associated functions as a single unit.
For example- Capsule, it is wrapped with different medicines.
A java class is the example of encapsulation. Java bean is the fully encapsulated class because all the data members are private.
provide public getter and setter methods to access and update the value of a private variable.
Polymorphism: Polymorphism means the ability to take more than one form. Polymorphism is Greek word; Poly means many, and morphism means form- many form. And form means function, many functions it means many methods.
Polymorphism uses methods to perform different tasks. This allows us to perform a single action in different ways.
2 types of Polymorphism:
A] Compile Time [Method Overload]
Method overload means same method name, but different parameters.
Method overload possible with in Single class
Static method allows to overload
Final method allows to overload
Both methods must have different arguments
The number of arguments, sequence and type of arguments is different
The Java Compiler handles Compile-time Polymorphism.
B] Run Time [Method Override]
Method override means same method name and same parameters.
Method Override never possible with in single class, we must need to use Inheritance concept.
Static method can’t allow to override
Final method can’t allow to override
The number of arguments, sequence and type of arguments is same
JVM handles the Runtime polymorphism.
Inheritance- One class can acquire the properties of another class.
Inheritance promotes the reusability of code
To inherit from a class, use the extends keyword.
In Oops there are 5 types of Inheritance-
Single Inheritance
Multilevel Inheritance
Multiple Inheritance
Hybrid Inheritance
Hierarchical Inheritance
Java does not support to Multiple and Hybrid Inheritance.
Because of Ambiguity problem, we can’t extend’s 2 class at a same time. Instead of multiple inheritance Java support to interfaces and by using interface will implements 2 or more interfaces with in single class by “,” separated.
Benefits of Inheritance-
Code reusability
We can achieve Runtime Polymorphism using Inheritance.