Tuesday, February 24, 2009

source codes Default Constructor



/* The default constructor is always no argument constructor.It contains only one statement which is ‘no arg call to super class. */
Demo 1:
programmer written code:

class Sample
{
}
compiler generated code:
class Sample
{
Sample()
{
Super();
}
}

Demo 2:
programmer written code:
class Sample1
{
Sample1(int i)
{
System.out.println(“constructor”);
}
}
Compiler generated code:
class Sample1
{
Sample1(int i)
{
Super();
System.out.println(“constructor”);
}
}


Demo 3:
programmer written code:
class Sample3
{
Sample3(int i)
{
super();
System.out.println(“Hai”);
}
}
Compiler generated code:- no new code is going to generate.


0 comments:

Post a Comment