Developer Interview Question and Answer Part 2
Q). Variable and Method Access Modifiers
• Link classes, methods and variables have different levels depending on the keywords used in the declaration.
– private: This method/variable is accessible within the class it is defined.
– protected: This method/variable is also available to any inner classes or subclasses. 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 webService keyword must be global.
– The default access modifier for methods and variables is private.
– private: This method/variable is accessible within the class it is defined.
– protected: This method/variable is also available to any inner classes or subclasses. 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 webService keyword must be global.
– The default access modifier for methods and variables is private.
Q). Casting
Apex enables casting: A data type of one class can be assigned to a data type of another class, but only if one class is a child of other class.
• Casting converts an object from one data type to another.
• Casting between the generic sObject type and the specific
sObject type is also allowed.
For Example:
sObject s = new Account();
Account a = (Account)s;
Contact c = (Contact)s //this generates a run time error.
• Casting converts an object from one data type to another.
• Casting between the generic sObject type and the specific
sObject type is also allowed.
For Example:
sObject s = new Account();
Account a = (Account)s;
Contact c = (Contact)s //this generates a run time error.
Q). Exceptions Statements
Similar to Java, Apex uses exception to note errors and other events that disrupt script execution with the following keywords:
• 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.
• 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.
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
}
Q). Exception Methods
All exceptions support built-in methods for returning the error message and exception type, below is the some of the Exception Methods,
AsyncException
CalloutException
DmlException
EmailException
JSONException
ListException
MathException
NoAccessException
NoDataFoundException
NullPointerException
QueryException
http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_classes_exception_methods.htm
AsyncException
CalloutException
DmlException
EmailException
JSONException
ListException
MathException
NoAccessException
NoDataFoundException
NullPointerException
QueryException
http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_classes_exception_methods.htm
Q). Loops
• Apex supports the following five types of procedural loops:
– do {statement} while (Boolean_condition);
– while (Boolean_condition) statement;
– for (initialization; Boolean_exit_condition; increment) statement;
– for (variable : array_or_set) statement;
– for (variable : [inline_soql_query]) statement;
• All loops allow for loop control structures:
– break; exits the entire loop
– continue; skips to the next iteration of the loop
– do {statement} while (Boolean_condition);
– while (Boolean_condition) statement;
– for (initialization; Boolean_exit_condition; increment) statement;
– for (variable : array_or_set) statement;
– for (variable : [inline_soql_query]) statement;
• All loops allow for loop control structures:
– break; exits the entire loop
– continue; skips to the next iteration of the loop
9 comments:
Hi, I have all latest dumps of salesforce for all types of salesforce exams if anyone wants you can mail me at
sfdcconsultant25@gmail.com
These are original questions from the certification exam and very useful to pass the exam.
I have all latest dumps of following exams
90% questions come from it
Salesforce Administrator (ADM 201)
Salesforce Sales Cloud Consultant (CON 201)
Salesforce Service Cloud Consultant
Platform Developer I
App Builder
Immediately i will sent dumps latest one,which helps you to pass
I will give you as-surety for all latest dumps
Hi,
Thanks for sharing the great information, Its useful and helpful information…Keep Sharing.
thanks
salesforce training in hyderabad
Great knowledge. Thanks for sharing post
dbms interview questions
spring interview questions
salesforce interview questions
Hey Folks for the Latest Salesforce Exam dumps with Answers please reach out to rakesh.sdna@gmail.com
I update questions after every release.
THANK YOU FOR THE INFORMATION .HI GUYS IF YOU SEARCHING FOR software application development services
PLEASE VISIT US
software application development services
good information..
Wireless Solutions
Wonderful article, thanks for putting this together! This is obviously one great post.
salesforce-training-in-kukatpally
salesforce-training-in-hyderabad
salesforce-training-in-madhapur
salesforce-training-in-kphb
salesforce-training-in-hitechcity
Really very happy to say, your post is very interesting to read. I never stop myself to say something about it. You’re doing a great job. Keep it up.
Web Designing Training in Chennai
Web Designing Course in Chennai
Web Designing Training in Bangalore
Web Designing Course in Bangalore
Web Designing Training in Hyderabad
Web Designing Course in Hyderabad
Web Designing Training in Coimbatore
Web Designing Training
Web Designing Online Training
Thanks for sharing such a great blog
python training in bangalore | python online Training
artificial intelligence training in bangalore | artificial intelligence online training
machine learning training in bangalore | machine learning online training
uipath-training-in-bangalore | uipath online training
blockchain training in bangalore | blockchain online training
aws training in Bangalore | aws online training
data science training in bangalore | data science online training
hadoop training in bangalore | hadoop online training
iot training in bangalore | iot online training
devops training in banaglore | devops online training
Post a Comment