class BaseObject { int x; } class SubObject extend BaseObject { int y; } BaseObject baseobj; SubObject subobj; //copy property from baseobj one by one. subobj