Classes and Object in Java
Classes and Object in Java
Presentation by
Mrs.S.Janani
Assistant Professor
Department of Information Technology
[email protected]
Department of
IT
Information
Technology
Drsnsrcas/CPreprocessor/April 27, 2024 Slide No : 1
INTRODUCTION
• Object-oriented programming (OOP) involves programming using
objects. An object represents an entity in the real world that can be
distinctly identified. For example, a student, a desk, a circle, a button,
and even a loan can all be viewed as objects.
Department of
www.snsgroup.com
IT
Information
Technology
Drsnsrcas/CPreprocessor/April 27, 2024 Slide No : 3
OBJECTS
An object has both a state and behavior. The state defines the object, and
the behavior defines what the object does.
Data Fields:
radius is _______
Methods:
getArea
Department of
www.snsgroup.com
IT Information
Technology Drsnsrcas/CPreprocessor/April 27, 2024
Slide No : 4
CLASSES
Classes are constructs that define objects of the same type. A
Java class uses variables to define data fields and methods to
define behaviors. Additionally, a class provides a special type of
methods, known as constructors, which are invoked to construct
objects from the class.
The Circle class is different from all of the other classes you
have seen thus far. It does not have a main method and
therefore cannot be run; it is merely a definition for circle objects.
The class that contains the main method will be referred to in
this book, for convenience, as the main class.
Department of
www.snsgroup.com
IT Information
Technology Drsnsrcas/CPreprocessor/April 27, 2024
Slide No : 7
Example: A Bank Account Object
Department of
www.snsgroup.com
IT Information
Technology Drsnsrcas/CPreprocessor/April 27, 2024
Slide No :8
EXAMPLE
Department of
www.snsgroup.com
IT Information
Technology Drsnsrcas/CPreprocessor/April 27, 2024
Slide No :9
Department of
www.snsgroup.com
IT Information
Technology Drsnsrcas/CPreprocessor/April 27, 2024
Slide No :10
Department of
www.snsgroup.com
IT
Information
Technology Drsnsrcas/CPreprocessor/April 27, 2024