APEX Salesforce Objective Type Questions and Answers


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

77.A developer wrote an apex code with soql embedded as given below. The account manager position
does not exist in database what type of exception will be thrown. QUERY:
Position__c Position = (select Status__c, Approval__status__c from Position__c where name=’Accounts
Manager’);

a) DML Exception
b) Query Exception
c) Null pointer Exception
d) Index Exception

ANS: B

78.Refer the given code and choose the correct option for checking whether set has an element 1 or
not? CODE: Set myset = new set(); myset.add(1); myset.add(3); system.assert(……);

a) myset.remove(1)
b) myset.index(1)
c) myset.contains(1)
d) myset.present(1)

ANS: C

79.In apex all variables and expressions have a data type?

TRUE
FALSE

ANS: TRUE

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

a) The developer uses messaging send.email() method address to the email service.
b) Class that only contains email services are not subject requirements.
c) Developer create messaging inbound email and pass them to messaging inbound email handler
d) The developer creates messaging outbound email method of messaging.Inbound email handler class

ANS: A

81.An org has candidate object with firstname and lastname field is required. A developer is trying to
insert a candidate programmatically by following code. What exception will be made? Code:
Candidate__c Candidate = new Candidate__c (First_Name__c = ‘Andrew’); Insert Candidate;

a) Index exception
b) Query exception
c) Nullpoint exception
d) Dml exception

ANS: D

82.What would fit into the model category of MVC paradigm? Choose two appropriate options.

a) VF
b) Custom object
c) Apex class
d) Custom componen

ANS: B,D

83.In a data model of an application, account & contact objects have a look up relation where account
is parent of contact. Refer the below SOQL statements 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

84.When u will use SOQL. Select 3 options

a) When you know in which objects the data resides
b) Count the no of records
c) Sort results
d) Retrieve a date from specific term

ANS: A,B,C

85.Consider the following code segment. List <Account>acclist = [select id, account, number from Account limit 20;] System.debug(‘Account Name:’ +acclist[0]. Name); Choose 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 during run time since the name field accessed without being queried.
c) Above code will throw exception.
d) Above code will not be saved.

ANS: C

86.In an Apex class, to declare a method as test method, which of the following annotation on keyword will u use? (select 2)

a) “@Test”
b) Testing Method
c) “@”isTest
d) testMethod

ANS: C,D

87.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 running user
c) Record sharing, FLS, CRUD record sharing for running user
d) Only the record sharing for running user

ANS: D

88.For the following Apex code select the correct option to fill the blank to retrieve the index 0. > mylist
= newList ();

a) mylist.pull(0);
b) mylist.get(0);

c) mylist.get(1);
d) mylist.retrive(0);

ANS: B

89.A developer used following query to retrieve Position object records. List Position = [Select Name,
Department__C, Location__c from Position__c]. Later in the code of Apex, developer try to print
Status__c field value. Identify the type of exception made

a) Index
b) Query Exception
c) SObject
d) Dml Exception

ANS: B

90.Consider the following SOSL statement. “Find {Joe Smith}”. What would be returned by statement assuming the saved text present in records?

a) Return the ids of the record where Joe Smith is found.
b) Return the name of the record where Joe Smith is found.
c) Return the owner ids of the record where Joe Smith is found.
d) Return the external ids of the record where Joe Smith is found.

ANS: A

91.Consider the following the trigger code. Identify what SOQL will return? Trigger simple trigger on
Account (After insert) {Contact [] cons = {select lastname from contact where Accountid in:
trigger.name}; 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

92.Identify the invalid trigger event from the following.

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

ANS: A

93.A user insert data into VF page that contains an apex trigger which calls an SObject.adderror()
method. Which statement is true. Choose most appropriate.

a) The error message will be displayed, provided component 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 filed method is used.

d) The error message will not be displayed as the apex errors are only records.

ANS: A

94.What are the valid data type in apex? select 3

a) Integer
b) Row Number
c) Date
d) Id

ANS: A,C,D

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

a) error()
b) showerror()
c) iserror
d) adderror()

ANS: D

96.You as an Apex developer want to execute a code when 4 records of Offer__c object are updated.
When will use to write your code?

a) Apex web services
b) Apex triggers
c) Apex unittest
d) Apex callouts

ANS: B

97.Which context variable provide a list of SObects which we can use only in inset, update & undelete triggers?

a) Old
b) OldMap
c) New
d) NewMap

ANS: C

98.Identify the error in following code. Public Class Test { Double x=87,60; integer y = 56; Integer Y=67;
Print 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() function is incorrect

ANS: A

99.A developer wrote an apex code with soql embedded 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 values for assignment to subject.
b) List has 0 rows for assignment to subject.
c) List has no rows for assignment to subject.
d) List has many rows for assignment to subject.

ANS: C

100.In a data model of an application, Accounts and contacts objects have a look up relation where
account is the parent of contact. Refer the given soql statement & identify the types of query. Select
account.name. (select contact.firstname, contact.lastname from account.contacts) 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

101.which of the following clause is used on a select statement of soql query to control the order of the Query results.

a) order by
b) where
c) group by
d) limit

ANS: A

102.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 relationship name for child-to-parent relationship?

a)Review___c
b)Review___r
c)Jobapplication___c
d)Jobapplication___r

ANS: D

103.Describe the relationship between sObjects and Salesforce records.

a) The name of an sObject field in Apex is the label of the field in Salesforce.
b) A custom object’s API name and label are the same.
c) Every record in Salesforce is natively represented as an sObject in Apex.

ANS:C

104.You can obtain an instance of an sObject, such as Account, in one of the following ways:

a) By creating the sObject only.
b) Either by creating the sObject or by retrieving a persistent record from Salesforce using SOQL.
c) By retrieving the sObject only

ANS:B

105.Which of the following is correct about a generic sObject variable?

a) A generic sObject variable can be assigned only to another generic sObject.
b) Generic sObjectscan’t be created.
c) A generic sObject variable can be assigned to any specific sObject, standard or custom. Such as
Account or Book__c.

ANS:C


1 Comment

Leave a Reply

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