Java programming: object-oriented, inheritance, encapsulation

Object Oriented

Object Orientation is a programming method designed for reuse and independence of software modules. A logical unit that assigns or classifies meaning for effective information management is called an object.

That is, communication between objects consists of messages, and each object is composed of methods for processing unique data.

The opposite of object orientation is procedural. Procedural orientation is a programming method that consists of an algorithm that changes the data with a structure of one data.

Class is a very important concept in object orientation. A class acts as a kind of template that creates an object. In Java, an object is always created from a class.

In Java, a class always consists of two parts: a “field” that represents a data structure and a “method” that is responsible for operations. Sometimes objects created from classes are also called instances. That is, instances and objects are used interchangeably.

In Java, the object is responsible for processing information, not the class. Object-oriented programming creates a class and then creates an object with the class you created. The generated objects process various information and execute the logic of programming. Objects can be created using new reserved words as shown below.

Student1 = new Student(mark, male, 21);
Student2 = new Student(james, male, 19);
Student3 = new Student(joana, female, 25);

Inheriting classes

Classes can inherit from each other. Inherited classes form a hierarchy, and in inheritance, classes in the lower hierarchy inherit all elements in the upper hierarchy. Of course, inheriting classes can create new data structures or add new methods.

A subclass that inherits is a concept that extends the superclass. In other words, it implement software that can be reused through inheritance. When you create a new class through inheritance, you declare it as a subclass of an existing class and extend the functionality of the existing class by adding properties or methods in the newly created class.

Encapsulation

Java programming has the concept of encapsulation. Encapsulation is a way to hide the logic that performs the actual processing and provide only the functions of the object. By creating the information that should be hidden and the information that should be disclosed when the object programming is done, the user uses only the function of the object. And since the logic that handles the functions of the object is not disclosed, the stability of the program can be secured.

Encapsulating a program can prevent damage to the information contained in the object. It can only be used with a certain usage, which prevents misuse of the program and keeps independence because the data does not affect other objects even if the data is changed. It has excellent portability because you can get processed results only through the functions provided by the object. In other words, the object itself can be modularized and applied to the new system.

Leave a Reply

Your email address will not be published. Required fields are marked *

Latest Post

  • Mastering the daily conversation in 4 languagesBasic sentences expressing my mood – I’m
  • 8 things you need to think about for work-life balance
    View on Youtube Image: juliezhuo.com who works as a design VP for Facebook, presented 8 ways for work and life balance in her article “The
  • 10 special abilities of Smartphone
    View on Youtube No matter where you go or what you do, your smartphone is always with us. We use the internet with a smartphone,
  • Java: abstract class, abstract method
    An abstract class in Java is a class that declares an abstract function to be implemented in a subclass as an abstract method. An abstract
  • Java: inheritance and constructors
    When an object is created from an inherited class, the constructor of the superclass is performed before the constructor of the subclass. That is, when
  • Java reserved words: super, final
    super is a Java reserved word that is used to access member variables or methods of a superclass that is obscured by a subclass. Access
  • Java: finalize method and garbage collection
    The Java Virtual Machine(JVM) automatically performs garbage collection for objects that are no longer needed for efficient system operation. At this point, the JVM calls
  • Java: Method overloading
    Method overloading is the same concept as constructor overloading. That is, you can use methods of the same name in the same class, but methods
  • Java final variable
    You can specify an end variable using the reserved word final. The final variable represents a constant value that can not be changed. Typically, final
  • Java class variables
    Class variables are declared with static and have the concept of global variables. Class variables are used for the following purposes. Object references and object