To find Object Key Prefix using Name in Salesforce Apex, we can use getKeyPrefix() method from DescribeSObjectResult class.
Sample Code:
DescribeSObjectResult sobjectRes =
PendingServiceRouting.sObjectType.getDescribe();
System.debug(
'Key prefix is ' +
sobjectRes.getKeyPrefix()
);
Output: