|
|
350 Mock Questions on SCJP 1.5 - JUST Rs.200 or 7 USD
Send us mail to sales@javabeat.net
more details
|
|
SCJP 5.0 - Enum Mock Questions - 2
1) what is the result of compiling and running the following code?
enum AccountType {
SAVING, FIXED, CURRENT;
private AccountType() {
System.out.println("It is a account type");
}
}
class EnumOne {
public static void main(String[] args) {
System.out.println(AccountType.FIXED);
}
}
Options :
a) Compiles fine and output is prints "It is a account type" once followed by "FIXED"
b) Compiles fine and output is prints "It is a account type" twice followed by "FIXED"
c) Compiles fine and output is prints "It is a account type" thrice followed by "FIXED"
d) Compiles fine and output is prints "It is a account type" four times followed by "FIXED"
e) Compilation fails
Answer:
1)C
For every value in enum, constuctor is fired.In this case AccountType enum has 3 values so constructor will be fired thrice.
|
|
350 Mock Questions on SCJP 1.5 - JUST Rs.200 or 7 USD
Send us mail to sales@javabeat.net
more details
|
|