Win a copy of The Journey To Enterprise Agility this week in the Agile and Other Processes forum! And see the welcome thread for 20% off.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

about native  RSS feed

 
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Question 150)
interface One
{
public void someMethod();
}
public class One_impl implements One
{
public native void someMethod();
}

Assuming that the native method is not provided in any local library, an attempt to compile and run the above lines of code will cause

Compilation error - implimentations can never be native.
Compilation error - method not found in local libraries.
Runtime Exception - method not found in local libraries.
Compilation successfull but runtime error is thrown if and only if the method someMethod of class One_impl is called.
the ans is 4th. why? i donot know much about native method.is it important in the real exam? if it is ,where can i get the tutorial stuff online?
 
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As far as the exam is concerned, I think that you should know the correct way to declare a native method. By providing the native modifier you are saying that its implementation is provided outside the JVM. So the method is declared similarly to an abstract method or interface method (no implementation body).
 
Ranch Hand
Posts: 3141
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just to add to Jim's comment. The compiler doesn't look for the implementation of a native method so no error will be raised if the method is declared correctly.
The runtime will not look for a native method until it is explicitly invoked; at which point it will ask the operating system to supply the implementation. If the method is not on the system; a runtime error will result.
Hope that helps.
------------------
Jane Griscti
Sun Certified Programmer for the Java� 2 Platform
Co-author Mike Meyers' Java 2 Certification Passport
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!