Top 200’s Salesforce APEX MCQ with Answers


Before Going throw to this post you should read this post – 100+ APEX Salesforce MCQ

26.Consider the following trigger code. Identify what SOQL will return?
Trigger simpleTrigger on Account (after insert) {
Contact[] cons = [SELECT LastName FROM Contact
WHERE AccountID IN :Trigger.new];
//some other code
}

a. Finds every account that is associated with any of the triggering contacts
b. Finds every contact that is associated with any of the triggering accounts
c. Finds every contact that is associated with any of the triggering contacts
d. Finds every account that is associated with any of the triggering accounts

ANS: B

27.Identify the invalid trigger event from the following

a. before undelete
b. after insert
c. before update
d. after delete

ANS: A

28.A user inserts data on a VF page that invokes an Apex Trigger, which calls an SObject.addError()
method. Which statement is true ? Choose most appropriate option.

a. The error message will be displayed, provided the included in the page
b. The error message will be displayed next to the field
c. The error message will not be displayed unless the field method is used
d. The error message will not be displayed as the Apex Errors are only records

ANS: A

29. Below given is the code for a Map. Identify the correct option to add 2 elements to the Map. Map m = new Map(); ______________________ // Add first key value ______________________ // Add second key value

a. m.add(1,’First Entry’);
m.add(2,’Second Entry’);
b. m.insert(1,’First Entry’);
m.insert(2,’Second Entry’);
c. m.push(1,’First Entry’);
m.push(2,’Second Entry’);
d. m.put(1,’First Entry’);
m.put(2,’Second Entry’);

ANS: D

30.What are valid data types in Apex? (Select three)

a. Integer
b. Row Number
c. Date
d. ID

ANS: A,C,D

31.Which method causes the entire set of operation to be rolled back ?

a. error()
b. showError()
c. isError
d. addError()

ANS: D

32.You as a Apex Developer want to execute a code when 4 records of Offer_c object are updated.When you will use to write your code ?

a. Apex Web Services
b. Apex Trigger
c. Apex Unit Test
d. Apex Callouts

ANS: B

33.Which context variable provide a list of SObjects which we can use only in insert, update & undelete triggers?

a. old
b. oldMap
c. new
d. newMap

ANS: c

34.Identify the error in the following code.
public class Test{
Double x = 87.60;
Integer y = 56;
Integer Y = 67;
public void printData(){
System.debug(x+” “ +y +” “ +y);
}}

a. Redeclaration of y
b. Double is not a valid datatype
c. values are not properly concatenated
d. printData() definition is incorrect

ANS: A

35.A developer wrote an Apex code with SOQL embeded below. The account manager position does
not exist in the database. What error message will be displayed ?
Position_c position = [SELECT Status_c, Approval_Status_c
FROM Position_c
WHERE Name = ‘Accounts Manager’];

a. List has zero rows for assignment to SObject
b. List has 0 rows for assignment to SObject
c. List has no rows for assignment to SObject
d. List has many rows for assignment to SObject

ANS: C

36.In a Data Model of an application. Account and Contact Object has a look-up relationship where
Accounts is parent of contact. Refer the given SOQL statement & identify the type of query.
SELECT Account.Name. (SELECT Contact.FirstName, Contact.LastName FROM Account.Contact) FROM
Account

a. child-to-parent relationship query
b. parent-to-child relationship query
c. child-to-child relationship query
d. parent-to-parent relationship query

ANS: B

37.Which of the following clause is used in a SELECT statement of a SOQL query to control the order of the query results.

a. ORDER BY
b. WHERE
c. GROUP BY
d. LIMIT

ANS: A

38.In a Data Model of an application, Job application and Review objects has Master-Detail relationship where Job Application is parent of Review. What will be the relationshipName for child-to-parent relationship?

a. Review_c
b. Reviews_r
c. Job_Application_c
d. Job_Application_r


ANS: D

39.In which Salesforce instances would there be identical record ids? Choose most appropriate option

A. Production, full sandbox
B. Production, full sandbox, apex sandbox.
C. Production, full sandbox, coding only sandbox, apex sandbox.
D. Salesforce.com never repeats record ids.

ANS: D

40.A developer used following query to retrieve position object records.
Listpositons= [SELECT Name,Department,Location__c from Position__c];
Later in the code of Apex,developer try to print Status__c field value. Identify the type of Exception raised?

A. IndexException
B. QueryException
C. SObjectException
D. DMLException

ANS: B

41.A developer wrote an Apex Code with SOQL embedded as given below. The Accounts Manager
position does not exist in the database. What type of exception will be thrown?
Position__c position= [SELECT Status__c, Approval_Status__c FROM Position__c WHERE
Name=’AccountsManager’];

  1. DML exception
  2. Query exception
  3. NullPointer exception
  4. Index exception

ANS: 2

42.What is true about Encrypted Fields? Choose most appropriate option

  1. They are available in Validation Rules or Apex Scripts even if the user is not having the permission
    “View Encrypted Data”
  2. Encrypted fields can be converted to other field types
  3. A custom field can be converted to Encrypted Field
  4. In Email Templates, if an encrypted field needs to be displayed without the mask character, the User
    who receives the email, should have ‘View Encrypted Data’ permission.

ANS: 1

43.Before code can be deployed in production, what percentage of test coverage must be achieved ?

a) 25
b) 100
c) 50
d) 75

ANS: D

44.What are the three different custom tabs you can create?(Select 3)

a) APEX Tab
b) Web Tab
c) Visualforce Tab
d) Custom object Tab

ANS: B,C,D

45.______Job Application and Review objects has Master-Detail______. is parent of Review. What will be the RelationshipName for

a. Review__c
b. Reviews__r
c. Job_Application__c
d. Job_Application__r

ANS: D

46.Consider the following trigger code. Identify what SOQL will return?
Trigger simpleTrigger on Account (after insert) { Contact[] cons = [SELECT LastName FROM Contact
WHERE AccountId IN :Trigger.new]; //some other code }

a. Finds every account that is associated with any of the triggering contacts.
b. Finds every contact that is associated with any of the triggering accounts.
c. Finds every contacts that is associated with any of the triggering contacts.
d. Finds every account that is associated with any of the triggering accounts.

ANS: B

47.In Developer Edition how much storage space we get when we sign-up for org?

A. 5MB
B. 10MB
C. 15MB
D. 20MB

ANS: A

48.Which method causes the entire set of operations to be rolled back?

A. error()
B. showError()
C. isError()
D. addError()

ANS: D

49.Which function we used to put server side apex method call in queue?

A.$A.queueAction()
B.$A.enqueueAction()
C.$Lightning.queueAction()
D.$Lighthning.enqueueAction()

ANS: B

50.Which triggers are invoked when two contacts are merged?

A.Only delete and update contact triggers
B.Only delete and update triggers
C.No triggers
D.Delete and update contact triggers and triggers

ANS: A

51.Which annotation will be used to expose Apex class as REST Resource?

A.“@”RestResource
B.“@”ResourceRest
C.“@”HttpResource
D.“@”RestHttp

ANS: A


2 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *