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
Can the garbage collection be forced by any means?
Explain the difference between intermediate and terminal operations in java8?
Is there a case when finally will not execute?
Is java a security risk?
What do you understand by overloading and overriding in java?
Explain 5 features introduced in jdk 1.7?
Is boolean a data type in java?
Why java is object oriented?
Difference between operator overloading and function overloading
What environment variables do I need to set on my machine in order to be able to run java programs?
What are peerless components?
How many types of parsers are there?
Can we use string in switch case in java?
What is vector?
Explain some best practices you would apply while using collection in java?