Hi Anjali,
Apex managed sharing is maintained across record owner changes. Basically, if you want to share a record programmatically we use Apex Managed Sharing. For example, AccountShare is the sharing object for the Account object, ContactShare is the sharing object for the Contact object, and so on.
Thanks.