Salesforce Apex interview Questions - PowerPoint PPT Presentation

About This Presentation
Title:

Salesforce Apex interview Questions

Description:

Salesforce Apex interview Questions – PowerPoint PPT presentation

Number of Views:435
Slides: 62
Provided by: svrtechnologie
Category:
Tags: apex | salesforce

less

Transcript and Presenter's Notes

Title: Salesforce Apex interview Questions


1
Salesforce ApexInterview Questions and Answers
2
1. What are the access modifiers in the apex ?
  •  If you do not specify an access modifier, the
    method or variable is private. This means that
    the method or variable is visible to any inner
    classes in the defining Apex class, and to the
    classes that extend the defining Apex class.

3
2. What are reference variables in apex ?
  • Passing Parameters By Reference and By Value in
    Apex. In Apex, all primitive data type
    arguments, such as Integer or String, are passed
    into methods by value. This means that any
    changes to the arguments exist only within the
    scope of the method. When the method returns, the
    changes to the arguments are lost.

4
3. In which object Roles are stored ?
  •  UserRole

5
4. What is on-Demand process ?
  • On-demand process is nothing but pay for what
    you use policy.
  • We can subscribe to what we want and
    pay-as-you-go model.

6
5. Will the Flow supports bulkification mechanism
?
  • Yes , flows support bulk records processing also.

7
6. If you organization Workflows limit is over
and if you want to write a workflow immediately
and it critical, what will you do ?
  • 1. De-activate any workflows and create it using
    trigger and then do the new workflow.

    or2. Go for Schedule apex or trigger to achieve
    this workflow.

8
7. What is an alternative for workflow ?
  • Process Builder or Flows or Trigger or Schedule
    apex or

9
8. What is the use of isNew() ?
  •  Checks whether the record is newly created.

10
9. What is the difference between List and Set ?
  •  Another significant difference between List and
    Set in Java is order. A list is an Ordered
    Collection while Set is an unordered Collection.
    List maintains insertion order of elements, means
    any element which is inserted before will go on
    the lower index than any element which is
    inserted after.

11
10. Data loader ? and which format it will
support ?
  • Data loader is a tool to manage bulk data. It
    will support .csv format of Excel.

12
11. What are the Disadvantages by using Batch
Apex processing ?
  • It runs asynchronously, which can make it hard to
    troubleshoot without some coded debugging,
    logging, and persistent stateful reporting. It
    also means that its queued to run, which may
    cause delays in starting.
  • Theres a limit of 5 batches in play at any time,
    which makes it tricky to start batches from
    triggers unless you are checking limits.If you
    need access within execute() to some large part
    of the full dataset being iterated, this is not
    available. Each execution only has access to
    whatever is passed to it, although you can
    persist class variables by implementing
    Database.stateful.
  • There is still a (fairly large) limit on total
    Heap size for the entire batch run, which means
    that some very complex logic may run over, and
    need to be broken into separate batches.

13
12. How many users have you supported ?
  • Number of users in the Salesforce organization.
    It helps the recruiter to understand your
    scalability.

14
13. In which object all email templates are saved
?
  •  EmailTemplate

15
14. What is Salesforce sites ?
  • Used to show data from our organization for
    public view.

16
15. Explain The Apex Data Manipulation Language
(dml) Operations ?
  • Use data manipulation language (DML) operations
    to insert, update, delete, and restore data in a
    database.
  • You can execute DML operations using two
    different forms
  • Apex DML statements, such as
  • insertSObject
  • Apex DML database methods, such as
  • Database.SaveResult result
    Database.Insert(SObject)
  • While most DML operations are available in either
    form, some exist only in one form or
    the other.

17
Continuation..
  • The different DML operation forms enable
    different types of exception processing
  • Use DML statements if you want any error that
    occurs during bulk DML processing to be thrown
    as an Apex exception that immediately interrupts
    control flow (by using try. . .catch blocks).
    This behavior is similar to the way exceptions
    are handled in most database procedural
    languages.
  • Use DML database methods if you want to allow
    partial success of a bulk DML operation If a
    record fails, the remainder of the DML operation
    can still succeed. Your application can then
    inspect the rejected records and possibly retry
    the operation. When using this form, you can
    write code that never throws DML exception
    errors. Instead, your code can use the
    appropriate results array to judge success or
    failure. Note that DML database methods also
    include a syntax that supports thrown exceptions,
    similar to DML statements.

18
16. In which object all Account Team Members are
added ?
  • AccountTeamMember

19
17. Auto-response rules and Escalation rules(for
which objects are mandatory) ?
  • Case and Lead.

20
18. What is Documenting Salesforce.com in Apex
class files ?
  • I have used apexDoc for a while and we are
    starting to roll it out more fully for our use at
    my organization. It is open source software and
    so you could always contribute some updates for
    it What features are you wanting to add to it
    that it doesnt have (just to give a flavor)?
  • In answer to your questions
  • I dont think anybody has successfully managed to
    do this. There is an idea of the ideas exchange
    for it to be done but it seems to gain very
    little support.
  • Theoretically, it should be pretty easy as apex
    is a Java DSL. Have you tried running Doxygen and
    if so what errors does it throw up?

