Write a java program to calculate the area of five different shapes using parameterized constructor overloading.
Answers
Answer:
please follow me and make my answer as brainlist
Explanation:
Like methods, constructors can also be overloaded. In this guide we will see Constructor overloading with the help of examples. Before we proceed further let’s understand what is constructor overloading and why we do it.
Constructor overloading is a concept of having more than one constructor with different parameters list, in such a way so that each constructor performs a different task. For e.g. Vector class has 4 types of constructors. If you do not want to specify the initial capacity and capacity increment then you can simply use default constructor of Vector class like this Vector v = new Vector(); however if you need to specify the capacity and increment then you call the parameterized constructor of Vector class with two int arguments like this: Vector v= new Vector(10, 5);
constructor overloading
You must have understood the purpose of constructor overloading. Lets see how to overload a constructor with the help of following java program.