Education logo

Java and Oops Concept for Beginners

Understanding Concept of Object

By jaiya DwivediPublished 4 years ago 7 min read
Java and Oops Concept for Beginners
Photo by Tom Bressolles on Unsplash

Java Language is an object-oriented programming language developed by James Gosling of Sun Micro systems. It is designed to create executable content such as applets, applications and handlers.

Java Tools include the Java Compiler, Interpreter, Documentation, Debugger and Class libraries from which developer build actual Java Programs.

Java Virtual Machine(JVM) is a specification to which we must write Java code.

All Java Code is compiled for use on this non-existent machine. Writing Code that runs under the Java Virtual Machine helps ensure platform independence. It is a set of specifications that define how Java bytecode is to be handled on a given computer system. Java programs can execute on any computer that has a virtual machine present.

The Java Technology

The Java Technology consists of Three entities :

• The Language itself

• A Runtime Environment

• A Set of Tools

Concept of Object Oriented : Object Oriented simply means things together as object. Treating Everything in this world as an OBJECT and then studying at object’s functions and features like how they look, how they act and how they interact with other objects.

Meaning of Object: Object is that capability which represent data and functions that operate on that data in one software bundle.

Take an example of a CAR as an object. So, its features are color of the car, speed or how fast it is?

How comfortable it is? How costly it is?

Or take another example of your pet DOG: Always hungry, run very fast when see a cat, has black in color, has four legs, two eyes.

Thus each feature again can be studied as an object i.e. his food, his taste etc. In software development this point is implemented and it is called as Oops means Object Oriented Programming Structure. The Developer of Oops see everything as an object. When they develop they create entities in code known as objects. These code objects contain state and behavior just like real world entities we discussed above of car and dog.

Features of Object Oriented Programming

Abstraction : It means abstract the essential and leave the non-essential things. If we consider the example of CAR we can say that when we travel in the car we do not bother about the engine, axle, tires rather we keep eye on the traffic and our destination. In our pet’s example also we only bother about his eating, sleeping and day to day activities rather than his color or breed every day. Thus Abstraction focuses on the essential and ignoring the non-essential.

Developers should do exactly the same thing while developing. They must consider what the essence of each object in their development A good developer must first identify the essential functions of the object and then select the relevant data to those functions. The data and functions together makes a software object which is known as STATE and BEHAVIOUR.

STATE is object’s knowledge and how it looks like i.e. color of dog, breed and personality etc.

BEHAVIOR is object’s action i.e. eating, sleeping or running.

STATE and BEHAVIOR together form the identity of that object. Object’s state and behavior may change in due course of time. For e.g. Bulb is ON or OFF, DOG is sleeping or not, CAR is moving or not.

An object’s behavior is the only thing that can change that object’s state so state in this way is protected which is the most important feature of Oops.

In Java, an object’s state consists of variables, and behavior is implemented as functions called methods. The combination of variables and methods together maintains state and behavior, and these two are combined into a single object. Data residing inside an object is surrounded by the methods of that object, protected from direct manipulation.

Encapsulation : It simply means hiding information. Now here in Java it means information that is not useful or not related to other functions or programs, java will hide it that information from them. As we are reading object oriented language so hiding simply means data that is inside the object. That is hidden from all other except the methods of that object. In other words, the information which is inside the object is its inner working and so that information are never made available to anyone but the object itself. The only way to get that information in an object is by calling its methods. Thus encapsulation permits objects to operate completely independently of each other as discrete and self contained bunch of data and code. In this way data and implementation can change without breaking the system.

The best example of encapsulation is when we upgrade the HARD DRIVE or RAM of our system, we don't have to worry about interacting with the system.

Interfaces : In object Oriented Programming object interact with each other through similar interfaces all the time. Objects send messages to other and other objects respond in response. Like giving food to pet. for that we have to open the container of food, keep some food in plate and keep that plate in front of the pet. This is specific act (behavior) of pet everyday. Plate will not change only the food will. So giving food and eating by pet is daily routine function. Thus Software objects are simple and so they provide simple interface to their data and behavior, through which other objects can interact with them. The first user interface in our daily life was the introduction of remote of our gadgets. To use remote we do not need to know about the inside setup or mess up of wires instead we only use the different buttons given on the remote control. TV set and Remote are two interfaces which easily enables us to communicate.

Messages :In object-oriented programming, objects are constantly communicating with each other through a complex web of messages. Messages are for communicating with the objects. Objects weave a complex web of messages to communicate with each other. Software Programs written in Object Oriented Languages like Java are full of objects. These objects access and edit their own data or information through their own methods or functions.

For example when we keep wet clothes in dryer of washing machine and set timer for drying the clothes means we are interacting with the internal functions of washing machine, which instructs the internal program to run the fan as soon as we switch on the button.

The message must be clearly stated in accordance with the interface of the object so that it should be understood. What will happen if message to dry the cloth i.e.to run the fan will not written properly?

Thus methods should be written in accordance with some purpose. The messages are sent by the objects should be able to trigger the execution of methods inside other objects. If required, they can also contain their required parameters.

Thus there is one object sending message and another receiving it. So the object receiving the message is on the left side and the message is on the right side, separated by dot.

like in drying the clothes by washing machine, the messages may be something like this

Washingmachine.dryClothes();

Modularity : Objects contain both variables and methods. In Object Oriented Programming data and behavior are neatly packaged inside objects and the only way to access data is through the interface as described above by the methods. We can change the inside working of an object without breaking the rest of the system. This is the feature called Modularity.

Classification : Object Oriented Programming groups things as per their classification. Objects are classified according to their features. Every object is created from a class. Classes and Objects are often use interchangeably.

Classes are like blueprints. It is like template in which source code is written and objects are created. These classes contain all the variables and methods which an object will possess.

Classes in Java Language

Java class is template from which we create objects. Classes defines data types, methods, gives objects its behavior and an interface. With interface, object communicates with other objects. The Java keyword class is used to define Java Classes.

The Form of Java Class

class name{

...... instance variables ....

...... method declaration ...

}

Instantiation : Instance means example or copy of. Here instantiation means to instantiate an object from class. To make it we can use methods of that class in another newly created class by instantiating it. The benefit of this is that repetition can be avoided and thus developers time is saved. When method is created it is reused many times by instantiating in another classes.

The new word is used to initialize an object. new word gives value to initialized object in memory.

Inheritance : As name suggests inheritance means to take some or all features from our fathers or forefathers. Here it means to take it from one level above i.e. its super class. Suppose we made a class having two to three methods so we can inherit these methods in our newly created class. We can reuse the code by inheriting the class. All objects of the class inherit its variables and methods. Another feature is that new subclass can be created which will inherit all the features of its super class as well as define its own new variables and methods.

Inheritance is the most powerful feature of any object oriented language because it the code we write once can be reused by this feature.

Know More at www.appbasics4u.com

how to

About the Creator

Reader insights

Be the first to share your insights about this piece.

How does it work?

Add your insights

Comments

There are no comments for this story

Be the first to respond and start the conversation.

Sign in to comment

    Find us on social media

    Miscellaneous links

    • Explore
    • Contact
    • Privacy Policy
    • Terms of Use
    • Support

    © 2026 Creatd, Inc. All Rights Reserved.