21
Continuation..
  • I use Apex Doc to generate some basic output and
    then have a little script tied in to copy across
    custom CSS and things. It isnt perfect but it
    does the small amount we need at the moment.
  • I believe the IDE is being open sourced at some
    time in which case I would imagine the antlr
    grammar file would become available which may
    help you out.
  • I know it is not really an answer for what you
    wanted to hear per se, but sadly its all we have
    atm (and I would love a nicer documentation
    generator!!)

22
19. In which object all Opportunity Team Members
are added ?
  •  OpportunityTeamMember

23
20. Difference between REST and SOAP APIS ?
  • Varies on records that can be handled.

24
21. In Which object all Apex Pages are stored ?
  •  ApexPage

25
22. What are the uses of the tag ?
  • A component that provides support for invoking
    controller action methods directly from
    JavaScript code using an AJAX request. A
    component must be a child of a component. Because
    binding between the caller and is done based on
    parameter order, ensure that the order of is
    matched by the callers argument list.
  • Unlike, which only provides support for invoking
    controller action methods from other Visualforce
    components, defines a new JavaScript function
    which can then be called from within a block of
    JavaScript code.
  • Note Beginning with API version 23 you cant
    place inside an iteration component and so on.
    Put them after the iteration component, and
    inside the iteration put a normal JavaScript
    function that calls it.

26
Continuation..
  • This tag supports following attributes
  • Action
  • The action method invoked when the actionFunction
    is called by a JavaScript event elsewhere in the
    page markup. Use merge-field syntax to reference
    the method. For example, action!save
    references the save method in the controller. If
    an action is not specified, the page simply
    refreshes.
  • Focus
  • The ID of the component that is in focus after
    the AJAX request completes.
  • Id
  • An identifier that allows the actionFunction
    component to be referenced by other components in
    the page.

27
Continuation..
  • Immediate
  • A Boolean value that specifies whether the action
    associated with this component should happen
    immediately, without processing any validation
    rules associated with the fields on the page. If
    set to true, the action happens immediately and
    validation rules are skipped. If not specified,
    this value defaults to false.
  • Name
  • The name of the JavaScript function that, when
    invoked elsewhere in the page markup, causes the
    method specified by the action attribute to
    execute. When the action method completes, the
    components specified by the reRender attribute
    are refreshed.
  • Onbeforedomupdate
  • The JavaScript invoked when the onbeforedomupdate
    event occursthat is, when the

28
Continuation..
  • Status
  • The ID of an associated component that displays
    the status of an AJAX update request. See the
    actionStatus component.
  • timeout
  • The amount of time (in milliseconds) before an
    AJAX update request should time out.

29
23. What is creating debug log for users ?
  • Track code.

30
24. What is Workarounds for Missing Apex
Time.format() Instance Method ?
  • You could just split the DateTime format() result
    on the first space does that give you what
    youre looking for?
  • public String myDateFormat(DateTime dt)
  • String parts dt.format().split( )
  • return (parts.size() 3) ? (parts1
    parts2) parts1
  • produces
  • 638 PM
  • for me in English (United States), and
  • 1842
  • in French(France).

31
Continuation..
  • UPDATE
  • As tomlogic points out, the above method is not
    very robust some locales may include spaces in
    the date or time portion of the format, and the
    ordering is not consistent. This second attempt
    assumes that the date and time are separated by
    zero or more spaces, but handles spaces within
    the two portions, and either ordering of date and
    time. The only assumption made is that the
    formatted Date is contained within the formatted
    Time
  • public String myDateFormat(DateTime dt)
  • return dt.format().replace(dt.date().format(),
    ).trim()
  • Seems to work fine for Hebrew, Vietnamese
    Korean, as well as English and French.

32
25. How cases are created ?
  • Email to Case and Web to Case

33
26. What is the difference between With Sharing
and Without Sharing ?
  • For example, if a method is defined in a class
    declared with sharing is called by a class
    declared with without sharing, the method will
    execute with sharing rules enforced. For
    example, if the class is called by another class
    that has sharing enforced, then sharing is
    enforced for the called class.

34
27. What is after undelete ?
  • While retrieving from recycle bin

35
28. In which object all Approval process are
stored ?
  • Approval

36
29. Is there an average method for apex math ?
  • Unfortunately the standard math methods only
    include simpler operations (i.e. those that work
    on a single, or two values), so it looks as
    though youll have to roll your own method.
  • Of course, the number of script statements
    executed will be proportional to the length of
    the list, so of the lists are ever of a fixed
    size it could be worth using a macro to generate
    the addition part for you
  • Int sum i0 i1 in
  • Doing so would only count for one statement, but
    youll only need this if governor limits are of
    concern which is often not a worry.
  • If govenor limits arent an issue you could
    create a function along these lines

37
Continuation..
  • Skip code block
  • Integer myInts new Integer1, 2, 3, 4, 5,
    6, 7
  • Integer total 0
  • Double dAvg
  • for (Integer i myInts)
  • total i
  • dAvg Double.valueOf(total) / myInts.size()
  • return dAvg

