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
hiteshwar marnihiteshwar marni 

without sharing query

When default sharing is set to Without sharing ,why salesforce has explictly provided without sharing keyword.

Thanks,
Hitesh
Devi ChandrikaDevi Chandrika (Salesforce Developers) 
Hi hiteshwar,
If we do not declare class with "With sharing" or "Without sharing"  the class will not take into account the sharing rules but if this class is called from another class which is declared with "With sharing" it will take into account the sharing rules.
IF the class with "With sharing" is calling method of another class with "Without sharing" than the method inside "Without sharing" class will execute without sharing rules.
IF the class with "Without sharing" is calling method of another class with "With sharing" than the method inside "With sharing" class will execute with sharing rules.
Inner class do not have sharing settings of parent class.
Class have sharing settings of parent class when we implements it or extends it from parent class.

Please refer below links which might help you further
https://www.sfdc-lightning.com/2018/11/with-sharing-and-without-sharing-in.html
https://developer.salesforce.com/forums/?id=906F0000000D7LQIA0

Hope this helps you
If this helps kindly mark it as solved so that it may help others in future.

Thanks and Regards