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 is reflexive association?
Is zero a natural number?
What is methods and methodology?
Write a factorial program using recursion in java?
Which collection allows duplicate values in java?
What will be the initial value of an object reference which is defined as an instance variable?
What is queue in java?
Explain some best practices you would apply while using collection in java?
What is use of map in java?
List two java ide’s?
Does java trim remove newline?
What's the access scope of protected access specifier?
What is the vector class in java programming?
What is a programming object?
Can you call a method on a null object?