









































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
A comprehensive collection of quiz questions and answers related to the apex programming language, specifically designed for salesforce certified platform developer i exam preparation. It covers fundamental concepts like data types, collections, classes, methods, access modifiers, and more. Valuable for students and professionals seeking to enhance their understanding of apex programming within the salesforce platform.
Typology: Exams
1 / 49
This page cannot be seen from the preview
Don't miss anything!










































What is a List? - Answer: A List is an ordered collection of elements of a single data type. Elements added to a List are assigned an implicit index, and therefore, Lists can contain non-unique values (i.e. elements can be duplicated within a List). What is a Set? - Answer: A Set is an unordered collection of unique elements. There are no indexes assigned to elements in a Set, and therefore, elements in a Set much be unique. What is a Map? - Answer: A Map is a collection of key-value pairs. Keys must be unique, but Values can be repeated. With Maps, we supply the index, unlike Lists, where the index is automatically applied when an element is added.
What is a common use case for Lists? - Answer: Lists are commonly used to hold the results of a SOQL query. What is a common use case for Sets? - Answer: Sets are commonly used to store values used to filter data queried by SOQL. What is a common use case for Maps? - Answer: Maps are commonly used as a cache of records that can be accessed by key/ID. Are Apex Arrays the same as Java Arrays? Why or why not? - Answer: While Apex Array notation seems the same as Java Array notation, they are internally different. Apex Arrays can be dynamically resized, while Java Arrays cannot be dynamically resized. //Array notation Account[] accounts = new Account[] {acc1,acc2,acc3}; //List notation List
What is an Apex Trigger? - Answer: A procedure that automatically executes during a DML operation. What are the three types of FOR() loops that Apex code supports? - Answer: 1.) Traditional FOR() loops 2.) List Iteration FOR() loops 3.) SOQL FOR() loops What are the three types of Collection data types in Apex code? - Answer: 1.) Lists 2.) Maps 3.) Sets What are Collections used for in Apex code? - Answer: Collections are used to store groups of elements, such as primitive data types, or sObjects. Where are the three areas where you can develop Apex code? - Answer: 1.) The Force.com IDE 2.) The Developer Console 3.) The Setup menu What conditional statements does Apex support? - Answer: if-else What conditional statements are not supported by Apex? - Answer: 1.) case 2.) switch
What is the sObject data type? - Answer: The sObject data type is a generic data type that is the parent class for all standard and custom objects in Apex. What are two data types that are unique to Apex? - Answer: 1.) sObject 2.) ID What is an inner class? - Answer: A class within another class Does the name of a class need to begin with a capital letter? - Answer: No. But, it is recommended that this be done. More specifically, it is recommended that the Java notation be followed. What are some ways that Apex classes are different from Java classes? - Answer: In Apex: 1.) Inner classes can only be nested one level deep 2.) Static methods and attributes can only be declared in a top-level class definition (i.e. an "outer class"). 3.) The system-defined "Exception" class must be extended in order to create new exception classes. What are two ways that an Apex class can be created from the UI - Answer: Under Setup > Develop > Apex Classes... 1.) Click the "New" button to enter the code manually.
3.) You want to allow users from outside the namespace to access the code. What happens when you use the public access modifier? - Answer: The class will be accessible throughout the application, org, or namespace that comprises the class. What happens when you use the private access modifier? - Answer: When you use the private access modifier in a class definition of an inner class, the inner class is only accessible to the outer class. What is the default access level for top-level classes, also called "outer classes"? - Answer: There is no default access level for top-level classes. The access modifier must be specified. What access modifiers can be assigned to a top-level class? - Answer: 1.) global 2.) public What is the default access level for inner classes? - Answer: private What is the default access modifier for all methods and attributes across all Apex classes? - Answer: private True or False: All Apex code executes in the system mode. - Answer: False. All Apex code, with the exception of anonymous blocks, executes in the system mode.
What happens when the code executes in system mode? - Answer: The code ignores all CRED permissions on objects and field level security, and ignores all record sharing privileges. What happens when you apply the "with sharing" definition modifier to a class? - Answer: Record level sharing privileges are enforced within the class. For example, a SOQL query executed within a "with sharing" class will only return the records to which the user has at least Read Only access. Similarly, users can only update records to which he/she has Read/Write access. True or False: A "with sharing" class still ignores all CRED permissions on objects and field level security. - Answer: True What happens when you apply the "without sharing" definition modifier to a class? - Answer: Sharing model access will be ignored. This means that when a user queries the database, the record level read or edit restrictions are not taken into account. Also referred to as "running in system mode". What happens when neither the "with sharing" or "without sharing" definition modifiers are specified for a class? - Answer: The sharing model access is enforced. That is to say, the "with sharing" behavior is the default. What happens if a class is called from a class that does not have sharing enforced?
2.) private 3.) protected 4.) global What can access a protected method or attribute? - Answer: Only instance methods and member attributes can access a protected method or attribute. True or False: A global method or attribute can be declared within a private class. - Answer: False. If you declare a global method or attribute within a class, that class must also be declared as global. Describe a static method. - Answer: Static methods do not require an instance of an object to run. They are accessed through the class itself. They are generally utility methods that do not depend on an instance of the class. Give an example of a standard static method. - Answer: system.debug(); Describe static attributes. - Answer: Static attributes are accessed through the class itself, and not through an instance of the class. They are used to store data that is shared within the class. All instances of the same class invoked in the same context share the same copy of static attributes. They can be used to set recursive flags to prevent recursive logic from performing the same operation more than once.
What is a constant? - Answer: Constants are attributes that can be assigned a value only once. Constants are defined using the "static" and "final" keywords. When can a constant be initialized? - Answer: Either in the declaration itself, or via a static initializer method, if the constant is defined within a class. What is the syntax for instantiating a class object? - Answer: [class name] [object name] = new [constructor()]; True or False: To work with non-static methods or attributes within a class, you do not need to create an instance of the class. - Answer: False. What is a constructor? - Answer: A constructor is a special method that is used to create an object out of a class definition. Do constructors have a return type? - Answer: No. True or False: Classes have a default, no argument, invisible public constructor ONLY if no explicit constructor is defined. - Answer: True. The default constructor goes away when you define a custom constructor. What is the "this" keyword used for? - Answer: The "this" keyword is used to represent the methods and attributes of the current instance of the class.
What is the ProcessSubmitRequest class used for? - Answer: ProcessSubmitRequest is used to submit a workflow item for approval. What is the ProcessWorkItemRequest class used for? - Answer: ProcessWorkItemRequest is used to process an item after it has been submitted Describe the format of Parent-to-Child relationships. - Answer: Parent-to-Child relationships use plural version of the child object name. Ex. Contacts If the relationship is a custom relationship, the relationship is appended with "__r" Ex. Interviewers__r Describe the format of Child-to-Parent relationships. - Answer: Child-to-Parent relationships use the singular version of the parent object name. Ex. Account If the relationship is a custom relationship, the relationship is appended with "__r" Ex. Position__r
True or False: Relationships in Apex are written in dot notation. - Answer: True. Ex. myRecord.Position__r.Status__c; Describe the three parts of a relationship field. - Answer: 1.) ID (position__c) 2.) Reference (position__r) 3.) Related List (job_applications__r) How many member variables exist on the child object to reference the parent object? - Answer: Two. 1.) Foreign key ( record.relationship_field__c = '001234567891ABC'; ) 2.) Object reference ( record.relationship_field__r = new ParentObject__c (); ) How many member variables exist on the parent object to reference the child object? - Answer: One. What does SOQL stand for? - Answer: Salesforce Object Query Language Where can you execute a SOQL query? - Answer: 1.) the queryString parameter in the query() call 2.) Apex statements 3.) Visualforce controllers and getter methods 4.) Schema explorer in the Force.com IDE
What does the AVG() function do within a SOQL query? - Answer: AVG() returns the average value of a numeric field What does the COUNT() function do within a SOQL query? - Answer: COUNT() returns the total number of rows matching the query criteria What does the COUNT_DISTINCT() function do within a SOQL query - Answer: COUNT_DISTINCT() returns the number of distinct non-null field values What does the MIN() function do within a SOQL query? - Answer: MIN() returns the minimum value of a field What does the MAX() function do within a SOQL query? - Answer: MAX() returns the maximum value of a field What does the SUM() function do within a SOQL query? - Answer: SUM() returns the total sum of a numeric field What does the CALENDAR_MONTH() function do within a SOQL query? - Answer: CALENDAR_MONTH() returns a number representing the calendar month of a date field What does the DAY_IN_MONTH() function do within a SOQL query? - Answer: DAN_IN_MONTH() returns a number representing the day in the month of a date field
What does the FISCAL_YEAR() function do within a SOQL query? - Answer: FISCAL_YEAR() returns a number representing the fiscal year of a date field What does the WEEK_IN_YEAR() function do within a SOQL query? - Answer: WEEK_IN_YEAR() returns a number representing the week in the year for a date field What is SOQL binding? - Answer: SOQL binding is the act of referencing a variable or expression within a square-bracketed SOQL query. What is the syntax for binding a variable or expression to a SOQL query in Apex? - Answer: Use a colon. For example... [SELECT Id FROM Account WHERE Type = :myTypeValue] [SELECT Id FROM Account WHERE Type = :('Active' + 'Client')] True or False: SOQL only returns data for fields that are specified in the SELECT clause of the query - Answer: True WITH ONE EXCEPTION: The Id field value is implicitly included for records returned in a SOQL query, even if the Id field is not specified in the SELECT clause.
True or False: SOQL queries including aggregate functions do not support queryMore(). - Answer: True. A LIMIT should be applied to these queries to ensure that an exception is not thrown by exceeding the limit of 2,000 rows for queries containing aggregate functions. SOQL "FOR UPDATE" keyword - Answer: Locks the returned records from being updated by another request. The records can only be updated within the current trigger context, and the locks are released when the transaction ends. SOQL "ALL ROWS" keyword - Answer: Returns both active and deleted records. What is the purpose of SOQL joins? - Answer: SOQL joins allow you to query data from two or more sObjects in a single query based on the relationships between them. Describe a SOQL Right Outer Join - Answer: A SOQL Right Outer Join is when you pull in Parent data via a SOQL query on a Child object. For example: SELECT Id, Account.Name, Account.Industry from Contacts Describe a SOQL Left Outer Join - Answer: A SOQL Left Outer Join is when you pull in related child data via a SOQL query on a Parent object. For example: SELECT Id, Name, (SELECT First Name, Last Name FROM Contacts) FROM Accounts Describe a Semi-Join SOQL Query - Answer: Used to query for Parent records that have at least one Child object. For example:
SELECT Id, Name FROM Position__c where Id IN (SELECT Position__c FROM Job_Application__c) Describe a Right Inner Join SOQL Query - Answer: Used to query for Child records that have a Parent record. For example: SELECT Id, Position__r.Name FROM Job_Application__c WHERE Position__c != NULL Describe a Right Anti-Join SOQL Query - Answer: Used to query for Child objects that do NOT have a Parent record. For example: SELECT Id FROM Job_Application__c WHERE Position__c = null Describe a Left Anti-Join SOQL Query - Answer: Used to retrieve Parent objects that do not have any Child records. For example: SELECT Id, Name FROM Position__c WHERE Id NOT IN (SELECT Position__c from Job_Application__c) Describe a Right Inner Join Without Remote Condition SOQL Query - Answer: Used to query for Child records that have Parent records that meet certain criteria (i.e. certain Parent records only). For example: