VipulPathak
September 21st, 2000, 01:54 PM
Hi All !
Below is a Simple Java Source Code. Please Analyse it and express ur view, that what is the flow of program ?
/* FileName: L.java implements Inheritance in Java */
import java.lang.* ;
class Base
{
Base(int XX)
{
System.out.println("BAS : "+XX) ;
}
Base(int XX, float sdf)
{
System.out.println("BAS2 :"+XX) ;
System.out.println("BAS2 :"+sdf) ;
}
}
class Der extends Base
{
Der(int XXX)
{
super(XXX) ;
System.out.println("DER : "+XXX) ;
}
}
public class L
{
public static void main(String[] SHE_SHE)
{
Der D = new Der(10) ;
return ;
}
}
We know that, If a No constructor is written by programmer then Java implicitly provides a default constructor. But, if any kind of construct is written, then the default constructor must also be explicitly provided by the Programmer.
The Base Class doesn’t contain the Default Constructor then how is the Instance of Base class is able to created ?
We know that whenever a Child class Object is being Created, the Parent Class constructor is first called then the Derived class object is created. In this case, how is the Base class object first created even when the base class constructor doesn’t exists ?
If we remove the statement “super(XXX) ;”, the javac report “Error”. What special treatment the “super()” is giving ?
e.g. What fine is this super is doing and how ?
Thanks.
-Vipul Pathak.
Pathak Developers Pvt. Ltd.
Indore, (MP) INDIA.
ICQ# 65423070
PS: If this helps you then Rate it, so let me know How much is this helpful to you.
Below is a Simple Java Source Code. Please Analyse it and express ur view, that what is the flow of program ?
/* FileName: L.java implements Inheritance in Java */
import java.lang.* ;
class Base
{
Base(int XX)
{
System.out.println("BAS : "+XX) ;
}
Base(int XX, float sdf)
{
System.out.println("BAS2 :"+XX) ;
System.out.println("BAS2 :"+sdf) ;
}
}
class Der extends Base
{
Der(int XXX)
{
super(XXX) ;
System.out.println("DER : "+XXX) ;
}
}
public class L
{
public static void main(String[] SHE_SHE)
{
Der D = new Der(10) ;
return ;
}
}
We know that, If a No constructor is written by programmer then Java implicitly provides a default constructor. But, if any kind of construct is written, then the default constructor must also be explicitly provided by the Programmer.
The Base Class doesn’t contain the Default Constructor then how is the Instance of Base class is able to created ?
We know that whenever a Child class Object is being Created, the Parent Class constructor is first called then the Derived class object is created. In this case, how is the Base class object first created even when the base class constructor doesn’t exists ?
If we remove the statement “super(XXX) ;”, the javac report “Error”. What special treatment the “super()” is giving ?
e.g. What fine is this super is doing and how ?
Thanks.
-Vipul Pathak.
Pathak Developers Pvt. Ltd.
Indore, (MP) INDIA.
ICQ# 65423070
PS: If this helps you then Rate it, so let me know How much is this helpful to you.