Java - Objective-Oriented Programming principles

Java - Objective-Oriented Programming principles

So, the last time we left off, we were introduced to writing our first piece of Java code and what that looks like. Now, we will dive into some of the core principles of Java; objected-oriented concepts. These core concepts include Abstraction, Encapsulation, Inheritance, and Polymorphism. With Java being an Object-Oriented Programming (OOP) language, to make things simple, it just means Java uses real-world objects which are represented while writing code. For instance, if you wish to write something dealing with payroll for employees, then you would use either people, employees, workers, or any other words to describe humans in the workplace.

Let's start with the first of the four pillars of OOP, Abstraction:

1) Abstraction is simply hiding internal details and showing only what is required. Let's use a TV as our example. The only thing revealed to the customer would be the buttons(in Java, we call these methods) needed to make changes to a device's functions such as turning the device off/on, changing stations and etc. The components of the remote are hidden from the user because the user does not need to know about the internal workings, just the functionality.

2) Encapsulation is the process of grouping data into a single section. In Java, curly braces {} keep our data within our class(es) contained. This allows for our information to be easier to read and decipher from different sections of our code.

3) Inheritance, which we touched on in our previous article on Java, means to design a class(Parent) and create other classes(Child) to 'inherit' or reuse properties associated with the Parent class. Think specialization, for example, Toyota has the Corolla, Camry, Crown, and Prius brands which contain many of the same features as any standard car would have, but they are different in their own unique way.

4) Finally, Polymorphism is a concept in which we execute a single operation in different ways(think generalization). TVs (our general object) have different brands such as LG, Samsung, and Sony. Within Java, overriding a method(runtime polymorphism) allows the Java Virtual Machine(JVM) to call the appropriate method for a class(Child) that inherits from a Parent class; given the Child class has unique characteristics of its own.

Well, I hope the concept of OOP was explained to you in a way you can understand. Trust me, it takes time to really get these concepts down. Not to mention, many programmers disagree(lol) about polymorphism from time to time. The important thing is to continue to learn and try to understand these concepts the best way you can. So, until next time, keep learning and strap on those seat belts because we will start diving into coding examples(illustrations) to bring these ideas home.

要查看或添加评论,请登录

David K.的更多文章

  • What a year(2023 Recap)!!

    What a year(2023 Recap)!!

    Greetings friends! I know, I know, it has been some time since we've heard from one another, but let me explain a bit…

  • Java Arrays

    Java Arrays

    Greetings friends! Today we will begin our introduction to some infamous or famous, depending on who you ask lol, data…

  • Java - For and ForEach Loops

    Java - For and ForEach Loops

    Good day everyone! Today's topic, while we are sadly coming to the end of the conditional statements, will revolve…

    4 条评论
  • Java - While statement

    Java - While statement

    Greetings Java fam!!! In this edition of the New Dev Journey, we will touch on the Java while statement. The great…

  • Java's Do-While statement

    Java's Do-While statement

    Good morning everyone! Today's topic will be another one of Java's conditional statements, the do-while statement. The…

    4 条评论
  • Java...If else statement

    Java...If else statement

    Java if-else example Greetings! Today's article we will dive into Java statements, in particular, the if-else…

    1 条评论
  • Java Primitive Data Types???

    Java Primitive Data Types???

    Hello everyone! Today's example will be Java's eight(8) primitive data types. These data types are very important to…

  • Java Class Example

    Java Class Example

    So, today, we are continuing our journey of learning Java. I wanted to show a small example of a Java class, attributes…

    2 条评论
  • What does a Java Program look like???

    What does a Java Program look like???

    Greetings everyone! I have posted a small snippet of what a Java program looks like. If you have read any of the…

  • Java - where do I start?

    Java - where do I start?

    So, last week was a brief introduction into Java and I do mean brief. Now, I want to dive into and answer the question,…

社区洞察

其他会员也浏览了