Maintain Your Platform Developer I Certification for Winter ’24

1. A

2. C

3. A

4. C

5. B

Get Hands-on with Bind Variables in a SOQL Query

Create an Apex class
Name: QueryContact
Replace the contents of the QueryContact class with the following code:

public class QueryContact {
public static Id getContactID(String lastName, String title) {
try {
Contact myContact = Database.query('SELECT ID FROM Contact WHERE lastName = :lastName AND title = :title LIMIT 1');
return myContact.Id;
} catch (Exception ex) {
return null;
}
}
public static Id getContactIDWithBinds(Map<String, Object> bindVars) {
string query='SELECT ID FROM Contact WHERE lastName = :lastName AND title = :title LIMIT 1';

List<Contact> Contacts = Database.queryWithBinds(query,bindVars,Accesslevel.user_mode);
if(contacts!=null && !contacts.isempty())
{
return contacts[0].id;
}
else{
return null;
}

}
}