• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

native??

 
Ranch Hand
Posts: 252
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1) What will happen when you attempt to compile and run this code? [7]
public class Mod{
public static void main(String argv[]){
}
public static native void amethod();
}
(a)Error at compilation: native method cannot be static.
(b)Error at compilation native method must return value.
(c)Compilation but error at run time unless you have made code containing native amethod available.
(d)Compilation and execution without error.


here why c is not correct ...
suppose if the native code is not available then how the program run??
answer given is d ...how can ???


please correct me if iam wrong???

thanks

sri
 
Ranch Hand
Posts: 657
Spring VI Editor Clojure
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

suppose if the native code is not available then how the program run??

Note that the native method is never called in that example. Since the method would be linked dynamically at runtime *if* it were called, there is no error message, and the code runs fine.

Hope this helps.
 
srikanth reddy
Ranch Hand
Posts: 252
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
so u mean to say steve that whether native method is written in some other language or not there wont be any compile or runtime error...??


thanks

sri
 
Steve Morrow
Ranch Hand
Posts: 657
Spring VI Editor Clojure
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

so u mean to say steve that whether native method is written in some other language or not there wont be any compile or runtime error...??


Correct. You can easily verify this by compiling and running a class that declares - but does not call - a native method with no linkable native code.
 
srikanth reddy
Ranch Hand
Posts: 252
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks steve ...
thats what the answer says that there would have been runtime exception if u had called the method explicitly....

thanks

sri......
 
reply
    Bookmark Topic Watch Topic
  • New Topic