When to use public class and when to use global class?



When to use public class and when to use global class?..

Answer / Mukul Chaudhary

Public classes in Salesforce are accessible from any context (Apex code, Visualforce pages, etc.), but they must be used inside a namespace. Global classes, on the other hand, can be accessed without a namespace qualification, making them more flexible for reuse across different orgs and packages. However, global classes should only be used when necessary, as they may introduce potential naming conflicts and make your code less portable.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Salesforce Interview Questions

Can you create a roll-up summary field in a lookup relation? State the number of such fields to be created for an object.

1 Answers  


Explain communities and sites in salesforce?

1 Answers  


What is wrapper class in apex salesforce ?

1 Answers  


What are the Exceptions Statements in salesforce?

1 Answers  


What are the standard profiles in salesforce?

1 Answers  


What is a governor limit in salesforce?

1 Answers  


What are the types of soql statements in sales force?

1 Answers  


What is lightning data services?

1 Answers  


How do users see report headers while scrolling? What to do to enable this floating report header?

1 Answers  


What is process builder? : salesforce process builder

1 Answers  


How many types of email templates can be created in salesforce?

1 Answers  


What is system.runas () is test class?

1 Answers  


Categories