Session 1
Object
Shapes
Mammals
A Dog has name,
It has some color,
It belongs to a breed,
It may be hungry.
name , color, breed, hungry are the attributes of Dog
object.
Dog can bark, search, eat ……..
Bark, search, eat define some behaviour of Dog object.
Behavior (Doing Responsibility) is how an object
reacts, in terms of its state changes, in response to
operations performed upon it.
Class
Class Defines the attributes and behaviour of the
objects.
Class is the blueprint of the objects.
Objects are physical entity and class is the logical
construct of the objects.
An object has some states.
• State(Knowing Responsibility) is a set of properties
which can take different values at different times in
the object’s life.
• Every object has an unique identity number.
Object has following characteristics-
» State
» Behavior
» Attributes
» Identity
Java Objects & Class
Contd.
• Example:
• Mr. White is married. He teaches OO Software
Engineering classes on Fridays. He is a part-time
member of the faculty at the CS Department of
the All-Smart Institute. John is enrolled in the
OOSE class that Mr. White teaches. Mrs. White
uses a Nano for transportation to and from the
campus (she teaches Philosophy at the same
institute). Class size is limited at the institute to 14
students. Janet, the sister of John is enrolled for
violin course in the same institute.
Identify all the objects & Similar
Objects / Class or Type that defines the objects …
Java Objects & Class
Contd.
• OBJECTS are:
Mr. White Mrs. White John
Janet Student
Faculty Faculty Student
Nano Philosophy CS All-Smart
Car Department Department Institute
OOSE Violin
Course Course
Properties of Object Orientated
Programming (OOP)
Common properties of OOP is given
below-
• Abstraction
• Encapsulation.
• Inheritance.
• Polymorphism.
Java as Object Orientated
Programming
Java Source Java Compiler Bytecode
Code(.java file) (javac) (.class file)
Interpreter Interpreter Interpreter
JVM JVM JVM
Windows Unix Mac
Executable file(Output)
• Example Java program to print “HELLO WORLD”
class exampleHW
{
public static void main (String args[])
{
System.out.println (“HELLO WORLD” );
}
}
Java Programming Elements
Contd.
Datatype Size
byte 8 bits
short 16 bits
int 32 bits
long 64 bits
float 32 bits
double 64 bits
Character takes 16 bits(Unicode), and size of the
Boolean data type is machine dependent.