Java Session1
Java Session1
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.
» 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
OOSE Violin
Course Course
Properties of Object Orientated
Programming (OOP)
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