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
Define iterator and methods in iterator?
What does ide stand for?
What are different types of control structures?
Implement two stacks using a single array.
What is the relationship difference the canvas class and the graphics class?
Is a case study a method or methodology?
When can we say that threads are not lightweight process in java?
what is session in java?
Is intellij better than eclipse?
Can you write a java class that could be used both as an applet as well as an application?
If we don’t want some of the fields not to serialize how to do that?
how to create multithreaded program? Explain different ways of using thread? When a thread is created and started, what is its initial state? : Java thread
how a programmer confirms that the data submitted has been succesfully inserted into the database(either oracle or my sql).. How a programmer confirm if there is any problem with the program he wrote for insertion... ANS:--- >executeupdate method is having boolean return type, if anything goes wrong in data insertion or data updation, it would return false. otherwise, if it successfully inserts data into the database, it would return true NOW HOW TO I CHECK IN MY DURING EXECUTION WHETHER IT RETURNS TRUE OR FALSE... WELL IT WILL DISPLAY ANY MESSAGE OR NOT
Where is stringbuffer stored?
Can we declare a constructor as final?