Discuss the object oriented approach
Discuss the drawbacks of traditional
Discuss object oriented programming
Discuss basic Object-Oriented concepts such as
objects, classes, properties, methods, abstraction,
inheritance, encapsulation, reusability and
Describe Java Virtual Machine
Write the First Java Program
The Object-Oriented Approach
The real world around is full of objects .We can consider both the living
beings as well as non living elements as objects.
For example, the different departments in a company are objects.
Drawbacks of Traditional
Problems in modification of data
Difficulty in implementation
Object – Oriented
Transact with banks
Here the application has to implement the entities as they are seen in real life and
associate their actions and attributes with each other.
Some real-life entities :
Vehicles in a traffic -monitoring application
Electrical components in a circuit design problem
Elements of the computer-user environment
An object is an element with defined boundaries that is relevant to the problem we
are dealing with
Collections of data
An inventory of machine parts
A personnel file
User defined data types
Model : Ferrari
Color : Red
Year : 1995
A class is a group of objects that have the same properties, common behavior.
Polygon objects Polygon class
Encapsulation is a process that allows
selective hiding of properties and
methods in a class.
Not accessible from outside
Accessible from outside class
Inheritance is the property that allows the reuse of an existing class to build a
Data abstraction is a process
of identifying properties and
methods related much to a
particular entity as relevant to
Eat and drink
Hunt big game
Polymorphism allows same method to behave differently on different classes.
Class : Shape
Object – Oriented Languages
The Problem with High Level
written for a
platform will not
work on another
Program To solve this
make use of
So the code for any application can be written only once, which can then be
executed with the help of Interpreters created for different platformsJigar Jobanputra(JJ)
Java is a language from SUN Microsystems.
Java uses an Interpreter to execute code so that it may run on different
computers without any change to the source code.
Java Programs are platform independent. Hence the code written in Java can be
executed on different platforms.
Java is a program mainly used for Web based applications because of its
support to different platforms.
Java is purely an Object Oriented Programming language.
Java Virtual Machine (JVM)
Java Virtual Machine
For each computer, there is a unique Java Virtual Machine
Machine language code
Life Cycle of a Java Program
Java Virtual Machine
Execution procedure by the JVM
The Java Virtual Machine creates a runtime system
internally that helps the execution of code by :
Loading the “ . class ” files.
Managing the memory.
Performing Garbage collection.
Java code and JVM
All java programs are written keeping in mind the
The Java source code and the byte code is machine
independent while JVM is machine dependant.
Different machines with different Operating system
will require a JVM developed for that machine.
public static void main( String args)
System.out.println(“Welcome to the
world of Java”);
First Program [Contd…]
• Save the file as HelloJava.java
• Use the javac command to compile the
• Execute the bytecodes of
HelloJava.class using the java