how to call One constructor from another;
Answer Posted / ajay
Hi,
Using super you can invoke constructor which is in parent
class. to invoke constructor which is in the same class we
have to use this. for example:
public class Point {
int m_x;
int m_y;
//============ Constructor
public Point(int x, int y) {
m_x = x;
m_y = y;
}
//============ Parameterless default constructor
public Point() {
this(0, 0); // Calls other constructor.
}
. . .
}
Is This Answer Correct ? | 21 Yes | 5 No |
Post New Answer View All Answers
Which data type is a class in java?
What is a linkedhashmap java?
what are Hostile Applets?
Can there be an abstract method without an abstract class?
Is an object null?
Why Java is not pure Object Oriented language?
How do you sort words in java?
Can keyword be used as identifier?
What is gc()?
When the constructor of a class is invoked?
Is it possible to override private or static method in java?
Implementations of set interface?
Can an interface have a constructor?
Explain covariant method overriding in java.
What does replaceall do in java?