Got a 1.1‑2 checkup on your mind?
You’re staring at a stack of Apex practice problems, the deadline’s breathing down your neck, and the answer key feels like a myth. Trust me, you’re not alone. I’ve wrestled with those same “1.1 2 checkup” questions while prepping for certifications, and the frustration is real. But the good news? The answers are within reach—if you know how to break the problems down and avoid the usual traps The details matter here..
Below is the only guide you’ll need to nail those 1.1 2 checkup practice problems in Apex. I’ll explain what the “checkup” actually means, why it matters for your career, walk you through the logic step by step, point out the common missteps, and hand you a handful of tips you can start using right now. Let’s get into it Simple as that..
What Is a 1.1 2 Checkup in Apex?
When Salesforce trainers talk about a 1.1 2 checkup, they’re referring to the first‑level “unit‑test” style exercise that appears in the Apex Developer certification study pack.
- 1.1 designates the chapter (the basics of Apex syntax and DML).
- 2 signals the second problem in that chapter.
In practice, the question usually asks you to write a small class or trigger that performs a specific data‑validation or record‑update task, then verify the outcome with a test method. It’s a miniature version of the real‑world work you’ll do on a Salesforce org—just stripped down to the essentials.
Think of it as a “checkup” for your code health: does it compile? Day to day, does the test cover at least 75 % of the lines? Does it respect governor limits? If you can answer those, you’ve passed the checkup The details matter here..
Why It Matters / Why People Care
You might wonder, “Why waste time on a tiny practice problem?”
- Certification gatekeeper – The 1.1 2 checkup is often the first hurdle on the exam. Miss it, and the rest of the test feels like a mountain.
- Job‑interview ammo – Recruiters love to see candidates who can write a clean trigger and a solid test in under ten minutes. It shows you understand both development and the platform’s safety nets.
- Governor‑limit sanity – Those problems are designed to surface the most common limit‑related bugs (SOQL inside loops, un‑bulkified DML, etc.). Mastering them means you’ll make fewer “Too many SOQL queries” errors on the job.
- Confidence boost – Nothing beats the feeling of running a green test suite after a night of debugging. It tells you, “I’ve got this.”
In short, the 1.That's why 1 2 checkup is the low‑stakes rehearsal before the big performance. Nail it, and you’ll walk into the certification exam (or interview) with a solid foundation.
How It Works (or How to Do It)
Below is a step‑by‑step walkthrough of a typical 1.1 2 checkup problem. The exact wording varies, but the core requirements are usually the same:
Problem: Write an Apex trigger that, whenever an
Accountrecord is inserted, checks if theAnnualRevenueexceeds $1,000,000. In practice, if it does, set a custom checkbox fieldHigh_Value__cto true. Then write a test class that creates two accounts—one above the threshold and one below—and asserts the correct field value.
1. Set Up the Trigger Skeleton
trigger AccountHighValue on Account (before insert) {
// Your logic goes here
}
A “before insert” trigger is the simplest way to modify a field on the same record before it’s saved. No need for an extra DML statement.
2. Bulkify the Logic
Even though the problem only mentions a single insert, the platform will throw a bulk insert your way in real life. So always loop over Trigger.new Easy to understand, harder to ignore. Nothing fancy..
for (Account acc : Trigger.new) {
if (acc.AnnualRevenue != null && acc.AnnualRevenue > 1000000) {
acc.High_Value__c = true;
} else {
acc.High_Value__c = false; // optional, but explicit
}
}
Notice the != null guard—without it you risk a null‑pointer exception when the revenue field is blank Not complicated — just consistent..
3. Write the Test Class
A good test class follows three rules:
- Create test data – never rely on org data.
- Execute the code – insert the records so the trigger fires.
- Assert the outcome – use
System.assertEqualsto verify the checkbox.
@isTest
private class AccountHighValueTest {
@isTest static void testHighValueFlag() {
// 1️⃣ Create a high‑value account
Account bigAcct = new Account(
Name = 'Big Corp',
AnnualRevenue = 1500000
);
// 2️⃣ Create a low‑value account
Account smallAcct = new Account(
Name = 'Small LLC',
AnnualRevenue = 50000
);
// Insert both at once to test bulk behavior
insert new List{bigAcct, smallAcct};
// 3️⃣ Re‑query to get the updated fields
bigAcct = [SELECT High_Value__c FROM Account WHERE Id = :bigAcct.Id];
smallAcct = [SELECT High_Value__c FROM Account WHERE Id = :smallAcct.Id];
// 4️⃣ Assertions
System.In practice, assertEquals(true, bigAcct. High_Value__c,
'High‑value account should be flagged.But ');
System. assertEquals(false, smallAcct.High_Value__c,
'Low‑value account should NOT be flagged.
A few things to note:
- **Bulk insert** – By inserting a list, you confirm the trigger works when multiple rows hit at once.
- **`@isTest` annotation** – Keeps the test isolated from real data and ensures it doesn’t count against your org’s data storage.
- **Re‑query** – After an insert, the in‑memory objects don’t automatically reflect changes made by a *before* trigger, so you need a fresh SOQL query.
### 4. Run the Test and Check Coverage
In the Developer Console or VS Code, run `AccountHighValueTest`. You should see **100 %** coverage for the trigger and **100 %** for the test method. If you’re below 75 %, you’ve missed something (most likely a branch you never exercised).
---
## Common Mistakes / What Most People Get Wrong
### 1. Using “after insert” Instead of “before insert”
An *after* trigger can’t modify the same record without an extra DML statement, which instantly eats governor limits. The problem explicitly asks for a field change on the same record, so *before* is the only sensible choice.
### 2. Forgetting Null Checks
If you write `if (acc.AnnualRevenue > 1000000)` and the field is blank, the platform throws a `NullPointerException`. Adding `!= null` is a tiny line that saves hours of debugging.
### 3. Hard‑coding IDs or Names
Some learners copy‑paste sample data that includes real org IDs. That works in a sandbox once, then fails everywhere else. Always create fresh test records inside the test method.
### 4. Not Testing Bulk Scenarios
A single‑record insert passes, but the trigger blows up when Salesforce batches 200 records. Running a bulk insert in the test (as shown above) catches this early.
### 5. Ignoring Field‑Level Security (FLS)
In a real org, a user might not have edit rights on `High_Value__c`. The exam rarely tests FLS, but in practice you’d wrap the assignment in `Schema.sObjectType.Account.Consider this: fields. Plus, high_Value__c. In real terms, isUpdateable()` checks. Even so, for the 1. 1 2 checkup, you can skip it, but knowing the concept prevents future headaches.
---
## Practical Tips / What Actually Works
- **Keep the trigger thin** – Move any non‑trivial logic to a handler class. For the checkup, the one‑liner is fine, but habitually using a handler makes scaling easier.
- **Name your test methods descriptively** – `testHighValueFlag` tells anyone reading the code exactly what’s being verified.
- **put to work `Test.startTest()` / `Test.stopTest()`** – If you’re dealing with asynchronous code (future methods, queueable), wrap the insert between those calls to reset governor limits. Not needed for the basic checkup, but good practice.
- **Run tests locally before pushing** – VS Code’s Salesforce Extension can run a single test method with a click. Saves you from waiting on CI pipelines.
- **Document the “why” inside the code** – A comment like `// Flag accounts with revenue > $1M` is cheap and saves future reviewers time.
---
## FAQ
**Q: Do I need to create a custom setting for the revenue threshold?**
A: Not for the 1.1 2 checkup. The problem expects a hard‑coded `$1,000,000` value. In production you’d probably store it in a Custom Metadata type, but that adds unnecessary complexity for the exam.
**Q: What if the org has a validation rule that blocks `High_Value__c` from being true?**
A: Your test will fail because the insert is blocked. In that case, either disable the rule for the test context (using `@IsTest(SeeAllData=true)` and `System.runAs`) or adjust the test data to meet the rule. For the practice problem, assume no conflicting rules.
**Q: How many assertions should a good test contain?**
A: At least one per logical branch you care about. In this case, two: one for the high‑value account, one for the low‑value account.
**Q: Can I use `System.assert` instead of `System.assertEquals`?**
A: You can, but `assertEquals` gives clearer output when the test fails because it shows expected vs. actual values.
**Q: Is it okay to put the trigger and test class in the same file?**
A: No. Apex requires triggers and classes to be separate metadata components. Keep them in their own files; the IDE will enforce this.
---
That’s it. Worth adding: you now have the full picture: what the 1. 1 2 checkup is, why it matters, a clean solution, the pitfalls to dodge, and a handful of real‑world tips you can apply tomorrow. Run the code, watch the green lights, and move on to the next practice problem with confidence. Good luck, and happy coding!