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 do you mean by stream pipelining in java 8?
What is the use of set in java?
How do you use parseint in java?
What is the use of join method?
What is object english?
Can a static method be overridden in java?
How are the elements of a gridbaglayout organized in java programming?
When a thread is executing synchronized methods , then is it possible to execute other synchronized methods simultaneously by other threads?
Does A Class Inherit The Constructors Of Its Superclass?
Can you explain the private protected field modifier?
What is gc()?
How many types of voids are there?
What is a java developer salary?
What is api data?
Is hashmap thread safe?