1. Difference between with sharing and without sharing in salesforce
Ans. By default, all Apex executes under the System user, ignoring all CRUD, field-level, and row-level security (that is always executes using the full permissions of the current user).
with sharing:
Enforcing the User’s Permissions, Sharing rules and field-level security should apply to the current user.
For example:
public with sharing class sharingClass {
// Code here
}
without sharing:
Not enforced the User’s Permissions, Sharing rules and field-level security.
For example:
public without sharing class noSharing {
// Code here
}
2. Access Modifiers in salesforce
Ans.
– private: This method/variable is accessible within the class it is defined.
– protected: This method/variable is also available to any inner classes or sub-classes. It can only be used by instance methods and member variables.
– public: This method/variable can be used by any Apex in this application namespace.
– global: this method/variable is accessible by all Apex everywhere.
• All methods/variable with the web-service keyword must be global.
– The default access modifier for methods and variables is private.
– protected: This method/variable is also available to any inner classes or sub-classes. It can only be used by instance methods and member variables.
– public: This method/variable can be used by any Apex in this application namespace.
– global: this method/variable is accessible by all Apex everywhere.
• All methods/variable with the web-service keyword must be global.
– The default access modifier for methods and variables is private.
3. Exceptions Statements in salesforce
Ans.
Throw: signals that an error has occurred and provides an exception object.
• Try: identifies the block of code where the exception can occur.
• Catch: identifies the block of code that can handle a particular exception. There may be multiple catch blocks for each try block.
• Finally: optionally identifies a block of code that is guaranteed to execute after a try block.
• Try: identifies the block of code where the exception can occur.
• Catch: identifies the block of code that can handle a particular exception. There may be multiple catch blocks for each try block.
• Finally: optionally identifies a block of code that is guaranteed to execute after a try block.
Exception Example:
public class OtherException extends BaseException {}
Try{
//Add code here
throw new OtherException(‘Something went wrong here…’);
} Catch (OtherException oex) {
//Caught a custom exception type here
} Catch (Exception ex){
//Caught all other exceptions here
}
public class OtherException extends BaseException {}
Try{
//Add code here
throw new OtherException(‘Something went wrong here…’);
} Catch (OtherException oex) {
//Caught a custom exception type here
} Catch (Exception ex){
//Caught all other exceptions here
}
4. What is the difference between a standard controller and custom controller ?
Ans: standard controller inherits all the standard object properties, standard button functionalities can be directly used. Custom controller defines custom functionalities, a standard controller can be extended to develop custom functionalities using keyword "extensions"
Ans: standard controller inherits all the standard object properties, standard button functionalities can be directly used. Custom controller defines custom functionalities, a standard controller can be extended to develop custom functionalities using keyword "extensions"
5. How to get current logged in users id in apex ?
Ans. Userinfo.getuserid()
6. How to fire dynamic query in SOQL?
Ans. Database.query('select name from account');
7. How can you lock records in apex?
Ans. Use For update in query to lock the record. For example: [select id,name from contact limit 10 For update];
8. How can you access custom label in apex ?
Ans. System.Label.LabelNamehere
9. What is search layout?
Ans . When we click on lookup field the results which is shown is called search layout.
10. What is mini page layout ?
Ans. For lookup fields on record detail page we see a link, whenever we put cursor on that link we see a popup window which displays few fields.
No comments:
Post a Comment