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 an exception in java?
What does the @override annotation do?
Is 64bit faster than 32 bit?
What is an interoperable application in java ?
Difference between java and javascript
What are variable names?
Why is it called a string?
What is a method header?
What is meant by memory leak?
What should I import for arraylist in java?
What is bubble sorting in java?
What is the difference between multitasking and multithreading in Java
What is java virtual machine? Explain
What is the basic of java?
Can we return null in java?