Java OCA OCP Practice Question 3187

Question

Given the following class, which statements can be inserted at (1) without causing a compilation error?.

public class Main {
  int a;//www  .  j  ava2 s  .c o m
  int b = 0;
  static int c;

  public void m() {
    int d;
    int e = 0;

    // (1) INSERT CODE HERE.
  }
}

Select the four correct answers.

  • (a) a++;
  • (b) b++;
  • (c) c++;
  • (d) d++;
  • (e) e++;


(a), (b), (c), and (e)

Note

Only local variables need to be explicitly initialized before use.

Fields are assigned a default value if not explicitly initialized.




PreviousNext

Related