Lec 3

advertisement
Lec 3
INTRODUCTION
• Java is a new object-oriented language that is
receiving wide attention from both industry
and academia.
• Java is often described as a Web
programming language because of its use in
writing programs called applets that run within
a Web browser.
CLASSES AND OBJECTS
• an object is a thing, both tangible and intangible, that
we can imagine.
Ex. For a program to keep track of student residents of a
college dormitory
• A class is a kind of mold or template that dictates
what objects can and cannot do. An object is called an
instance of a class.
BENEFITS OF OBJECTS
• Modularity
• Information hiding(API)
• Class diagrams
1.Doughnut diagrams
2. Object Modeling Technique(OMT) diagrams
3. Unified Modeling Language (UML) diagrams
MESSAGES
• To instruct a class or an object to perform a task, we
send a message to it. For example, we send a
message deposit to an Account object to deposit
$100.
• For a class or an object to process the message it
receives, it must possess a matching method, which is
a sequence of instructions that a class or an object
follows to perform a task
A value we pass to an object is called an argument
of a message.
• A method defined for a class is called a class method,
and a method defined for an object is an instance
method
CLASS AND INSTANCE DATA VALUES
Download