Java Installation
To download Java visit: https://www.oracle.com/java/technologies/downloads/#jdk17-windows
To decide on an IDE: https://www.educative.io/blog/best-java-ides-2021
To learn about the Hello, World! program: https://www.learnjavaonline.org/en/Hello%2C_World%21
To follow a NetBeans tutorial for Hello World: https://youtu.be/6En-7F8XEb8
Object Oriented Programming Principles
Objects have two characteristics- state and behavior. For instance, an oven will have two possible states- on or off and multiple behaviors such as low heat, medium heat, high heat. Software objects store their state in fields (variables) and show their behavior through methods (functions). A class is a collection of objects.
These methods (functions) act on an object's internal state. Hiding these internal states and requiring interaction to be performed through an objects method is called data encapsulation. This can be thought of as binding code and data into a single unit. This concept allows programmers to hide and restrict access to private data. This can be done through access modifiers that define the visibility of classes, methods, and attributes. From most to least restrictive the modifiers are: private, no modifier, protected, and public.
Private access modifiers make an attribute or method only accessible within the same class (Janssen, 2022). No modifiers allow attributes or methods within a class or all classes within the same package to be accessible (Janssen, 2022). Protected access modifiers can be accessed within a class, by all classes within the same package, and by all subclasses within the same or other packages (Janssen, 2022). Lastly, public modifiers can be accessed by the current class and all other classes (Janssen, 2022).
Abstraction is when only the necessary details are exposed. Everything else is hidden from the user. Abstraction defines an object in terms of its properties (
attributes), behavior (
methods), and interfaces (TechVidvan, 2021). To read more about abstract classes click
here.
Inheritance is when an object acquires all the properties and behaviors of a parent object. Inheritance is a property that makes code easily reusable. In Java, each class is allowed to have one direct superclass, and each superclass has the potential for an unlimited number of subclasses (Oracle, 2021). This can be visualized by a hierarchy.
Polymorphism is when an object can behave in different ways. In Java,
overloading and
overriding are how polymorphism is achieved. When two or more methods in the same class have the same name but different parameters, it’s called overloading (
Pankaj, 2019). When the method signature (name and parameters) are the same in the superclass and the child class, it’s called overriding (
Pankaj, 2019). To read more about the differences visit this
link.
References
Janssen, T. (2022, January 21). OOP concept for beginners: What is encapsulation. Stackify. Retrieved February 3, 2022, from https://stackify.com/oop-concept-for-beginners-what-is-encapsulation/#:~:text=By%20definition%2C%20encapsulation%20describes%20the,This%20is%20called%20information%20hiding.
Pankaj. (2019, August 23). Overriding vs overloading in Java. JournalDev. Retrieved February 3, 2022, from https://www.journaldev.com/32182/overriding-vs-overloading-in-java#:~:text=What%20is%20Overloading%20and%20Overriding,child%20class%2C%20it's%20called%20Overriding.
Oracle. (2021). What is inheritance? The Java™ Tutorials. Retrieved February 3, 2022, from https://docs.oracle.com/javase/tutorial/java/concepts/inheritance.html
TechVidvan. (2021, June 23). Abstraction in java - learn with its types and real-life examples. TechVidvan. Retrieved February 3, 2022, from https://techvidvan.com/tutorials/abstraction-in-java/#:~:text=An%20Abstraction%20is%20a%20process,are%20exposed%20to%20the%20users.
Comments
Post a Comment