java inheritance වලට අදාල අභ්යාස අංක 1.
යාලුවනේ මේක run කරන්න කලින් ඔයාල එන්න පුලුවන් output එක guess කරන්න පුලුවන් නම් කොලේක ලිය ගන්න .පස්සේ මේක run කරලා output එක හරිද කියලා බලන්න .

================================================
class A{
int a=10;
static int b=20;
static{
System.out.print("1 ");
}
{
System.out.print("2 ");
}
A(){
System.out.print("3 ");
}
static void mA(){
System.out.print("4 ");
}
}
class B extends A{
int x=10;
static int y=20;
static{
System.out.print("5 ");
}
{
System.out.print("6 ");
}
B(){
System.out.print("7 ");
}
static void mB(){
System.out.print("8 ");
}
}
class Demo{
public static void main(String args[]){
// පහත code මෙතනින් තබන්න
}
}
//A. new A()
//B. new A(); new A();
//C. A.mA();
//D. A.mA(); new A();
//E. new B();
//F. new B();new B();
//G. B.mB(); new B();
//H. B.mA();
========================================================================
ඔයාලගේ අදහස් comment line එකෙන් දක්වන්න ...
ජය වේවා !
යාලුවනේ මේක run කරන්න කලින් ඔයාල එන්න පුලුවන් output එක guess කරන්න පුලුවන් නම් කොලේක ලිය ගන්න .පස්සේ මේක run කරලා output එක හරිද කියලා බලන්න .

================================================
class A{
int a=10;
static int b=20;
static{
System.out.print("1 ");
}
{
System.out.print("2 ");
}
A(){
System.out.print("3 ");
}
static void mA(){
System.out.print("4 ");
}
}
class B extends A{
int x=10;
static int y=20;
static{
System.out.print("5 ");
}
{
System.out.print("6 ");
}
B(){
System.out.print("7 ");
}
static void mB(){
System.out.print("8 ");
}
}
class Demo{
public static void main(String args[]){
// පහත code මෙතනින් තබන්න
}
}
//A. new A()
//B. new A(); new A();
//C. A.mA();
//D. A.mA(); new A();
//E. new B();
//F. new B();new B();
//G. B.mB(); new B();
//H. B.mA();
========================================================================
ඔයාලගේ අදහස් comment line එකෙන් දක්වන්න ...
ජය වේවා !















