function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
ashish jadhav 9ashish jadhav 9 

In class syntax what are some bydefault optional things?

In a class syntax what are some things which is bydefault applied on the class if we don't declare them? for ex. with sharing/without sharing which is bydefault applicable on the class? please explain everything comes under the class syntax.
 
cloudSavvyProgcloudSavvyProg
Hi Ashish,

[virtual | abstract | with sharing | without sharing] are optional parameters on class definition.

The with sharing and without sharing keywords specify the sharing mode for this class. For more information, see Using the with sharing or without sharing Keywords.
Use the with sharing or without sharing keywords on a class to specify whether or not to enforce sharing rules. Salesforce doc link to give you more info.
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_keywords_sharing.htm

The virtual definition modifier declares that this class allows extension and overrides. You cannot override a method with the override keyword unless the class has been defined as virtual.
The abstract definition modifier declares that this class contains abstract methods, that is, methods that only have their signature declared and no body defined.

Here is link to all the info on class definition.
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_defining.htm


Hope this helps.

Regards,
CloudSavvyProg