Friday, October 17, 2014

Developer Interview Question and Answer Part 2

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.

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.

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.
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
}

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

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




4 comments:

sfdc consultant said...

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

hariprasad p said...

Hi,
Thanks for sharing the great information, Its useful and helpful information…Keep Sharing.
thanks
salesforce training in hyderabad

Hema Malini said...

Great knowledge. Thanks for sharing post
dbms interview questions
spring interview questions
salesforce interview questions

Rakesh said...

Hey Folks for the Latest Salesforce Exam dumps with Answers please reach out to rakesh.sdna@gmail.com
I update questions after every release.

Post a Comment

 
| ,