Before 1995, Java only meant coffee, named after the Island of Java, where it is grown. As of today, Java is more of a programming language than the brew. In fact, since early 2000’s , it's one of the most popular programming language.
So, what made Java so popular?
Other than being Simple and Secure the two features that made it loved by most IT industry are Platform Independence and Object Oriented.
Java follows the slogan WORA - Write Once Run Anywhere. It means that Java program can be compiled on one machine and later can be executed on any other machine, be it Windows or Max or Linux. This portability is the biggest strength of Java.
In simple words, a compiled java code is like coffee grounds that can be used with variety of coffee makers to produce ever satisfying cup of coffee.
Java is not pure object-oriented but it supports 5 of the 7 major characteristics that make a language pure object oriented. In this post we will discuss the 4 of those characteristics
It simply means hiding unnecessary details.
Suppose you want some cappuccino. You go to a coffee shop, place an order, pay for it
and enjoy it once ready. You are unaware of the type of coffee grounds used, the
company that packaged those, the person who was responsible to prepare your coffee,
the machine that was used to prepare your coffee, the type of milk used etc. All these
details were hidden from you. Didn't it made your life a little simple and your coffee more
abstract class Coffee
String typeOfRoast ;
class Brew extends class Coffee
It is derived from 2 words- poly and morph. Poly means many and morph means form.
Something things that can exist in more than one form displays polymorphism.
Continuing with our cup of coffee, it can be a cappuccino, latte, mocha, Americano and
what not. In raw form it can be coffee beans, coffee grounds, pods or even instant
Public void Brew(int coffeeBeans, int water)
Public void Brew(int coffeeBeans, int water, int milk)
Here, we have two methods with the same name. The resulting brew will depend on what ingredient we use in the coffee machine.
It means to enclose, like in a capsule. It is done to wrap up data and code together as
one single unit.
In encapsulation, the variables of a class can be accessed only through the methods of
their current class. Methods outside of that class can't access them.
What could be a better example other than k-cup pods which can only be used by Keurig
Private int k-pod;
Public int water;
Since the k-pods are declared as private, they can only be accessed within the class
Keurig and by the method Brew().
The classic example of inheritance is obviously parent and child where a child inherits the
qualities from its parents. To justify the title of my post, I would like to present you with an
example of coffee as well. Here the parent will be coffee beans that are brewed and the extract
is dried to prepare coffee powder (child). This instant coffee inherits the properties of the coffee
beans like color, taste and aroma.
String typeOfRoast ;
class InstantCoffee extends Class Coffee
In this world, things are quite complicated. To simplify, I always try to relate them with our day to day activities. My main purpose behind writing this blog was to simplify these Java concepts for people who find it difficult to understand the technical language.
This is my first blog. I hope you enjoyed and understood these basics of Java. I will meet you next time with another topic over a cup of coffee.
Please give a thumbs-up and share this post with friends and family. I would love your feedback, so please leave a comment.