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 differences between string and stringbuffer?
What is space character in java?
When throw keyword is used?
What are recursive functions?
Does A Class Inherit The Constructors Of Its Superclass?
What is an iterator interface in java programming?
Why do people says “java is robust”?
What is the purpose of the wait(), notify(), and notifyall() methods in java programming?
Difference between notify() method and notifyall() method in java?
Is it possible to instantiate the abstract class?
What is java util collection?
What is main method?
Which are the two subclasses under exception class?
What is a string token?
What is difference between java and java ee?