Hi
Can anyone please explain this to me
Here when I compile this,I get the results :
Base Class Constructor called with Hello argument
SubClass Constructor called
As far as I know , whenever a Sub class is instanciated,
always its Base class constructor is called first
and then the Sub Class constructor.Here also
the same is happening but how does the Base
Class Constructor receives the "Hello" argument
through super keyword which is placed in Subclass
contructor.It can only happen if the sub class constructor
is called first and then the Base class constructor.
If I am wrong please correct me
class BaseClass
{BaseClass(
String str)
{
System.out.println("Base Class Constructor called with " + str + " argument");
}}
public class SubClass extends BaseClass
{
SubClass()
{
super("Hello"); //1
System.out.println("SubClass Constructor called");
}
public static void main(String args[])
{
SubClass sc = new SubClass();
}}