Java Installation and Object-Oriented Programming (OOP) Principles

 

Source: Rana, K. (2023, April 27). Introduction to Java [Online Image]. ArtOfTesting. https://artoftesting.com/what-is-java
Note. Image sourced from Rana, K. (2023, April 27). Introduction to Java [Online Image]. ArtOfTesting. https://artoftesting.com/what-is-java

Installing and getting started with Java programming does not have to be complicated. This post will help beginners install the Java Development Kit (JDK) and an integrated development environment (IDE) to write, compile and run programs. In addition, we will discuss the concepts and features of object-oriented programming design principles to help beginners become more familiar with these ideas.

You will want to install the most recent and stable version of Java or JDK to get started. The JDK provides the tools needed to write Java programs which can be found here Java Download. To write, compile and run your Java code, you will need an IDE. An IDE is a software application that allows programmers to write and debug software code. There are many IDEs to choose from, and it may take installing a few to find the one that works best for you. 

Oracle, the current owner of Java, recommends using Netbeans, which can be downloaded here NetBeans Download. To avoid issues with installing the IDE, make sure to install the JDK first. The IDE will search for the JDK, and if it is not found will prompt you to install Java. If you run into any issues, the following link will help guide you through installation and writing your first program Java Tutorials.

It is also important to understand the four main principles of OOP, which can make your programs more flexible and manageable. The four main principles include Encapsulation, Abstraction, Inheritance, and Polymorphism. Don't let the names discourage you. These principles, once explained, are easy to understand and remember. 

Encapsulation

This first principle is basically a rule that separates objects from each other. According to Petkov (2018), "Encapsulation is achieved when each object keeps its state private, inside a class" (Encapsulation Section). The methods, such as variables in a private state within a class, cannot be used by other objects, which encapsulates them from other objects. Public methods are the opposite of which objects can use to modify the internal state of other objects. Not all objects should be able to change things about other objects, so they must stay protected.

Abstraction  

This second principle is often referred to as an extension of Encapsulation and aims to hide internal details that other objects do not need to see or use. Petkov (2018) explains, "Applying abstraction means that each object should only expose a high-level mechanism for using it" (Abstraction Section). This method further protects an object's methods and helps simplify large programs, and makes them more efficient.

Inheritance

This third principle can be viewed as a hierarchy of common logic and helps to share common details between similar objects. For example, a vehicle manufacturer may share similar properties between the various models they produce, such as trim, engines, and other technology but individual models will differ from other models. To share common traits between all models, we use inheritance. This allows programmers to set levels of details that can be shared amongst similar objects while retaining individual differences. 

Polymorphism

This final principle may sound complicated, but it is just a fancy word for many types. You can use the same data for many different things, even if the data is in a higher or parent class. According to GeeksforGeeks (2023), "Polymorphism is a property through which any message can be sent to objects of multiple classes, and every object has the tendency to respond in an appropriate way depending on the class properties" (Para. 3). In other words, we can use the same method for different objects and change what they do depending on the circumstances.

Now that we have reviewed how to install Java and an IDE while covering the core principles of OOP, you are ready to start creating your own programs. I would recommend starting with a simple program like "Hello Word," which can be found in the Java Tutorials. Getting the hang of it can be tricky the first few times, but with practice, you can start creating more complex and efficient programs.


References

GeeksforGeeks. (2023). Perl Polymorphism in OOPs. GeeksforGeeks. https://www.geeksforgeeks.org/perl-polymorphism-in-oops/

Petkov, A. (2018, June 27). How to explain object-oriented programming concepts to a 6-year-old. freeCodeCamp. https://www.freecodecamp.org/news/object-oriented-programming-concepts-21bb035f7260/

Comments