Skip to content

Instantly share code, notes, and snippets.

@ElBell
Last active May 23, 2019 22:01
Show Gist options
  • Select an option

  • Save ElBell/84bb333f7c2dbdff7b7e88d81a4e5936 to your computer and use it in GitHub Desktop.

Select an option

Save ElBell/84bb333f7c2dbdff7b7e88d81a4e5936 to your computer and use it in GitHub Desktop.

Core Java 11th edition

We're going to walk through a simple program to learn about the principles of OOP.
Each Repl.it below contains the functionally same program, but written differently each time.
When you click run, the program will prompt you for an animal to speak to.
For example, if you type "dogsay woof woof" a dog will appear with a speech bubble above its head saying "woof woof"
You'll be adding an animal of your own, pick something cute!

Object-Oriented Programming

"Simply stated, object-oriented design is a programming technique that focuses on the data-objects and on the interfaces to those objects."
"Each object has a specific functionality, exposed to its users, and a hidden implementation."

OOP Repl.it

Polymorphism

"The fact that an object variable can refer to multiple actual types"
"The "is-a" rule states that every object of the subclass is an object of the superclass."

Repl.it sans Polymorphism

Inheritance

"You can create new classes that are built on existing classes. When you inherit from an existing class, you reuse its methods , and you can add new methods and fields to adapt your new class to new situations"

Repl.it sans Inheritance

Encapsulation

"Combining data and behavior in one package and hiding the implementation details from the users of the object"

Repl.it sans Encapsulation

Abstraction

"The concept of exposing only the required essential characteristics and behavior with respect to a context."

Repl.it sans Abstraction

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment