What is the difference between this() and super()?
Answer Posted / ankita jain
super is the first statement of derived class constuctor.
class room
{
int l,b;
room(int x,int y)
{
l = x;
b = y;
}
void area()
{
int a;
a = l*b;
return(a);
}
}
class studyroom extend room
{
int h;
studyroom (int x ,int y, int z)
{
super(x,y)
z = h;
}
int volume()
{
int v;
v = l*b*h;
return(v);
}
}
class sup
{
public static void main(String args[])
{
int ar,vol;
studtroom s=new Studyroom()
ar = s.area();
vol = s.volume();
System.out.println("the area is = "+ar);
System.out.println("the volume is = "+vol);
}
}
Is This Answer Correct ? | 24 Yes | 11 No |
Post New Answer View All Answers
What are the three parts of a lambda expression?
How many types of exception can occur in a java program?
Can we catch more than one exception in a single catch block?
What is charat java?
What is polymorphism java example?
Can extern variables be initialized?
What is class and its types?
What is function and its uses?
Can I overload to string method
Explain creating threads by extending thread class ?
What are the parts of methodology?
What is difference between array and arraylist in java?
What do you mean by mnemonics?
What does three dots mean in java?
What is string in java?