i AM GETTING THESE ERRORS
.\Triangle.java:9: error: constructor Shape in class Shape cannot be applied to given types;
{
^
required: int,int
found: no arguments
reason: actual and formal argument lists differ in length
.\Square.java:7: error: constructor Shape in class Shape cannot be applied to given types;
{
^
required: int,int
found: no arguments
reason: actual and formal argument lists differ in length
.\Circle.java:7: error: constructor Shape in class Shape cannot be applied to given types;
{
^
required: int,int
found: no arguments
reason: actual and formal argument lists differ in length
Rajesh Km wrote:i AM GETTING THESE ERRORS
.\Triangle.java:9: error: constructor Shape in class Shape cannot be applied to given types;
{
^
required: int,int
found: no arguments
reason: actual and formal argument lists differ in length
Basically, this error is saying that your Triangle class is trying to use the the default constructor of shape class -- but your shape class doesn't have a default constructor. Your shape class has a constructor that takes two int parameters.
thanks its working know.but a doubt if we dont provide the constructor Java virtual machine automatically creates one default constructor and initiates the parent constructor.then why in this case it didnt work
Because if you provide a constructor with parameters, then the compiler will NOT insert the default constructor and you will have to explicitly write it like you just did.
No, it is not mandatory, provided the superclass of class Shape, has a default constructor. This is because the first statement of any constructor, by default is a call to super().