how to call One constructor from another;
Answer Posted / tulasi prasad
We can call the parent class constructor from the child
class constructor.
class Parent
{
int a;
Parent(int x)
{
a=x;
}
}
class Child extends Parent
{
int b;
Child(int x,int y)
{
super(x);
b=y;
System.out.println(a);
System.out.println(b);
}
}
class Test
{
public static void main(String args[])
{
Child obj = new Child(1,2);
}
}
| Is This Answer Correct ? | 13 Yes | 1 No |
Post New Answer View All Answers
What is method with example?
What is a pattern what is an anti pattern?
What does this () mean in java?
How do you use equal in java?
How many types of operators are there?
explain the difference between jdk and jvm?
What is meant by distributed application? Why are we using that in our application?
How variables are stored in memory?
What is the difference between multiple processes and multiple threads?
Can we define package statement after import statement in java?
What are daemon Threads in java?
What does you mean in math?
What is public static void main?
What is type inference in java8?
describe method overloading