Tech
News
Videos
Forums
Jobs
Books
Events
More
Interviews
Live
Learn
Training
Career
Members
Blogs
Challenges
Certification
Contribute
Article
Blog
Video
Ebook
Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Refer
Rewards
SharpGPT
Premium
Contribute
Article
Blog
Video
Ebook
Interview Question
Register
Login
Java Overloading Constructor
WhatsApp
Senthilvelan Sambamoorthy
5y
3.6
k
0
1
25
Blog
Introduction
In this blog, I will explain about Overloading Constructor in Java. It is effortless in Java Programming. The output will be displayed in the Run module.
Software Requirement
JDK1.3
Simple program
class
overlo {
double
x, y;
overlo(
double
a,
double
b) {
x = a;
y = b;
}
public
void
squ() {
System.out.println(
"The Area of Square : "
+ (x * x));
}
public
void
rec() {
System.out.println(
"The Area of Rectangle : "
+ (x * y));
}
public
void
cir() {
System.out.println(
"The Area of Circle : "
+ (
3.14
* x * x));
}
public
static
void
main(String arg[]) {
overlo t;
t =
new
overlo(
4
,
4
);
t.squ();
t =
new
overlo(
5
,
6
);
t.rec();
t =
new
overlo(
2
,
3
);
t.cir();
}
}
Output
Overloading Constructor
Constructor
Overloading
Up Next
Copying The Values of One Object to Another Using Constructor in Java
Ebook Download
View all
Coding Principles
Read by 2.7k people
Download Now!
Learn
View all
Membership not found