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
Is array passed by reference in java?
How does a cookie work in Servlets?
Why do you canvas?
What are the steps involved to write rmi based programs?
Explain about static nested classes in java?
What are the advantages of user defined functions?
Can constructor be static or final?
Why we used break and continue statement in java?
Is char a data type in java?
why using interface interface ?
State two differences between C and Java.
What is final method?
What do you understand by java?
What is method in java with example?
What are java annotations?