Experiment with a simple derivation relationship between two classes. Put printl
ID: 3769422 • Letter: E
Question
Experiment with a simple derivation relationship between two classes. Put println statements in constructors of both the parent and child classes. Do not explicitly call the constructor of the parent in the child classes. Do not explicitly call the constructor of teh parent in the child. What happens? Why? Change the child's constructor to explicitly call the constructor of the parent. Now what happens?
I need an example program in java, because I can't visualize what I am supposed to do, and I do need help with that, if you could send me the sample programs I would be grateful thank you.
Explanation / Answer
class parent
{
parent()
{
System.out.println("In Parent");
}
}
class child extends parent
{
child()
{
System.out.println("In Child");
}
}
class parent_child_constructor
{
public static void main(String args[])
{
child o=new child();
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.