GeekInterview.com
   Home |  Tech FAQ  |   Interview Questions |  Placement Papers |  Tech Articles |  Learn |  Freelance Projects |  Online Testing |  Geeks Talk |  Job Postings |  Knowledge Base | Site Search |  Add/Ask Question

GeekInterview.com  >  Interview Questions  >  J2EE  >  OOPS
Go To First  |  Previous Question  |  Next Question 
 OOPS  |  Question 21 of 30    Print  
How can i call a funtion,given its name as string?

  
Total Answers and Comments: 5 Last Update: March 10, 2008     Asked by: smita 
  
 Sponsored Links

 
 Best Rated Answer

No best answer available. Please pick the good answer available or submit your answer.
November 10, 2006 07:06:02   #1  
sathish        

RE: How can i call a funtion,given its name as string?...
Use reflection API's
 
Is this answer useful? Yes | No
November 11, 2006 06:46:33   #2  
shiva        

RE: How can i call a funtion,given its name as string?...
satish explain it, i dont understand
 
Is this answer useful? Yes | No
December 18, 2006 07:39:58   #3  
nagu        

RE: How can i call a funtion,given its name as string?...

   Class clsObj = Class.forName("ClassName");
   Method method = clsObj.getMethod("methodName",null);
   method.invoke(clsObj.newInstance(),null);


 
Is this answer useful? Yes | No
March 01, 2007 06:21:31   #4  
ashishvyas_83 Member Since: February 2007   Contribution: 1    

RE: How can i call a funtion,given its name as string?...
we can also call the method using Introspection API, Eclipse uses this API to get the name of all the methods available in a class after we enter "." after a Class Instance or Class Name for static methods;
 
Is this answer useful? Yes | No
March 10, 2008 05:03:11   #5  
sampra Member Since: February 2008   Contribution: 279    

RE: How can i call a funtion,given its name as string?
Class clsObj = Class.forName("ClassName");
   Method method = clsObj.getMethod("methodName",null);
   method.invoke(clsObj.newInstance(),null);

 
Is this answer useful? Yes | No


 
Go To Top


 Sponsored Links

 




About Us  |   Privacy Policy  |   Terms and Conditions  |   Contact  |   Site Map  |   Add Question  |   Propose Category  |   RSS Feeds  |   Articles Sitemap  |   Site Updates  |   Add Resource

Copyright © 2005 - 2008 GeekInterview.com. All Rights Reserved
Page copy protected against web site content infringement by Copyscape