Multiple choice technology programming languages

Which of the following are appropriate ways to use assertions? (Choose all that apply) You have not made any correct choices. The correct options are as follows

  1. 1 public void myMethod(int x) {

  2. 2 private void myMethod(int x) {

  3. 3 switch(z) {

  4. 4 private void anotherMethod() {

Reveal answer Fill a bubble to check yourself
B,C Correct answer
Explanation

Assertions should be used in private methods (internal invariants that the caller cannot violate) and in switch default cases (to catch unreachable states). Public methods validate arguments via explicit checks, not assertions, since assertions can be disabled. Option A shows a public method without argument validation - inappropriate.