File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes which part is wrong in this following fragment Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Java in General
Bookmark "which part is wrong in this following fragment" Watch "which part is wrong in this following fragment" New topic
Author

which part is wrong in this following fragment

uday krishna
Greenhorn

Joined: Feb 10, 2000
Posts: 5
import java.lang.reflect.Constructor;
Constructor con;
con=new Constructor(Class.forName("Object"));
Thandapani Saravanan
Ranch Hand

Joined: Oct 17, 1999
Posts: 117
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

Joined: Jan 30, 2000
Posts: 3222
    
    5
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 Alicea
Senior Java Web Application Developer, SCPJ2, SCWCD
Jim Yingst
Wanderer
Sheriff

Joined: Jan 30, 2000
Posts: 18671
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.


"I'm not back." - Bill Harding, Twister
 
GeeCON Prague 2014
 
subject: which part is wrong in this following fragment