This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes interface again Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "interface again" Watch "interface again" New topic
Author

interface again

payal sharma
Ranch Hand

Joined: Oct 04, 2000
Posts: 57
interface One
{
public void someMethod();
}
public class One_impl implements One
{
public static void main(String a[]){
System.out.println("hello");
}
public native void someMethod();
}
the interface above is implemented but still leaving someMethod without code and also not making this class as abstract why?
Manfred Leonhardt
Ranch Hand

Joined: Jan 09, 2001
Posts: 1492
Hi Payal,
The keyword native is the reason why. When you use the native keyword you are telling the compiler that the implementation is external to java. The compiler only requires the class to be made abstract if it doesn't implement (or imply implementation) the interface method(s).
Regards,
Manfred.
tvs sundaram
Ranch Hand

Joined: Jan 28, 2001
Posts: 153
Does it mean that the class One_impl need not be declared abstract? I tend to think yes based on above answer but please confirm.
Desai Sandeep
Ranch Hand

Joined: Apr 02, 2001
Posts: 1157
Hi all:
When you declare the method as native, you give the control to the OS to implement the code for that method.You will not get any compile time errors because the compiler assumes that the method is implemented in the OS dependent way.
The Developer may later on use JNI (Java Native Inteface) to implement this method.
Hope this helps,
Sandeep
SCJP2, OCSD(Oracle JDeveloper) OCED(Oracle Internet Platform)


<b>Sandeep</b> <br /> <br /><b>Sun Certified Programmer for Java 2 Platform</b><br /> <br /><b>Oracle Certified Solution Developer - JDeveloper</b><br /><b>-- Oracle JDeveloper Rel. 3.0 - Develop Database Applications with Java </b><br /><b>-- Object-Oriented Analysis and Design with UML</b><br /> <br /><b>Oracle Certified Enterprise Developer - Oracle Internet Platform</b><br /><b>-- Enterprise Connectivity with J2EE </b><br /><b>-- Enterprise Development on the Oracle Internet Platform </b>
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: interface again
 
Similar Threads
tricky question
How this program compiled successfully?
Interface
native methods
can anyone explain me this?