hi all ..
I am trying to copy Subclass object to Super class ..
which is in my code . from Bclass object to Aclass object.. but it is not copied .
the program compiled successfully .
but the value of Aclass object x is still 10 ..
Any help ??
and thanks in advance.
class Aclass{
int x;
Aclass(){
x =10;
}
Aclass(int i ){
x =i;
}
Aclass ( Aclass object)
{
x = object.x;
}
}
class Bclass extends Aclass {
int x;
Bclass ( int i )
{
x = i;
}
Bclass ( Bclass obj){
super( obj);
x= obj.x;
}
}
public class refrencertst {
public static void main ( String arg[]){
Aclass Aobj = new Aclass(6);
Bclass Bobj= new Bclass (5);
Aclass Aobj2 = new Aclass (Bobj);
System.out.print(" member is " + Aobj2.x);
}
}