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
Discuss about garbage collector in Java.
What are the basics of core java?
Which one will take more memory: an int or integer?
What is the epoch date?
What is the advantage of OOP in java?
What are the differences between this and super keyword?
Can we use both this () and super () in a constructor?
What is anagram word?
What are the characteristics of java?
What is mysql driver class name?
What is difference between calling start() and run() method of thread?
Who is the owner of java?
What is the difference between form & report?
What is yield () in java?
What is difference between stringbuffer and string?