Sravani Duggirala

Greenhorn
+ Follow
since May 06, 2009
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Sravani Duggirala

Hei Pushkar,

Thanks a lot for the comments...................I edited my message and now it doesn't seem to be violating the Java Ranch Protocol
Suites in line 14 is a typo from my side..........................and that was corrected...............so now the problem seems to be with the getBidValue() method.

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()

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(Suites.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()