100+ APEX Salesforce MCQ


Hello friends, in this post we are going to discuss about APEX Salesforce Language Multiple Choice Questions with answers PDF | APEX Salesforce Language Objective Type Questions with Answers PDF

1.A developer wrote an APEX code with SOQL embeded as given below. There are five positions for IT department. What error message will be displayed ?

Position_c position =
[SELECT Status_c, Approval_Status_c
FROM Position_c
WHERE Department_c = ‘IT’ );

a. List has more than 1 row for assignment to SObject
b. List has multiple rows for assignment to SObject
c. List has many rows for assignment to SObject
d. List has too many rows for assignment to SObject

ANS: A

2.Which of the following clause is used in SOQL query to specify the maximum number of rows to
return?

a. Order By
b. Where
c. Group By
d. Limit

ANS: D

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

a. Only delete and update contact triggers
b. Only delete and update triggers on the parent account
c. No triggers
d. Delete and update contact triggers and triggers on the parent account.

ANS: A

4.What would be the value of old context variable when 3 records are inserted in an object.

a. null
b. new values
c. current values
d. old values

ANS: A

5.Which clause will be used in SOSL statement to restrict search in specific objects.

a. Limit
b. Returning
c. Using
d. Order By

ANS: B

6.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 parent-to-child relationship?

a. Review_c
b. Reviews_r
c. Job_application_c
d. Job_application_r

ANS: B

7.What should be the minimum code coverage % before deploying an Apex code?

a. 71
b. 73
c. 75
d. 72

ANS: C

8.A developer wrote an Apex code with SOQL embeded 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 = ‘Accounts Manager’];

a. DmlException
b. QueryException
c. NullPointerException
d. IndexException

ANS: B

9.In which salesforce instances would there be identical record IDs? Choose most appropriate.

a. Production; Full Sandbox
b. Production; Full Sandbox; Apex Sandbox
c. Production; Full Sandbox; Config only Sandbox; Apex Sandbox
d. Salesforce.com never repeats record IDs

ANS: A

10.Refer the given code & select the correct option for checking whether the set has an element 1 or not? Set mySet = new Set(); mySet.add(1); mySet.add(3); System.assert(…………);

a. mySet.r(1)
b. mySet.Index(1)
c. mySet.contains(1)
d. mySet.present(1)

ANS: C

11.Identify the correct trigger context variable which shows the currently executing code is Apex trigger

a. isInsert
b. isExecuting
c. isAfter
d. isDelete

ANS: B

12.What is the default option related to scope of fields to search in SOSL statement?

a. NAME FIELDS
b. SLIDEBAR FIELDS
c. ALL FIELDS
d. PHONE FIELDS

ANS: C

13.An org has a Candidate object with First Name and Last Name field as required. A developer is tryingto insert a candidate programmatically by following code. What exception will be raised?
Candidate_c candidate = new Candidate_c(First_Name_c = ‘Andrew’);
insert candidate;

a. IndexException
b. QueryException
c. NullPointerException
d. DmlException

ANS: D


14.What would fit into the Model category of MVC paradigm? Choose two most appropriate options.

a. VF
b. Custom Object
c. Apex Class
d. Custom Component
e. Controller Extensions

ANS: B,D

15.In Apex, all variables and expressions have a data type?

a. True
b. False

ANS: True

16.A developer created an email service and wants to deploy the classes it references in production. How can the developer write a test method to sufficiently test these classes? Choose most appropriate options.

a. The developer uses the Messaging.sendEmail().method address for the email service.
b. Classes that only contain email services are not subject requirements.
c. Developer creates Messaging.Inbound Email & pass them to Messaging inboundEmailHandler.
d. The developer creates a Messaging.outbound Email method of the Messaging.InboundEmail
Handler class.

ANS: C

17.Match the Dynamic Apex features with the corresponding syntax.

Features:
a) Describe Object/ Field
b) Dynamic SOQL
c) Dynamic DML
d) Dynamic SOSL

Syntax: 1. Scheme.DescribeFieldResult f = Schema.sObjectType.Account.fields.AccountNumber;

2. List s = Database.query(querSTring);

3. Schema.DescribeFieldResult f = Schema.sObjectType.Account.fields.AccountNumber; Sobject s = Database.query(‘SELECT AccountNumber FROM Account LIMIT 1’); s.put(f.getsObjectField(),’12345’);

4. List o = Database.search(queryString); Choose most appropriate option.

a. a-1, b-2, c-3, d-4
b. a-1, b-4, c-3, d-2
c. a-3, b-4, c-1, d-2
d. a-3, b-2, c-1, d-4

ANS: A

18.In a Data Model of an application, Account & Contact objects has a look-up relationship where
Account is parent of contact. Refer the given SOQL statement and identify the type of query.
SELECT Contact.FirstName, Contact.Account.Name from Contact

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: A

19.When you will use SOQL ? (Select three)

a. When you know in which objects the data resides
b. Count the number of records
c. Sort results
d. Retrieve data for a specific term

ANS: A,B,C

20.Consider the following code segment :

List <Account>accList = [Select Id, AccountNumber From Account limit 20]; System.debug(‘Account Name : ‘ + accList[0].Name); Choose most appropriate option.

a. Above code will fail to execute during compile time since the name field accessed without
being queried.
b. Above code will fail to execute only during run time since the name accessed without being
queried.
c. Above code will throw exception.
d. Above code will not saved.

ANS: B

21.In an APEX class, to declare a method as Test method, which of the following annotation or keyword you will see? ( Select 2 )

a. “@Test”
b. testing method
c. “@” is Test
d. testMethod

ANS: C,D

22.What does use of “with sharing” keyword enforce ? Choose appropriate option.

a. Only the record sharing and FLS for the running use
b. Only CRUD permission for the running user.
c. Record sharing, FLS, CRUD permission for the running user
d. Only the record sharing for the running user

ANS: D

23.For the following Apex code. Select the correct option to fill in the blank to retrieve the index 0

>my List = newList<Integer>();

);

…………………….;

a. myList.pull(0);
b. myList.get(0);
c. myList.get(1);
d. myList.retrieve(0);

ANS: B

24.A developer used following query to retrieve Position object records.

List<Position_c> position = [ Select Name, Department_c, Location_c FROM Position_c]; Laler in the code of Apex, developer try to print status_c field value. Identify the type of exception raised.

a. Index Exception
b. Query Exception
c. SObject Exception
d. DML Exception

ANS: B

25.Consider the following SOSL statement.

FIND {Joe Smith }
What would be returned by statement assuming the search text present in 4 records ?

a. Return the IDs of the records where Joe Smith is found
b. Return the name of the records where Joe Smith is found
c. Return the OwnerID of the records where Joe Smith is found
d. Return the external IDs of the records where Joe Smith is found

ANS: A

       


2 Comments

Leave a Reply

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