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 language is java written?
What is the difference between preemptive scheduling and time slicing in java programming?
What is the difference between stringbuffer and stringbuilder class?
What is a arraylist in java?
Is java se open source?
What makes a function well defined?
What is finally block?
What are the differences between abstract class and interface?
Explain the concept of proper inheritance?
Write a java program to count the number of words present in a string?
What do you mean by a JVM?
What is array list in java?
Is java 9 released?
What are locale settings?
Which method you will use to create a new file to store some log data. Each time a new log entry is necessary, write string to the file in java ?