Undelete Records in Salesforce Using Apex

Sample Code:

List<Account> accList = New List<Account>();
accList = [SELECT Id FROM Account WHERE IsDeleted =: true ALL ROWS];
Undelete accList;