Sravani Duggirala wrote:The following is the code for one of the questions in the Scjp study guide :
public class Bridge
{
public enum Suits
{
CLUBS(20),DIAMONDS(20),HEARTS(30),SPADES(30),
NOTRUMP(40){ public int getValue(int bid){
return ((bid-1)*30)+40;
} };
Suits(int points) { this.points=points;}
private int points;
public int getValue(int bid) { return points*bid; }
}
public static void main(String[] args)
{
System.out.println(Suits.NOTRUMP.getBidValue(3));
System.out.println(Suits.SPADES+ " "+Suits.SPADES.points);
System.out.println(Suits.values());
}
}
The options provided are :
A.The output could contain 30
B.The output could contain @bf73fa
C.The output could contain DIAMONDS
D.Compilation fails due to an error on line 6
E.Compilation fails due to an error on line 7
F.Compilation fails due to an error on line 8
G.Compilation fails due to an error on line 9
H.Compilation fails due to an error within lines 12 to 14
The answer is provided to be A and B.
But the above code should not Compile as there is no method named getBidValue()