Second line of the fragment should be the one which is illegal. Are we not supposed to have class declaration here?

Saravanan

Tony Alicea

Desperado
Sheriff

Posts: 3226

5

posted 17 years ago

I'm moving this thread to the Intermediate section where it will get the attention it deserves. This topic is not covered in the SCPJ2 exam... Thanks.

Tony AliceaSenior Java Web Application Developer, SCPJ2, SCWCD

Jim Yingst

Wanderer
Sheriff

Posts: 18671

posted 17 years ago

Since the code is identified as a "fragment", it's impossible to say just what's wrong with it - it depends on how it's used. If the fragment is used inside a class declaration, then the first line is illegal - imports cannot be inside classes. The third line is also illegal unless it's inside a method or static initializer. If it's outside a class, then the second and third lines are illegal.