SlideShare a Scribd company logo
1 of 14
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
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

What's hot

input/ output in java
input/ output  in javainput/ output  in java
input/ output in javasharma230399
 
Control Statements in Java
Control Statements in JavaControl Statements in Java
Control Statements in JavaNiloy Saha
 
Type casting in java
Type casting in javaType casting in java
Type casting in javaFarooq Baloch
 
Classes, objects in JAVA
Classes, objects in JAVAClasses, objects in JAVA
Classes, objects in JAVAAbhilash Nair
 
Pointers,virtual functions and polymorphism cpp
Pointers,virtual functions and polymorphism cppPointers,virtual functions and polymorphism cpp
Pointers,virtual functions and polymorphism cpprajshreemuthiah
 
class and objects
class and objectsclass and objects
class and objectsPayel Guria
 
structure and union
structure and unionstructure and union
structure and unionstudent
 
Inline function
Inline functionInline function
Inline functionTech_MX
 
Java awt (abstract window toolkit)
Java awt (abstract window toolkit)Java awt (abstract window toolkit)
Java awt (abstract window toolkit)Elizabeth alexander
 
Data Structures in Python
Data Structures in PythonData Structures in Python
Data Structures in PythonDevashish Kumar
 
Class and Objects in Java
Class and Objects in JavaClass and Objects in Java
Class and Objects in JavaSpotle.ai
 
Types of Constructor in C++
Types of Constructor in C++Types of Constructor in C++
Types of Constructor in C++Bhavik Vashi
 

What's hot (20)

Java input
Java inputJava input
Java input
 
Interface in java
Interface in javaInterface in java
Interface in java
 
Java program structure
Java program structureJava program structure
Java program structure
 
input/ output in java
input/ output  in javainput/ output  in java
input/ output in java
 
Recursive Function
Recursive FunctionRecursive Function
Recursive Function
 
C# classes objects
C#  classes objectsC#  classes objects
C# classes objects
 
Control Statements in Java
Control Statements in JavaControl Statements in Java
Control Statements in Java
 
Type casting in java
Type casting in javaType casting in java
Type casting in java
 
Functions in C
Functions in CFunctions in C
Functions in C
 
Classes, objects in JAVA
Classes, objects in JAVAClasses, objects in JAVA
Classes, objects in JAVA
 
Pointers,virtual functions and polymorphism cpp
Pointers,virtual functions and polymorphism cppPointers,virtual functions and polymorphism cpp
Pointers,virtual functions and polymorphism cpp
 
class and objects
class and objectsclass and objects
class and objects
 
structure and union
structure and unionstructure and union
structure and union
 
Data types in java
Data types in javaData types in java
Data types in java
 
Inline function
Inline functionInline function
Inline function
 
Java awt (abstract window toolkit)
Java awt (abstract window toolkit)Java awt (abstract window toolkit)
Java awt (abstract window toolkit)
 
Data Structures in Python
Data Structures in PythonData Structures in Python
Data Structures in Python
 
Class and Objects in Java
Class and Objects in JavaClass and Objects in Java
Class and Objects in Java
 
Types of Constructor in C++
Types of Constructor in C++Types of Constructor in C++
Types of Constructor in C++
 
File in C language
File in C languageFile in C language
File in C language
 

Similar to Classes,object and methods java

Classes & objects new
Classes & objects newClasses & objects new
Classes & objects newlykado0dles
 
Classes,object and methods jav
Classes,object and methods javClasses,object and methods jav
Classes,object and methods javPadma Kannan
 
packages and interfaces
packages and interfacespackages and interfaces
packages and interfacesmadhavi patil
 
Ap Power Point Chpt4
Ap Power Point Chpt4Ap Power Point Chpt4
Ap Power Point Chpt4dplunkett
 
classandobjectunit2-150824133722-lva1-app6891.ppt
classandobjectunit2-150824133722-lva1-app6891.pptclassandobjectunit2-150824133722-lva1-app6891.ppt
classandobjectunit2-150824133722-lva1-app6891.pptmanomkpsg
 
Object Oriented Principles
Object Oriented PrinciplesObject Oriented Principles
Object Oriented PrinciplesSujit Majety
 
