This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Question about native methods (Dan C example) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Question about native methods (Dan C example)" Watch "Question about native methods (Dan C example)" New topic
Author

Question about native methods (Dan C example)

Garrett Smith
Ranch Hand

Joined: Jun 27, 2002
Posts: 401
[B]

Compile-time errors are generated at which lines?
a. 1
b. 2
c. 3
d. 4
e. 5
f. None of the above.
[/B]

In looking at this, I went through each implementation to see if it violated the rules for implementing an interface. All subclasses are concrete (non-abstract), so the question is: does each class implement public void m1()?
Classes D, E, and F do. What about class G? It looks like an abstract method. I chose answer e, because it looks like a lack of implementation.
My answer is wrong. The real answer is below (don't look yet).
My question: How do native methods work?

(anwser: i. none of the above)


comp.lang.javascript FAQ: http://jibbering.com/faq/
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
A native method is implemented in a module which the JVM has to load before calling the method. The module is implemented in a language such as C, C++, PL/1 (yes, on IBM 390).
There's something here that explains it all.


Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
Sarma Lolla
Ranch Hand

Joined: Oct 21, 2002
Posts: 203
Unless you call the native method in your code JVM wouldn't even verify if the library in which the native method has implementation is included or not.
So as long as you are not calling the native method every thing is OK. You can declare a method as native.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Question about native methods (Dan C example)