SlideShare a Scribd company logo
Presented by,
Siva Shankari Rajan,
CPSV
CONTENTS
What is Constructor
Types of Constructor
Constructor overloading
1
2
3
4
Passing initial values as
arguments
1
Java Constructor
A constructor in Java is a
special method that is used
to initialize objects. The
constructor is called when an
object of a class is created. It
can be used to set initial
values for object attributes
2
Rules for Java Constructor
The constructor
name must match
the name of the
class
The default
constructor is
ALWAYS as no-arg
constructor
Constructors can
use any access
modifier, including
private
Constructors
must not have a
return type.
3
Difference Between Constructor and Method
Constructor are
used to initialize
the state of
object
Constructor
must not have
return type
Constructor
compil er provide
default
constructor .
Method is expose
the behaviour of
object.
Method must have
return type.
Method compiler
does't provide.
1
2
3
1
2
3
4
Types of Java Constructor
Default
constructor
Parameterized
constructor
Copy
constructor
5
01
02
A constructor that
have no parameter is
known as default
constructor.
Syntax of default
constructor:
<class_name>(){}
Default Constructor
Class Measuring
{
Private double Metre;
Private double kilometer;
Private double centimeter;
Private double Millimeter;
Measuring()
{
Metre=120; kilometer=10.0; centimeter=12.0;
Millimeter=5.0;
}
Void display()
{
System.out.println(“kilometer=“+kilometer);
}
}
Output:
Kilometer=10.0
6
01
02
A constructor that have
parameters is known as
parameterized
constructor.
Parameterized
constructor is used to
provide different values to
the distinct objects
Parameterize
dconstructor
Class Rectangle
{
int length; int breadth;
Rectangle(int len, int bre)
{
length=len;
breadth=bre;
}
}
Class demo
{
Public static void main(String args[])
{
Rectangle r1= new Rectangle(20,10);
System.out.println(“length of rectangle=“
r1.length);
System.out.println(“breadth of
rectangle=“ r1.breadth);
}}
7
01
02
We can create the object
with any initial value to
extract values in the
parameterized
constructor
Parameterized
constructor can pass a
value as:
1. An implicit call
2. An explicit call
Passing initial values
As arguments
Implicit call constructor:
It retrieves the parameterized
constructor even if it is not declared in
the main().
We can create the object with any
initial value to extract values in the
parameterized constructor
Explicit call constructor:
It helps in creating a temporary
instance.
A temporary instance remains in the
memory as long as it is being used in an
expression.
8
01
02
It is used to create a
temporary object of a
class object.
A copy constructor takes
only one argument, which
is of the type as the class.
Copy
constructor
Class Rectangle
{
int length; int breadth;
Rectangle(int len, int bre)
{
length=len;
breadth=bre;
}
Rectangle(Rectangle obj)
{
System.out.println(“copy constructor
invoked”);
length=obj.len;
breadth=obj.bre;
}
int area()
{
return(length*breadth);
}
9
01
02
It is used to create a
temporary object of a
class object.
A copy constructor takes
only one argument, which
is of the type as the class.
Copy
constructor
Class demo
{
Public static void main(String args[])
{
Rectangle r1= new Rectangle(20,10);
Rectangle r2=new Rectangle(r1);
System.out.println(“area of 1st rectangle=“
r1.area());
System.out.println(“area of 2nd rectangle=“
r2.area());
}}
10
01
02
A constructor may be
overloaded, so a single
class may have more
than one constructor, all
of which have the same
name but different
argument lists.
Constructor
overloading
Class overloading
{
int x,
float y;
Overloading()
{x=0;y=0.0;}
Overloading(int a)
{x=a; y=0;}
Overloading(int a, float b)
{x=a; y=b;}
Public static void main(String args[])
{
Overloading ov1=new overloading();
Overloading ov2=new overloading(40);
Overloading ov3=new overloading(10,4.5);
}
}
Constructor in java
Ad

More Related Content

What's hot (20)

Method overloading
Method overloadingMethod overloading
Method overloading
Lovely Professional University
 
Type casting in java
Type casting in javaType casting in java
Type casting in java
Farooq Baloch
 
Arrays in Java
Arrays in JavaArrays in Java
Arrays in Java
Naz Abdalla
 
Java package
Java packageJava package
Java package
CS_GDRCST
 
Final keyword in java
Final keyword in javaFinal keyword in java
Final keyword in java
Lovely Professional University
 
JAVA AWT
JAVA AWTJAVA AWT
JAVA AWT
shanmuga rajan
 
I/O Streams
I/O StreamsI/O Streams
I/O Streams
Ravi Chythanya
 
Java awt (abstract window toolkit)
Java awt (abstract window toolkit)Java awt (abstract window toolkit)
Java awt (abstract window toolkit)
Elizabeth alexander
 
This keyword in java
This keyword in javaThis keyword in java
This keyword in java
Hitesh Kumar
 
Strings in Java
Strings in JavaStrings in Java
Strings in Java
Abhilash Nair
 
Packages in java
Packages in javaPackages in java
Packages in java
Elizabeth alexander
 
Java Data Types
Java Data TypesJava Data Types
Java Data Types
Spotle.ai
 
MULTI THREADING IN JAVA
MULTI THREADING IN JAVAMULTI THREADING IN JAVA
MULTI THREADING IN JAVA
VINOTH R
 
Java variable types
Java variable typesJava variable types
Java variable types
Soba Arjun
 
java interface and packages
java interface and packagesjava interface and packages
java interface and packages
VINOTH R
 
Java interfaces
Java interfacesJava interfaces
Java interfaces
Raja Sekhar
 
Constructor overloading & method overloading
Constructor overloading & method overloadingConstructor overloading & method overloading
Constructor overloading & method overloading
garishma bhatia
 
Wrapper class
Wrapper classWrapper class
Wrapper class
kamal kotecha
 
Java exception handling
Java exception handlingJava exception handling
Java exception handling
BHUVIJAYAVELU
 
Event handling
Event handlingEvent handling
Event handling
swapnac12
 

Similar to Constructor in java (20)

C++
C++C++
C++
vrushali shivsharan
 
C++
C++C++
C++
vrushali shivsharan
 
Constructor&amp; destructor
Constructor&amp; destructorConstructor&amp; destructor
Constructor&amp; destructor
chauhankapil
 
Constructors and destructors
Constructors and destructorsConstructors and destructors
Constructors and destructors
Prof. Dr. K. Adisesha
 
Constructor in java
Constructor in javaConstructor in java
Constructor in java
Madishetty Prathibha
 
Constructors in Java (2).pdf
Constructors in Java (2).pdfConstructors in Java (2).pdf
Constructors in Java (2).pdf
kumari36
 
Constructor oopj
Constructor oopjConstructor oopj
Constructor oopj
ShaishavShah8
 
Constructor and destructor in oop
Constructor and destructor in oop Constructor and destructor in oop
Constructor and destructor in oop
Samad Qazi
 
UNIT 3- Java- Inheritance, Multithreading.pptx
UNIT 3- Java- Inheritance, Multithreading.pptxUNIT 3- Java- Inheritance, Multithreading.pptx
UNIT 3- Java- Inheritance, Multithreading.pptx
shilpar780389
 
Constructors in java
Constructors in javaConstructors in java
Constructors in java
sunilchute1
 
Constructor and Destructor
Constructor and DestructorConstructor and Destructor
Constructor and Destructor
Sunipa Bera
 
basic concepts of object oriented in python
basic concepts of object oriented in pythonbasic concepts of object oriented in python
basic concepts of object oriented in python
deepalishinkar1
 
Constructors in C++.pptx
Constructors in C++.pptxConstructors in C++.pptx
Constructors in C++.pptx
Rassjb
 
ConsTRUCTION AND DESTRUCTION
ConsTRUCTION AND DESTRUCTIONConsTRUCTION AND DESTRUCTION
ConsTRUCTION AND DESTRUCTION
Shweta Shah
 
Constructor and Destructor in c++
Constructor  and Destructor in c++Constructor  and Destructor in c++
Constructor and Destructor in c++
aleenaguen
 
Constructor in java Presentation by Dawood Khan .pptx
Constructor in java Presentation by Dawood Khan .pptxConstructor in java Presentation by Dawood Khan .pptx
Constructor in java Presentation by Dawood Khan .pptx
Dawoodkhan980027
 
Constructor & Destructor
Constructor & DestructorConstructor & Destructor
Constructor & Destructor
KV(AFS) Utarlai, Barmer (Rajasthan)
 
C++ Constructor and Destructors.pptx
C++ Constructor and Destructors.pptxC++ Constructor and Destructors.pptx
C++ Constructor and Destructors.pptx
sasukeman
 
5 Constructors and Destructors
5 Constructors and Destructors5 Constructors and Destructors
5 Constructors and Destructors
Praveen M Jigajinni
 
Oops
OopsOops
Oops
Gayathri Ganesh
 
Constructor&amp; destructor
Constructor&amp; destructorConstructor&amp; destructor
Constructor&amp; destructor
chauhankapil
 
Constructors in Java (2).pdf
Constructors in Java (2).pdfConstructors in Java (2).pdf
Constructors in Java (2).pdf
kumari36
 
Constructor and destructor in oop
Constructor and destructor in oop Constructor and destructor in oop
Constructor and destructor in oop
Samad Qazi
 
UNIT 3- Java- Inheritance, Multithreading.pptx
UNIT 3- Java- Inheritance, Multithreading.pptxUNIT 3- Java- Inheritance, Multithreading.pptx
UNIT 3- Java- Inheritance, Multithreading.pptx
shilpar780389
 
Constructors in java
Constructors in javaConstructors in java
Constructors in java
sunilchute1
 
Constructor and Destructor
Constructor and DestructorConstructor and Destructor
Constructor and Destructor
Sunipa Bera
 
basic concepts of object oriented in python
basic concepts of object oriented in pythonbasic concepts of object oriented in python
basic concepts of object oriented in python
deepalishinkar1
 
Constructors in C++.pptx
Constructors in C++.pptxConstructors in C++.pptx
Constructors in C++.pptx
Rassjb
 
ConsTRUCTION AND DESTRUCTION
ConsTRUCTION AND DESTRUCTIONConsTRUCTION AND DESTRUCTION
ConsTRUCTION AND DESTRUCTION
Shweta Shah
 
Constructor and Destructor in c++
Constructor  and Destructor in c++Constructor  and Destructor in c++
Constructor and Destructor in c++
aleenaguen
 
Constructor in java Presentation by Dawood Khan .pptx
Constructor in java Presentation by Dawood Khan .pptxConstructor in java Presentation by Dawood Khan .pptx
Constructor in java Presentation by Dawood Khan .pptx
Dawoodkhan980027
 
C++ Constructor and Destructors.pptx
C++ Constructor and Destructors.pptxC++ Constructor and Destructors.pptx
C++ Constructor and Destructors.pptx
sasukeman
 
Ad

Recently uploaded (20)

Understanding P–N Junction Semiconductors: A Beginner’s Guide
Understanding P–N Junction Semiconductors: A Beginner’s GuideUnderstanding P–N Junction Semiconductors: A Beginner’s Guide
Understanding P–N Junction Semiconductors: A Beginner’s Guide
GS Virdi
 
K12 Tableau Tuesday - Algebra Equity and Access in Atlanta Public Schools
K12 Tableau Tuesday  - Algebra Equity and Access in Atlanta Public SchoolsK12 Tableau Tuesday  - Algebra Equity and Access in Atlanta Public Schools
K12 Tableau Tuesday - Algebra Equity and Access in Atlanta Public Schools
dogden2
 
How to Customize Your Financial Reports & Tax Reports With Odoo 17 Accounting
How to Customize Your Financial Reports & Tax Reports With Odoo 17 AccountingHow to Customize Your Financial Reports & Tax Reports With Odoo 17 Accounting
How to Customize Your Financial Reports & Tax Reports With Odoo 17 Accounting
Celine George
 
Multi-currency in odoo accounting and Update exchange rates automatically in ...
Multi-currency in odoo accounting and Update exchange rates automatically in ...Multi-currency in odoo accounting and Update exchange rates automatically in ...
Multi-currency in odoo accounting and Update exchange rates automatically in ...
Celine George
 
SPRING FESTIVITIES - UK AND USA -
SPRING FESTIVITIES - UK AND USA            -SPRING FESTIVITIES - UK AND USA            -
SPRING FESTIVITIES - UK AND USA -
Colégio Santa Teresinha
 
Geography Sem II Unit 1C Correlation of Geography with other school subjects
Geography Sem II Unit 1C Correlation of Geography with other school subjectsGeography Sem II Unit 1C Correlation of Geography with other school subjects
Geography Sem II Unit 1C Correlation of Geography with other school subjects
ProfDrShaikhImran
 
New Microsoft PowerPoint Presentation.pptx
New Microsoft PowerPoint Presentation.pptxNew Microsoft PowerPoint Presentation.pptx
New Microsoft PowerPoint Presentation.pptx
milanasargsyan5
 
Timber Pitch Roof Construction Measurement-2024.pptx
Timber Pitch Roof Construction Measurement-2024.pptxTimber Pitch Roof Construction Measurement-2024.pptx
Timber Pitch Roof Construction Measurement-2024.pptx
Tantish QS, UTM
 
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - Worksheet
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - WorksheetCBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - Worksheet
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - Worksheet
Sritoma Majumder
 
Quality Contril Analysis of Containers.pdf
Quality Contril Analysis of Containers.pdfQuality Contril Analysis of Containers.pdf
Quality Contril Analysis of Containers.pdf
Dr. Bindiya Chauhan
 
To study Digestive system of insect.pptx
To study Digestive system of insect.pptxTo study Digestive system of insect.pptx
To study Digestive system of insect.pptx
Arshad Shaikh
 
Unit 4: Long term- Capital budgeting and its types
Unit 4: Long term- Capital budgeting and its typesUnit 4: Long term- Capital budgeting and its types
Unit 4: Long term- Capital budgeting and its types
bharath321164
 
P-glycoprotein pamphlet: iteration 4 of 4 final
P-glycoprotein pamphlet: iteration 4 of 4 finalP-glycoprotein pamphlet: iteration 4 of 4 final
P-glycoprotein pamphlet: iteration 4 of 4 final
bs22n2s
 
World war-1(Causes & impacts at a glance) PPT by Simanchala Sarab(BABed,sem-4...
World war-1(Causes & impacts at a glance) PPT by Simanchala Sarab(BABed,sem-4...World war-1(Causes & impacts at a glance) PPT by Simanchala Sarab(BABed,sem-4...
World war-1(Causes & impacts at a glance) PPT by Simanchala Sarab(BABed,sem-4...
larencebapu132
 
Diabetic neuropathy peripheral autonomic
Diabetic neuropathy peripheral autonomicDiabetic neuropathy peripheral autonomic
Diabetic neuropathy peripheral autonomic
Pankaj Patawari
 
YSPH VMOC Special Report - Measles Outbreak Southwest US 4-30-2025.pptx
YSPH VMOC Special Report - Measles Outbreak  Southwest US 4-30-2025.pptxYSPH VMOC Special Report - Measles Outbreak  Southwest US 4-30-2025.pptx
YSPH VMOC Special Report - Measles Outbreak Southwest US 4-30-2025.pptx
Yale School of Public Health - The Virtual Medical Operations Center (VMOC)
 
How to Subscribe Newsletter From Odoo 18 Website
How to Subscribe Newsletter From Odoo 18 WebsiteHow to Subscribe Newsletter From Odoo 18 Website
How to Subscribe Newsletter From Odoo 18 Website
Celine George
 
Presentation on Tourism Product Development By Md Shaifullar Rabbi
Presentation on Tourism Product Development By Md Shaifullar RabbiPresentation on Tourism Product Development By Md Shaifullar Rabbi
Presentation on Tourism Product Development By Md Shaifullar Rabbi
Md Shaifullar Rabbi
 
YSPH VMOC Special Report - Measles Outbreak Southwest US 4-26-2025.pptx
YSPH VMOC Special Report - Measles Outbreak  Southwest US 4-26-2025.pptxYSPH VMOC Special Report - Measles Outbreak  Southwest US 4-26-2025.pptx
YSPH VMOC Special Report - Measles Outbreak Southwest US 4-26-2025.pptx
Yale School of Public Health - The Virtual Medical Operations Center (VMOC)
 
Michelle Rumley & Mairéad Mooney, Boole Library, University College Cork. Tra...
Michelle Rumley & Mairéad Mooney, Boole Library, University College Cork. Tra...Michelle Rumley & Mairéad Mooney, Boole Library, University College Cork. Tra...
Michelle Rumley & Mairéad Mooney, Boole Library, University College Cork. Tra...
Library Association of Ireland
 
Understanding P–N Junction Semiconductors: A Beginner’s Guide
Understanding P–N Junction Semiconductors: A Beginner’s GuideUnderstanding P–N Junction Semiconductors: A Beginner’s Guide
Understanding P–N Junction Semiconductors: A Beginner’s Guide
GS Virdi
 
K12 Tableau Tuesday - Algebra Equity and Access in Atlanta Public Schools
K12 Tableau Tuesday  - Algebra Equity and Access in Atlanta Public SchoolsK12 Tableau Tuesday  - Algebra Equity and Access in Atlanta Public Schools
K12 Tableau Tuesday - Algebra Equity and Access in Atlanta Public Schools
dogden2
 
How to Customize Your Financial Reports & Tax Reports With Odoo 17 Accounting
How to Customize Your Financial Reports & Tax Reports With Odoo 17 AccountingHow to Customize Your Financial Reports & Tax Reports With Odoo 17 Accounting
How to Customize Your Financial Reports & Tax Reports With Odoo 17 Accounting
Celine George
 
Multi-currency in odoo accounting and Update exchange rates automatically in ...
Multi-currency in odoo accounting and Update exchange rates automatically in ...Multi-currency in odoo accounting and Update exchange rates automatically in ...
Multi-currency in odoo accounting and Update exchange rates automatically in ...
Celine George
 
Geography Sem II Unit 1C Correlation of Geography with other school subjects
Geography Sem II Unit 1C Correlation of Geography with other school subjectsGeography Sem II Unit 1C Correlation of Geography with other school subjects
Geography Sem II Unit 1C Correlation of Geography with other school subjects
ProfDrShaikhImran
 
New Microsoft PowerPoint Presentation.pptx
New Microsoft PowerPoint Presentation.pptxNew Microsoft PowerPoint Presentation.pptx
New Microsoft PowerPoint Presentation.pptx
milanasargsyan5
 
Timber Pitch Roof Construction Measurement-2024.pptx
Timber Pitch Roof Construction Measurement-2024.pptxTimber Pitch Roof Construction Measurement-2024.pptx
Timber Pitch Roof Construction Measurement-2024.pptx
Tantish QS, UTM
 
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - Worksheet
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - WorksheetCBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - Worksheet
CBSE - Grade 8 - Science - Chemistry - Metals and Non Metals - Worksheet
Sritoma Majumder
 
Quality Contril Analysis of Containers.pdf
Quality Contril Analysis of Containers.pdfQuality Contril Analysis of Containers.pdf
Quality Contril Analysis of Containers.pdf
Dr. Bindiya Chauhan
 
To study Digestive system of insect.pptx
To study Digestive system of insect.pptxTo study Digestive system of insect.pptx
To study Digestive system of insect.pptx
Arshad Shaikh
 
Unit 4: Long term- Capital budgeting and its types
Unit 4: Long term- Capital budgeting and its typesUnit 4: Long term- Capital budgeting and its types
Unit 4: Long term- Capital budgeting and its types
bharath321164
 
P-glycoprotein pamphlet: iteration 4 of 4 final
P-glycoprotein pamphlet: iteration 4 of 4 finalP-glycoprotein pamphlet: iteration 4 of 4 final
P-glycoprotein pamphlet: iteration 4 of 4 final
bs22n2s
 
World war-1(Causes & impacts at a glance) PPT by Simanchala Sarab(BABed,sem-4...
World war-1(Causes & impacts at a glance) PPT by Simanchala Sarab(BABed,sem-4...World war-1(Causes & impacts at a glance) PPT by Simanchala Sarab(BABed,sem-4...
World war-1(Causes & impacts at a glance) PPT by Simanchala Sarab(BABed,sem-4...
larencebapu132
 
Diabetic neuropathy peripheral autonomic
Diabetic neuropathy peripheral autonomicDiabetic neuropathy peripheral autonomic
Diabetic neuropathy peripheral autonomic
Pankaj Patawari
 
How to Subscribe Newsletter From Odoo 18 Website
How to Subscribe Newsletter From Odoo 18 WebsiteHow to Subscribe Newsletter From Odoo 18 Website
How to Subscribe Newsletter From Odoo 18 Website
Celine George
 
Presentation on Tourism Product Development By Md Shaifullar Rabbi
Presentation on Tourism Product Development By Md Shaifullar RabbiPresentation on Tourism Product Development By Md Shaifullar Rabbi
Presentation on Tourism Product Development By Md Shaifullar Rabbi
Md Shaifullar Rabbi
 
Michelle Rumley & Mairéad Mooney, Boole Library, University College Cork. Tra...
Michelle Rumley & Mairéad Mooney, Boole Library, University College Cork. Tra...Michelle Rumley & Mairéad Mooney, Boole Library, University College Cork. Tra...
Michelle Rumley & Mairéad Mooney, Boole Library, University College Cork. Tra...
Library Association of Ireland
 
Ad

Constructor in java

  • 2. CONTENTS What is Constructor Types of Constructor Constructor overloading 1 2 3 4 Passing initial values as arguments
  • 3. 1 Java Constructor A constructor in Java is a special method that is used to initialize objects. The constructor is called when an object of a class is created. It can be used to set initial values for object attributes
  • 4. 2 Rules for Java Constructor The constructor name must match the name of the class The default constructor is ALWAYS as no-arg constructor Constructors can use any access modifier, including private Constructors must not have a return type.
  • 5. 3 Difference Between Constructor and Method Constructor are used to initialize the state of object Constructor must not have return type Constructor compil er provide default constructor . Method is expose the behaviour of object. Method must have return type. Method compiler does't provide. 1 2 3 1 2 3
  • 6. 4 Types of Java Constructor Default constructor Parameterized constructor Copy constructor
  • 7. 5 01 02 A constructor that have no parameter is known as default constructor. Syntax of default constructor: <class_name>(){} Default Constructor Class Measuring { Private double Metre; Private double kilometer; Private double centimeter; Private double Millimeter; Measuring() { Metre=120; kilometer=10.0; centimeter=12.0; Millimeter=5.0; } Void display() { System.out.println(“kilometer=“+kilometer); } } Output: Kilometer=10.0
  • 8. 6 01 02 A constructor that have parameters is known as parameterized constructor. Parameterized constructor is used to provide different values to the distinct objects Parameterize dconstructor Class Rectangle { int length; int breadth; Rectangle(int len, int bre) { length=len; breadth=bre; } } Class demo { Public static void main(String args[]) { Rectangle r1= new Rectangle(20,10); System.out.println(“length of rectangle=“ r1.length); System.out.println(“breadth of rectangle=“ r1.breadth); }}
  • 9. 7 01 02 We can create the object with any initial value to extract values in the parameterized constructor Parameterized constructor can pass a value as: 1. An implicit call 2. An explicit call Passing initial values As arguments Implicit call constructor: It retrieves the parameterized constructor even if it is not declared in the main(). We can create the object with any initial value to extract values in the parameterized constructor Explicit call constructor: It helps in creating a temporary instance. A temporary instance remains in the memory as long as it is being used in an expression.
  • 10. 8 01 02 It is used to create a temporary object of a class object. A copy constructor takes only one argument, which is of the type as the class. Copy constructor Class Rectangle { int length; int breadth; Rectangle(int len, int bre) { length=len; breadth=bre; } Rectangle(Rectangle obj) { System.out.println(“copy constructor invoked”); length=obj.len; breadth=obj.bre; } int area() { return(length*breadth); }
  • 11. 9 01 02 It is used to create a temporary object of a class object. A copy constructor takes only one argument, which is of the type as the class. Copy constructor Class demo { Public static void main(String args[]) { Rectangle r1= new Rectangle(20,10); Rectangle r2=new Rectangle(r1); System.out.println(“area of 1st rectangle=“ r1.area()); System.out.println(“area of 2nd rectangle=“ r2.area()); }}
  • 12. 10 01 02 A constructor may be overloaded, so a single class may have more than one constructor, all of which have the same name but different argument lists. Constructor overloading Class overloading { int x, float y; Overloading() {x=0;y=0.0;} Overloading(int a) {x=a; y=0;} Overloading(int a, float b) {x=a; y=b;} Public static void main(String args[]) { Overloading ov1=new overloading(); Overloading ov2=new overloading(40); Overloading ov3=new overloading(10,4.5); } }