Thursday, March 10, 2016

salesforce interview questions part3

1. Can we modify records directly in trigger.new ?
Ans: trigger.new is a read only list, but field values can be changed in case of before trigger
2. What does the error "list has no rows for assignment" mean?
Ans: it means the list you are trying to access has no values in it.
3. Why should we not write select query within for loop?
Ans: Writing select query within for loop may hit the governer limit of 100 select queries.
4. What should we do to avoid view state error in visualforce page?
Ans: Clear unused collections, define variable as transient.
5. What is a sandbox org?
Ans: It is the exact copy of your production org.
6. What is sosl?
Ans: select query that can return records of multiple objects as list of lists
7. How many records a select query soql can return?
Ans: as of now the limit is 50000
8. What is the full form of AJAX?
Ans: it stands for assynchronous java and XML
9. Why do we need to write test classes?
Ans: Salesforce does not allow deployment in production if the test coverage is less than 75%
10.How can you show a custom error message in trigger?
Ans: This can be done using addError() method in trigger
11. What is the use of future annotation?
Ans: Future method starts execution when Salesforce has resources available.That is for asynchronous execution.
12. How to identify if a class is a test class?
Ans: test class always begins with @isTest
13. How to convert a blob variable into a string?
Ans Use toString to convert blob into string
14. what are the different methods of batch apex class?
Ans: start method, execute method and finish method
15.What is' with sharing' in apex class code?
Ans: When you use 'with sharing', user's permissions and field-level security are respected. In case of 'without sharing' code runs in system mode.
16. How many records can a sosl return ?
Ans: It can return 2000 records as of now as per governers limit
17. Can you use dml statement in visualforce compoenent controller ?
Ans: To use dml in visualforce component you have to declare allowdml=true in visualforce component otherwise you will get an exception
      "DML is currently not allowed"
18. Can you write sosl in trigger>?
Ans: Earlier this was not allowed but now sosl are allowed in triggers.
19. Which are the different access modifiers in apex?
Ans: 1. Private 2. Public 3. Protected 4.Global are the four access modifiers allowed in apex
20. Can you change the master of a detail record in salesforce ?
Ans. Yes provided you have ticked marked "Allow reparenting" in field setting otherwise the field is read only and master cannot be changed.
21. 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];
22. IS there any limit on the number of items that can be stored in apex collections?
Ans: There is ni such limit but we need to consider heap size limit 6mb (6 MB as of now)
23. How can you monitor future actions of time based workflow?
Ans: setup --> administration set up --> monitoring --> time based workflow
24. What is visaulforce component ?
Ans: It is a piece of code that can be reused. It can be encapsulated in other visualforce pages.
25. Ho can you display the status of an AJAX update request in a visualforce page ?
Ans: To display AJAX request status we can use <apex:actionstatus> component.
26. How can you access custom label in apex:
Ans: Example --> string custLabelstr = System.Label.LabelNamehere
27.How can you get all the keys of a map variable ?
Ans: USe method keyset() for this
     Example = Set<id> idSet = mapname.keyset();
28. How can you compare values of a picklist field in validation rule?
Ans : for comparing picklist value use ispickval
      ISPICKVAL(picklist_field, text_to_compare)
29. What are the different types of sandboxes in salesforce ?
Ans: Developer, Developer Pro, Partial Data and Full are the 4 types of sandboxes in salesforce.
30. With what frequency can you refresh a full copy sandbox?
Ans: full copy sandbox can be refreshed every 29 days from production.
31. How can you make fields required on a visualforce page?
Ans: mark required = true as done in the example below:
     <apex:inputfield value="{!account.Description}" required="true"/>
32. What is minimum coverage for every trigger for deployment?
Ans: every trigger should have a minimum coverage of 1%. Total coverage should be 75%
33. What is minimum coverage for every class for deployment?
Ans: There is no such requirement. A class can have 0% but the total coverage should be >75%
34. How can you implement custom functionality for a standardcontroller visualforce page?
Ans: This can be done by associating a controller class with that standard controller using "Extenssions"
35. How can you get the current record id in a visualforce page ?
Ans use ApexPages.CurrentPage().getparameters().get('id') to get the current record id in visaulforce page.
36. Can a user change his own profile in salesforce ?
Ans: No, a user cannot change change his own profile !!
37. Can a user change his own role?
Ans: Yes this can be done !!
38. Reset security token option is unavailabel in set up. What could be the reason?
Ans: If in the profile setting "login ip ranges" have been set up then the option of "reset security token" is uanvailbale.
39. How can you skip record type selection page(and take up default record type) while creating new record of a aprticular object ?
Ans: just tickmark against the object by navigating to following :
     set up --> my personal information -- > Record type selection --> check against the required object
40. What are the different data types that a standard field record name can have?
Ans: Record name field can have either of the two data types : Auto Number or Text data type
41. Can you edit a apex trigger/apex class in production environment ?
Ans: No apex trigger /class cannot be edited in production.
42. Can you edit a visuaflorce apge in production environment ?
Ans: Yes this can be done.
43.How can you deliver a visualforce page in excel form ?
Ans: use contentType="application/vnd.ms-excel#Contacts.xls" in page component of visualforce page
44. What is trigger.new?
Ans: It is a list of records in current context in a trigger.
45. What does it mean when you get the error "too many soql queries 101 salesforce"
Ans: It means you are hitting the limit of 100 soql queries as per governers limit
46. How can you create a input field for date on a visualforce page ?
Ans: To create a input date field on vf page you will have to bind it with a existing date field on any object.
47. How can you convert a text to upper string ?
Ans: stringname.toUppercase();
48. How can you convert a integer into a string ?
Ans: string.valueof(integerName);
49. What are the different types of email templates that can be created in salesforce?
Ans: Text, HTML (using Letterhead), Custom (without using Letterhead) and Visualforce.
50. How can you display different picklist values for picklist fields in different page layouts?
Ans: This can be done using record types.

3 comments:

  1. it is really useful.
    can you please post some scenario based queries.
    thaks for a such grate thing..

    ReplyDelete
  2. It is really useful. Please keep posting ..thanks a lot

    ReplyDelete
  3. It is really useful. Please keep posting ..thanks a lot

    ReplyDelete