Forums Register Login

Question about native methods (Dan C example)

+Pie Number of slices to send: Send
 

[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)
+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
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.
A timing clock, fuse wire, high explosives and a tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 678 times.
Similar Threads
Dan's Exam
question about Dan's mock exam (interfaces)
interfaces-method overriding
interface implementation
interface methods
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 03:19:02.