Given the following program:.
public enum Main { GOOD('C') { public char getGrade() { return v; } }, BETTER('B') { public char getGrade() { return v; } }, BEST('A') { public char getGrade() { return v; } }; private char v; Main(char v) {// ww w . ja v a 2 s . co m this.v = v; } // (1) INSERT CODE HERE public static void main (String[] args) { System.out.println(GOOD.getGrade()); } }
Which code, when inserted at (1), will make the program print C?.
Select the two correct answers.
getGrade()
{ return v; }getGrade()
{ return v; }getGrade()
;getGrade()
;(a) and (d)
Declarations in (a) and (d) are overridden in each constant-specific class body.
Declarations in (b) and (c) are not overridden by the declarations in the constant-specific class bodies, because of the incompatible return type.