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 is the difference between class forname and new?
How many bytes is a url?
What is predicate in java?
What is a dynamic array java?
Does constructor return any value?
Is simpledateformat safe to use in the multithreaded program?
What is garbage collection? What is the process that is responsible for doing that in java?
What is r in java?
What is substring in java?
What are constructors in java?
How do you define a set in java?
What do u mean by variable?
What is string pool in java?
Is Constructor possible in abstract class in java ?
Can you explain the meaning of aggregation and composition