• Post Reply Bookmark Topic Watch Topic
  • New Topic

A Interesting question about reflection  RSS feed

 
Steven Lau
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sample code :
import java.lang.reflect.Constructor
Constructor con
con = new Constructor(Class.forname(Object));
What's wrong with the above code:
1)Constructor is abstract and can not be instantiated
2)Constructor has a private constructor, inaccessible to the code above
3)Constructor object can only be created in classes in the default package
4)Objects can not be created for the Object objects
5)Constructor is static and need not be instantiated
I think this question is too tricky, I do appreciate for your help.
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't think this is too tricky; you can check some of the possibilities just by looking at the Javadoc for this class.
  • Is Constructor abstract?
  • Does it have any public constructors?


  • (Hint: the last three answers don't make any sense, so it's one of these.)
     
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!