• 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 method

 
Ranch Hand
Posts: 170
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I was reviewing my answers to Dan;s test in the topic 'method declaration'..
The statement
"If a superclass method is native, then the overriding method must also be native." was marked false.
Could any one help me in understanding this ?
 
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


"If a superclass method is native, then the overriding method must also be native." was marked false.



Override means, when a method has the same name and type signature as a method in its super class. So if return type, method name & parameters are same means it is overridden. Other than that access modifiers, throwing an exception... could be different. Only the thing is, Overriding methods can not be more restrictive than the original method.
So, as per my understanding it should be false only.
 
Lakshmi Saradha
Ranch Hand
Posts: 170
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am sorry, still I dont understand.
I understand that 'native' methods are written in a platform dependent, another programming lang..This is the only fact I know about native language.
Please help me.
 
Arulkumar Gopalan
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please check the example below. It does not throw any compile error.
class Super
{
public void t()
{
System.out.println("super");
}
public native void test();
}
class Sub extends Super
{
public native void t();
public void test()
{
System.out.println("sub");
}
}
Looks like already there are some discussion on this. You can refer
https://coderanch.com/t/386577/java/java/Method-Overriding
http://www.javaranch.com/maha/Discussions/Overloading_and_Overriding/Overriding_-_JavaRanch_Big_Moose_Saloon.htm
Pls do let me know if you come across anything else related to this topic.
 
Lakshmi Saradha
Ranch Hand
Posts: 170
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank u... I understand it now.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic