Anonymous Apex allows developers to execute ad hoc code snippets without creating a permanent class or trigger. It is useful for tasks like bulk data manipulation or testing. * B. Deleting 15,000 inactive Accounts: * Anonymous Apex can perform ad hoc bulk operations to clean up data after a deployment. * Example: Use Cases:List<Account> inactiveAccounts = [SELECT Id FROM Account WHERE IsActive__c = false LIMIT 15000]; delete inactiveAccounts; * C. Running a batch Apex class: * Anonymous Apex can execute batch jobs for data processing. * Example: apex Copy code Database.executeBatch(new UpdateContactBatch()); * A. Schedule an Apex class to run periodically: This requires a scheduled job, not Anonymous Apex. * D. Add unit test code coverage: Unit tests must be written in test classes and cannot be added using Anonymous Apex. References:Anonymous Apex:https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_execute_anonymous.htm
最新のコメント (最新のコメントはトップにあります。)
GenerativeAI - 2025-11-18
正解は B と C です。 解説: 匿名 Apex は 1回限りの処理や即時実行したいコードを開発者コンソールなどから直接実行するために使われます。
B. デプロイメント後に1回のトランザクションで15,000の非アクティブなアカウントを削除する → 一度だけのデータ修正やクリーンアップに匿名 Apex が適しています。
C. すべての連絡先を更新するバッチApexクラスを実行する → Database.executeBatch(new MyBatchClass()); のように、匿名 Apexからバッチを起動するのは典型的なユースケースです。
不正解の選択肢:
A. Apex クラスを定期的に実行するようにスケジュールする → スケジュール自体は匿名 Apexから設定できるものの、日常的に「匿名 Apexを使う」という意味では微妙。
D. 組織にユニットテストコードカバレッジを追加する → テストメソッドは Apex クラスで作成する必要があり、匿名 Apexでは直接テストメソッドを作成できません。
最新のコメント (最新のコメントはトップにあります。)
正解は B と C です。
解説:
匿名 Apex は 1回限りの処理や即時実行したいコードを開発者コンソールなどから直接実行するために使われます。
B. デプロイメント後に1回のトランザクションで15,000の非アクティブなアカウントを削除する
→ 一度だけのデータ修正やクリーンアップに匿名 Apex が適しています。
C. すべての連絡先を更新するバッチApexクラスを実行する
→ Database.executeBatch(new MyBatchClass()); のように、匿名 Apexからバッチを起動するのは典型的なユースケースです。
不正解の選択肢:
A. Apex クラスを定期的に実行するようにスケジュールする
→ スケジュール自体は匿名 Apexから設定できるものの、日常的に「匿名 Apexを使う」という意味では微妙。
D. 組織にユニットテストコードカバレッジを追加する
→ テストメソッドは Apex クラスで作成する必要があり、匿名 Apexでは直接テストメソッドを作成できません。
したがって、B と C が正しい回答です。