Review Questions

graphics/rq_icon.gif

2.7

Which of the following lines are valid declarations?

Select the three correct answers.

  1. char a = '\u0061';

  2. char 'a' = 'a';

  3. char \u0061 = 'a';

  4. ch\u0061r a = 'a';

  5. ch'a'r a = 'a';

2.8

Given the following code within a method, which statement is true?

int a, b;
b = 5;

Select the one correct answer.

  1. Local variable a is not declared.

  2. Local variable b is not declared.

  3. Local variable a is declared but not initialized.

  4. Local variable b is declared but not initialized.

  5. Local variable b is initialized but not declared.

2.9

In which of these variable declarations will the variable remain uninitialized unless explicitly initialized?

Select the one correct answer.

  1. Declaration of an instance variable of type int.

  2. Declaration of a static variable of type float.

  3. Declaration of a local variable of type float.

  4. Declaration of a static variable of type Object.

  5. Declaration of an instance variable of type int[].