Generic sObject means, it can be of any persisted SFDC objects type. For ex: Vehicle is generic type and Car, Motor Bike all are concrete types of Vehicle. In SFDC,sObject is generic and Account, Opportunity, CustomObject__c are its concrete type. Generic sObject abstracts the actual representation of any object assigned to it. sObject is the name of the generic abstract type that can be used to represent any persisted object type.
Generic sObject is a general type of sObject, just like Account, Contact and custom object.
List<SObject> GenericList = new List<SObject>();
SObject acc = [Select Id, Name from Account limit 1];
GenericList.add(acc);
SObject con = [Select Id, Name from Contact limit 1];
GenericList.add(con);
system.debug(GenericList);
Its like a parent object for all the standard and custom objects we have in Salesforce. Generally, we use sObject when we write dynamic code in which we do not know which object we would be processing at run time. For example, lets say we have a general method which can work for both Account and Contacts and it accepts the account / contact records a param. In this case, we can generalise the method parameter as sObject like below:
Generic sObject means, it can be of any persisted SFDC objects type.
For ex: Vehicle is generic type and Car, Motor Bike all are concrete types of Vehicle.
In SFDC,sObject is generic and Account, Opportunity, CustomObject__c are its concrete type.
Generic sObject abstracts the actual representation of any object assigned to it. sObject is the name of the generic abstract type that can be used to represent any persisted object type.
Please refer the below link for reference.
- https://salesforce.stackexchange.com/questions/48789/getting-a-type-of-the-generic-object
Hope it will be helpful.Please mark it as best answer if the information is informative.
Thanks
Rahul Kumar
See below article for more information.
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_methods_system_sobject.htm
Let me know, If you have any confusion.
Regards,
Waqar Hussain
Skype: waqar.hussain991
2011waqar@gmail.com