38
30. Will Trigger.new supports gtInsert, Will
Trigger.Delete supports gtDelete ?
  • Yes.

39
31. What is a constructor ?
  •  A constructor is a special method of a class or
    structure in object-oriented programming that
    initializes an object of that type. A constructor
    is an instance method that usually has the same
    name as the class, and can be used to set the
    values of the members of an object, either to
    default or to user-defined values.

40
32. What is Inline visualforce page ?
  • Having vf page in pagelayout.

41
33. What are the Grammar for creating an Apex
parser ?
  • Keep an eye on Apex tooling API, which is used in
    Developer console. This is supposed to be
    released to public access soon.

42
34. If is child is mandatory field in lookup and
I m deleting Parent, will child get deleted ?
  •  No.

43
35. What is the use of the static variables ?
  • Static variables are used when only one copy of
    the variable is required. so if you declare
    variable inside the method there is no use of
    such variable its become local to function
    only.. Variables declared static are commonly
    shared across all instances of a class.

44
36. Junction object ? when will we use ? If we
delete the junction object what will happen ?
  • For many to many relationship.

45
37. Does default value do anything if the
object is created through Apex ?
  • New feature coming in the next release
  • Foo__c f Foo__c.sobjecttype.newSObject(
  • recordTypeId, // can be null
  • true) // loadDefaultValues

46
38. Can we have V.F pages in page layout ?
  • Yes.

47
39. What are Sobjects ?
  • An sObject is any object that can be stored in
    the Force.com platform database. These are not
    objects in the sense of instances of Apex
    classes rather, they are representations of data
    that has or will be persisted. sObject is a
    generic abstract type that corresponds to any
    persisted object type.

48
40. How to create standard object as child to
custom object(which is not possible thru standard
away process,have to bypass this restriction) ?
  • Create Lookup and make the lookup field mandatory.

49
41. Detect the current Logging Level in Apex ?
  • Unfortunately, I dont think there is a way to
    check the current logging level in APEX.

50
42. In a visual force page the save should ensure
the data to be be stored in current object as
well as associated child object ?
  • We have to use Database.SavePoint and
    Database.Rollback for this situation.

51
Continuation..
  • do not open recruitmentfor that position.
    whenever a record submitted to the Approval
    process, the record is going into locking state.
    if it is approved then it is in locking state
    forever.if it is rejected then that records come
    into unlocking state. In approval process, we can
    trigger the workflow when initial submission,
    approval action, rejection action, final
    rejection..
  • Trigger Trigger is also same when a DML event
    occurs like insert, update, delete trigger will
    fireHere in deletion Scenario also trigger
    will fire.but in workflows, a workflow cannot
    fire.for deletion.

52
43. What is Map in apex ?
  •  A map is a collection of key-value pairs where
    each unique key maps to a single value. Keys and
    values can be any data type primitive types,
    collections, sObjects, user-defined types, and
    built-in Apex types.

53
44. What is audit field, what is the purpose of
audit field ?
  • Created By, Created Date, Last Modified By and
    Last Modified Date are audit fields. Used to
    track when the changes are done to the records.

54
45. Call Apex class method on the fly
(dynamically) ?
  • While you can instantiate a class based on its
    name using the Type system class, you cant
    dynamically locate a method and execute it. The
    best that you can do is to dynamically create an
    instance of a class that implements an interface
    and executes one of the methods on the interface.
  • Theres more information on the Type class and an
    example in the
  • Apex Developers Guide

55
46. What we need to do for extending the limit of
creating only 2 M-D relationships for custom
object ?
  • Create Lookup and make the lookup field mandatory.

56
47. Can we have duplicate Keys in Map ?
  • You cant have duplicate keys in a Map. You can
    rather create a MapltKey, Listgt, or if you can,
    use Guavas Multimap. And then you can get the
    java.util.Map using the MultimapasMap() method.

57
48. How to write java script code for save button
?
  • We have to create the custom button and in that
    custom button, we have to write Javascript code.

58
49. How many objects we can store in list ?
  • You can store only one Object at a time. But you
    can store as many as records or instance of an
    object till you dont hit Salesforce Heap size
    limit which is 6 MB for Developer Edition. So it
    will depend on data you are storing in List like
    how many fields and type of data you want to
    store in that list.

59
Continuation..
  • When you delete the master it will cascade delete
    all detail records relating to that master. A
    typical use of a Master-Detail would be the
    classic Sales Order and Sales Order Items
    objects.
  • Lookups are generally for use where you may or
    may need to have a relationship between two
    objects (but not always).
  • Lookups are generally used to reference commonly
    shared data, such as reference data.
  • Lookups are used to link two objects together
    when you dont want the behaviour of the
    master-detail particularly around sharing
    rules, profile permissions and cascade delete.
  • Lookups are used when you need to relate multiple
    parents to the detail record.

60
50. What are the attributes of apex tag ?
  • Attribute tag is used in creating components.

61
THANKS!
  • For more details, you can contact us
  • 91 988 502 2027 info_at_svrtechnologies.com
Write a Comment
User Comments (0)
About PowerShow.com