SlideShare a Scribd company logo
3
Most read
8
Most read
10
Most read
S.SANDHIYA-181611
P.DHIVYA-181602
S.B.K COLLEGE
ARUPPUKOTTAI
To
K.Padma priya M.Sc,M.Phill
Dep of maths (CA)
SBK College ,
ARUPPUKOTTAI
Classes,object and methods java
Definition of class
and objects:
 JAVA program must be encapsulated
in class that defines the state and
behaviour of the basic components
known as objects classes create
object and objects use methods to
communicate between them.
In JAVA the data items are called
fields and functions are called
methods.
Defining a class:
Class is a were defined data
type.once the class type has been
defined then we create variables of
type using declaration syntax.
Class class name{extends superclass}
Class classname{extends
superclassname}
{
{variable declaration}
Adding variables:
 Data is encapsulation in class by
placing data field inside the body of
class def.These variables are known
ass instance variables.we can declare
the instance variables exactly the
same way to declare the local
variables.
Eg:
Class Rectangle
{
int lenth;
int width;
}
Class rectangle containss the two integer
type instance variables.It allowed to
declare them in one line.
int length,width;
Instance variable also known as
member variables.
Adding methods:
A class with only data field has no
file.We must add methods that are
necessary for manipulating the data
contained in the class.Methods are
declared inside the body of the
class.syntax,
Type
methodname(parrameter list)
{
Creating objects:
Object in JAVA is a block of memory
that contains space to store all the
instance variables.Creating an object
is also referred to infantiating an
object.
Rectangle rect1;
rect1=new Rectangle();
Accessing class
members:
 We created objects each containing
its own set of variables and assign
values to these variables in order to
use our program.All variables must be
assigned values before they are used.
 We cannot access the instance
variables and the methods directly.
Objectname.variable
name
This again can be done in two ways.
The first approach is to access the
instance variables using the dot
operator and compute the area.That
is,
 Int
area1=rect1.length*rect1.width;
The second approach is to call the
method rectArea declared inside the
class.That is,
int area1=rect1.rectarea();
Constructors:
JAVA supports a special type of
method called a constructor,that
enables an oobject to initialize itself
when it is created.
Constructors have the same name as
the class itself.secondly,they do not
specify a return type,not even
void.this is because they return the
instance of the class itself.
Methods overloading:
 JAVA to create methods that have
the same,but different parameter list
and different definitions.This is called
method overloading.
 JAVA matches up the method name
first and then the number and type of
parameter to decide which one of the
definites to excute.This process is
known as polymorphism.
Static members:
Class basically contains two sections.
One declares variables and the other
declares methods.These variables and
methods are called is instance
variables and instance methods.
Member can be defined as follows,
static int count;
static int max(int x,int y);
Nested of methods:
The class nesting defines one
constructor and two methods,namely
largest( )and display ( ) calls the
method largest( ) to determine the
largest of the two numbers and then
displays the result.

More Related Content

PPT
Abstract class in java
PPTX
Constructor in java
PPTX
Java package
PPTX
Access specifiers(modifiers) in java
PPTX
Super keyword in java
PPTX
Polymorphism in java
PDF
Arrays in Java
PPTX
Constructor in java
Abstract class in java
Constructor in java
Java package
Access specifiers(modifiers) in java
Super keyword in java
Polymorphism in java
Arrays in Java
Constructor in java

What's hot (20)

PPSX
Data Types & Variables in JAVA
PPTX
Java exception handling
PPTX
class and objects
PPTX
I/O Streams
PPTX
Structure of java program diff c- cpp and java
PPTX
Java awt (abstract window toolkit)
PPTX
Packages in java
PPTX
Operators in java
PPS
Java Exception handling
PPTX
File handling
PPTX
PPTX
Type casting in java
PPTX
String, string builder, string buffer
PPT
Exception Handling in JAVA
PPTX
classes and objects in C++
PDF
Java thread life cycle
PPTX
Methods in java
PPTX
Java abstract class & abstract methods
PPTX
Static Members-Java.pptx
PPTX
Applets in java
Data Types & Variables in JAVA
Java exception handling
class and objects
I/O Streams
Structure of java program diff c- cpp and java
Java awt (abstract window toolkit)
Packages in java
Operators in java
Java Exception handling
File handling
Type casting in java
String, string builder, string buffer
Exception Handling in JAVA
classes and objects in C++
Java thread life cycle
Methods in java
Java abstract class & abstract methods
Static Members-Java.pptx
Applets in java
Ad

Similar to Classes,object and methods java (20)

PPTX
Ch-2ppt.pptx
PPTX
classes-objects in oops java-201023154255.pptx
PPTX
1707325642974_Classes fffand objects.pptx
PPT
Classes & objects new
PPTX
C# classes objects
PPTX
Classes,object and methods jav
PPT
packages and interfaces
PPTX
Classes objects in java
PPTX
Chapter 3
PPTX
702641313-CS3391-OBJORIENTEDPS-Unit-2.pptx
PDF
Wrapper classes
PPTX
Classes, objects in JAVA
PDF
Java defining classes
DOC
Delphi qa
PPTX
Hemajava
PPT
4 Classes & Objects
PPT
Reflection
PPT
Ap Power Point Chpt4
PPT
classandobjectunit2-150824133722-lva1-app6891.ppt
PPTX
classes and objects of python object oriented
Ch-2ppt.pptx
classes-objects in oops java-201023154255.pptx
1707325642974_Classes fffand objects.pptx
Classes & objects new
C# classes objects
Classes,object and methods jav
packages and interfaces
Classes objects in java
Chapter 3
702641313-CS3391-OBJORIENTEDPS-Unit-2.pptx
Wrapper classes
Classes, objects in JAVA
Java defining classes
Delphi qa
Hemajava
4 Classes & Objects
Reflection
Ap Power Point Chpt4
classandobjectunit2-150824133722-lva1-app6891.ppt
classes and objects of python object oriented
Ad

More from Padma Kannan (13)

PPTX
B tree
PDF
Operators in C++
PPTX
Java packags
PPTX
Java and c++
PDF
Inheritance
PPTX
Functions in c++
PPTX
Functions in c++,
PPTX
Functions of dbms
PPTX
Basic concept of oops
PPTX
LEARNING BASES OF ACTICITY
PPTX
Social networking risks
PDF
Inheritance
PPT
Excel2002
B tree
Operators in C++
Java packags
Java and c++
Inheritance
Functions in c++
Functions in c++,
Functions of dbms
Basic concept of oops
LEARNING BASES OF ACTICITY
Social networking risks
Inheritance
Excel2002

Recently uploaded (20)

PPTX
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Machine learning based COVID-19 study performance prediction
PDF
Encapsulation theory and applications.pdf
PDF
KodekX | Application Modernization Development
PPT
Teaching material agriculture food technology
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
Electronic commerce courselecture one. Pdf
PPTX
A Presentation on Artificial Intelligence
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
Digital-Transformation-Roadmap-for-Companies.pptx
Machine learning based COVID-19 study performance prediction
Encapsulation theory and applications.pdf
KodekX | Application Modernization Development
Teaching material agriculture food technology
Building Integrated photovoltaic BIPV_UPV.pdf
Diabetes mellitus diagnosis method based random forest with bat algorithm
Dropbox Q2 2025 Financial Results & Investor Presentation
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
Understanding_Digital_Forensics_Presentation.pptx
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
NewMind AI Weekly Chronicles - August'25 Week I
Electronic commerce courselecture one. Pdf
A Presentation on Artificial Intelligence
Spectral efficient network and resource selection model in 5G networks
Per capita expenditure prediction using model stacking based on satellite ima...
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Agricultural_Statistics_at_a_Glance_2022_0.pdf
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx

Classes,object and methods java

  • 1. S.SANDHIYA-181611 P.DHIVYA-181602 S.B.K COLLEGE ARUPPUKOTTAI To K.Padma priya M.Sc,M.Phill Dep of maths (CA) SBK College , ARUPPUKOTTAI
  • 3. Definition of class and objects:  JAVA program must be encapsulated in class that defines the state and behaviour of the basic components known as objects classes create object and objects use methods to communicate between them. In JAVA the data items are called fields and functions are called methods.
  • 4. Defining a class: Class is a were defined data type.once the class type has been defined then we create variables of type using declaration syntax. Class class name{extends superclass} Class classname{extends superclassname} { {variable declaration}
  • 5. Adding variables:  Data is encapsulation in class by placing data field inside the body of class def.These variables are known ass instance variables.we can declare the instance variables exactly the same way to declare the local variables.
  • 6. Eg: Class Rectangle { int lenth; int width; } Class rectangle containss the two integer type instance variables.It allowed to declare them in one line. int length,width; Instance variable also known as member variables.
  • 7. Adding methods: A class with only data field has no file.We must add methods that are necessary for manipulating the data contained in the class.Methods are declared inside the body of the class.syntax, Type methodname(parrameter list) {
  • 8. Creating objects: Object in JAVA is a block of memory that contains space to store all the instance variables.Creating an object is also referred to infantiating an object. Rectangle rect1; rect1=new Rectangle();
  • 9. Accessing class members:  We created objects each containing its own set of variables and assign values to these variables in order to use our program.All variables must be assigned values before they are used.  We cannot access the instance variables and the methods directly. Objectname.variable name
  • 10. This again can be done in two ways. The first approach is to access the instance variables using the dot operator and compute the area.That is,  Int area1=rect1.length*rect1.width; The second approach is to call the method rectArea declared inside the class.That is, int area1=rect1.rectarea();
  • 11. Constructors: JAVA supports a special type of method called a constructor,that enables an oobject to initialize itself when it is created. Constructors have the same name as the class itself.secondly,they do not specify a return type,not even void.this is because they return the instance of the class itself.
  • 12. Methods overloading:  JAVA to create methods that have the same,but different parameter list and different definitions.This is called method overloading.  JAVA matches up the method name first and then the number and type of parameter to decide which one of the definites to excute.This process is known as polymorphism.
  • 13. Static members: Class basically contains two sections. One declares variables and the other declares methods.These variables and methods are called is instance variables and instance methods. Member can be defined as follows, static int count; static int max(int x,int y);
  • 14. Nested of methods: The class nesting defines one constructor and two methods,namely largest( )and display ( ) calls the method largest( ) to determine the largest of the two numbers and then displays the result.