JAVA OOP Concepts

 Java is an object oriented programming language which is laid on basic OOP Concepts. Abstraction, Encapsulation, Inheritance, Polymorphism, Object and Class. Abstraction is using basic components to represent something complex. As an example we know how to turn on the TV, but we don’t know the inside mechanism. However it does not affect to enjoy it. Basically in Java, abstraction is the representation of complex code and data using simple components like variables, classes, and objects. In simple way abstraction is the representation of the big picture by hiding the inner workings. Abstraction helps to create reusable, useful tools. It means that can create several different types variables, functions, or data structures as well as different classes of objects. Suppose if a class of variable is an address, this class will specify each address object shall have a name, street, city, and zip code and the objects are employee addresses, customer addresses, or supplier addresses. Object is any entity that has state and behavior. An object can be physical or logical. An Object can be an instance of a class which contains an address to allocate space in the memory. They can communicate without the details of each other's data or code and the only important thing is to know is type of message accepted and the type of its response.
As examples:
§  Book
§  Tree
§  Toy
§  Computer
§  Car

Polymorphism allows using the same keyword to give out various things in various contexts. One type of polymorphism in Java is known as method overloading. There different meanings are given out by the code itself and the other type is method overriding. There different meanings are given out by the values declared for the variables. A class is a blueprint from which you design individual objects. A class is a logical entity. Classes do not occupy any space. A class can be defined as collection of objects. Inheritance allows creating new classes that share required attributes of existing classes. Inheritance helps to build on previous work without implementing it again. Inheritance allows new class adopts the properties of another class. The inheriting class is known as a subclass. The original class is often known as the parent class. We use extends” keyword to define inheritance. Encapsulation is the way of storing fields within a class which is private, then accessing these fields by using public methods. The process of encapsulation is a protective barrier that holds the data and code secure within the particular class. By doing so we can reuse variables or code components without permitting open access to the relevant data system wide. Encapsulation is re-using functions so that save a lot of time. We can create particular code that calls data from a specific database and reuse that code with other databases or processes. This can be done while keeping original data in private and can change original code without affecting other reused occasions.
 -Java OOP Concepts-

Comments

Post a Comment

Popular posts from this blog

Solid Principles in Java

OOP Design Patterns