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
what do you understand by the term string with respect to java?
What is the default value of byte datatype in java?
What is the difference between processes and threads?
What are new features introduced with java 8 ?
Why to use nested classes in java?
What is meant by design patterns?
What are packages in java?
What is maximum size of arraylist in java?
How can we create an immutable class in java?
How to instantiate static nested classes in java?
What is data and its types?
Can list contain null in java?
What is runtime polymorphism or dynamic method dispatch?
What is lastindexof in java?
Define how can we find the actual size of an object on the heap?