Introduction to Java and OOP
Introduction to Java and OOP
Hello all!
My name is Daniel and today in my blog we will be covering how to get setup and started with Java, as well as some of the basics of object-oriented programming, henceforth referred to as OOP.
Java setup:
First things first, you will want to get Java setup. I recommend the JDK17 as this is the latest LTS (long term support) package. It will continue to get steady updates until September of 2024. You can find it here. Pick whichever version is needed for your operating system and go ahead and get it installed. I recommend an .exe file if you're on windows, a .dmg file if on Mac, or a .rpm file if on a variant of Redhat Linux. For the sake of brevity, I will not explain a step-by step on how to install it here. However, if you need more assistance the link found here gives a good guide on the process.
Next, you will want to pick an IDE for your development. I recommend Visual Studio Code or IntelliJ. Personally, I use Visual Studio Code as it's what I'm most used to and comfortable with. Personally, I had some minor issues with setting up Java within VSCode due to it not finding the JDK path correctly. The answers here helped me to resolve this fairly quickly, however.
OOP Basics:
To get started with OOP there are a few basic concepts that will need to be understood. I'll list these below.
- Objects
An object is one of the basic fundamentals in OOP. It is an entity that has state and behavior. These can be tangible or intangible. A chair is an example of a tangible object and the banking system is an example of an intangible object. Objects have three primary characteristics.
- State: the value of an object
- Behavior: the functionality of an object (what it does)
- Identity: a unique identifier for the object, this is usually not visible to the user but is used internally by the JVM
- Classes
A class can be viewed as a blueprint for creating objects that share common properties. This is a purely logical construct and not physical. An example would be the class "mammal" of which a created object could be "cat", "dog", "fox", or many other variations. Classes in Java often contain the following items.
- Inheritance
Inheritance is exactly as it sounds. It is when one object inherits properties from a parent object. For instance, the object "dog" would be the parent object of "Labrador" which is a type of dog. Therefore, all characteristics of a dog will be exhibited with the object "Labrador", but "Labrador" might have some individual variations on these characteristics.
- Polymorphism
Polymorphism is the concept that one action can be performed in a variety of ways. In many ways this extends upon the concept of inheritance discussed previously. Let's say class "Animal" has the action "move". We could overwrite this action in class "Fish" and set the action to "swim". This is an example of runtime polymorphism.
- Abstraction
Abstraction is the act of hiding runtime level details and only showing functionality to an end user. Abstraction can be achieved either via a class or via the interface.
- Encapsulation
Encapsulation is a process of wrapping code and data into a single unit. It can be utilized for better data control, hiding of data, or because it makes data easier to test.
Resources:
Codecademy. (n.d.). What is an IDE? Codecademy.
https://www.codecademy.com/article/what-is-an-ide
I can’t set up JDK on Visual Studio Code. (n.d.). Stack Overflow. https://stackoverflow.com/questions/52539414/i-cant-set-up-jdk-on-visual-studio-code
Java OOPs Concepts - Javatpoint. (n.d.).
www.javatpoint.com. https://www.javatpoint.com/java-oops-concepts


Comments
Post a Comment