In an effort to understand object oriented programming more deeply and learn a new programming language, I've decided to learn JAVA!!! Thank you to Congnizant for sponsoring a Java bootcamp with UNC Charlotte's continuing education program.
Java helped me solidify a few concepts that were previously lost on me. Let's get into it, here are the four major Java OOP principles . Abstraction is about hiding implementation details from the user while only sharing the functionality. For instance, we can mark a method as abstract and each child class that extends the parent will have to provide it's own implementation. We also have the option to use interfaces with or without default methods. Next up is Encapsulation, or data hiding. When we create a class, we should make variables private from other classes and public getters and setters. Think of an ATM. There is a public interface that we interact with but private implementation behind the scenes that does all the work and handles sensitive data. Inheritance is the ability that allows Java classes to be derived from other classes. The parent is called the superclass and derivatives are subclasses. Subclasses inherit all public and protected fields and methods from their superclasses. The Object class is the mother of all classes in Java. Java has a single inheritance model, meaning that every class has only one direct superclass. Finally we'll look at polymorphism. Polymorphism means "many forms". Java allows subclasses to define their own behaviors while sharing some of the same functionality of the superclass. You know if an object is polymorphic if it passes more than one "is-a" test. If Class Dog extends Animal. Dog is a Dog and an Animal. It's polymorphic.
My Java journey began with a quest to know just what OOP really means and how to best navigate. Properly using these 4 principles will allow us to write fewer lines of code and maintain our code better.
Java helped me solidify a few concepts that were previously lost on me. Let's get into it, here are the four major Java OOP principles . Abstraction is about hiding implementation details from the user while only sharing the functionality. For instance, we can mark a method as abstract and each child class that extends the parent will have to provide it's own implementation. We also have the option to use interfaces with or without default methods. Next up is Encapsulation, or data hiding. When we create a class, we should make variables private from other classes and public getters and setters. Think of an ATM. There is a public interface that we interact with but private implementation behind the scenes that does all the work and handles sensitive data. Inheritance is the ability that allows Java classes to be derived from other classes. The parent is called the superclass and derivatives are subclasses. Subclasses inherit all public and protected fields and methods from their superclasses. The Object class is the mother of all classes in Java. Java has a single inheritance model, meaning that every class has only one direct superclass. Finally we'll look at polymorphism. Polymorphism means "many forms". Java allows subclasses to define their own behaviors while sharing some of the same functionality of the superclass. You know if an object is polymorphic if it passes more than one "is-a" test. If Class Dog extends Animal. Dog is a Dog and an Animal. It's polymorphic.
My Java journey began with a quest to know just what OOP really means and how to best navigate. Properly using these 4 principles will allow us to write fewer lines of code and maintain our code better.
Comments
Post a Comment