UNIT-2.pptx CS3391 Inheritance , types, packages and Interfaces
UNIT-2.pptx CS3391 Inheritance , types, packages and InterfacesUNIT-2.pptx CS3391 Inheritance , types, packages and Interfaces
UNIT-2.pptx CS3391 Inheritance , types, packages and InterfacesSakkaravarthiS1
 
3 functions and class
3   functions and class3   functions and class
3 functions and classtrixiacruz
 
Java As an OOP Language,Exception Handling & Applets
Java As an OOP Language,Exception Handling & AppletsJava As an OOP Language,Exception Handling & Applets
Java As an OOP Language,Exception Handling & AppletsHelen SagayaRaj
 

Similar to Classes,object and methods java (20)

Ch-2ppt.pptx
Ch-2ppt.pptxCh-2ppt.pptx
Ch-2ppt.pptx
 
Classes & objects new
Classes & objects newClasses & objects new
Classes & objects new
 
Classes,object and methods jav
Classes,object and methods javClasses,object and methods jav
Classes,object and methods jav
 
packages and interfaces
packages and interfacespackages and interfaces
packages and interfaces
 
Chapter 3
Chapter 3Chapter 3
Chapter 3
 
Wrapper classes
Wrapper classesWrapper classes
Wrapper classes
 
Java defining classes
Java defining classes Java defining classes
Java defining classes
 
Delphi qa
Delphi qaDelphi qa
Delphi qa
 
Hemajava
HemajavaHemajava
Hemajava
 
4 Classes & Objects
4 Classes & Objects4 Classes & Objects
4 Classes & Objects
 
Reflection
ReflectionReflection
Reflection
 
Ap Power Point Chpt4
Ap Power Point Chpt4Ap Power Point Chpt4
Ap Power Point Chpt4
 
classandobjectunit2-150824133722-lva1-app6891.ppt
classandobjectunit2-150824133722-lva1-app6891.pptclassandobjectunit2-150824133722-lva1-app6891.ppt
classandobjectunit2-150824133722-lva1-app6891.ppt
 
Object Oriented Principles
Object Oriented PrinciplesObject Oriented Principles
Object Oriented Principles
 
UNIT-2.pptx CS3391 Inheritance , types, packages and Interfaces
UNIT-2.pptx CS3391 Inheritance , types, packages and InterfacesUNIT-2.pptx CS3391 Inheritance , types, packages and Interfaces
UNIT-2.pptx CS3391 Inheritance , types, packages and Interfaces
 
3 functions and class
3   functions and class3   functions and class
3 functions and class
 
C# interview
C# interviewC# interview
C# interview
 
Java As an OOP Language,Exception Handling & Applets
Java As an OOP Language,Exception Handling & AppletsJava As an OOP Language,Exception Handling & Applets
Java As an OOP Language,Exception Handling & Applets
 
Chapter 7 java
Chapter 7 javaChapter 7 java
Chapter 7 java
 
Oops
OopsOops
Oops
 

More from Padma Kannan

More from Padma Kannan (13)

B tree
B treeB tree
B tree
 
Operators in C++
Operators in C++Operators in C++
Operators in C++
 
Java packags
Java packagsJava packags
Java packags
 
Java and c++
Java and c++Java and c++
Java and c++
 
Inheritance
InheritanceInheritance
Inheritance
 
Functions in c++
Functions in c++Functions in c++
Functions in c++
 
Functions in c++,
Functions in c++,Functions in c++,
Functions in c++,
 
Functions of dbms
Functions  of dbmsFunctions  of dbms
Functions of dbms
 
Basic concept of oops
Basic concept of oopsBasic concept of oops
Basic concept of oops
 
LEARNING BASES OF ACTICITY
LEARNING BASES OF ACTICITYLEARNING BASES OF ACTICITY
LEARNING BASES OF ACTICITY
 
Social networking risks
Social networking risksSocial networking risks
Social networking risks
 
Inheritance
InheritanceInheritance
Inheritance
 
Excel2002
Excel2002Excel2002
Excel2002
 

Recently uploaded

Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsSnow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsHyundai Motor Group
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?XfilesPro
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 

Recently uploaded (20)

E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsSnow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptxVulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 

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
  • 2.
  • 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.