We know that every custom object ends with __c . Here we are going through all objects present in Salesforce org and if Object contains __c then we are considering that object as custom object and print that object local name using getLocalName method .
The about code will give you all custom objects . Check how to find all the Standard Objects in Salesforce. Also here you can find how to filter Standard objects in APEX.