This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Question from Marcus Green mock exam..

 
prakash sodhani
Greenhorn
Posts: 11
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have a question about the one of the question from Marcus Green mock test 2.

What will happen when you attempt to compile and run this code?

public class Mod
{
public static void main(String argv[]){}
public static native void amethod();
}

1) Error at compilation: native method cannot be static
2) Error at compilation native method must return value
3) Compilation but error at run time unless you have made code containing native amethod available
4) Compilation and execution without error


As far as I know..none of these answers are correct as looking at method "amethod" in the above code, it should be declared abstract (ends with () and hence class shuld be declared abstract.

The answer given is 4.

Please let me know your views.

Thanks
-Prakash
 
Satyam Kothapally
Greenhorn
Posts: 7
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Prakash-

Native methods are also declared that way in classes , so it need not be an abstract method.

Moreover I compiled the code and ran it. It worked fine. So answer 4 is correct.

Hope this helps.

Satyam
 
Fisher Daniel
Ranch Hand
Posts: 582
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Prakash,
I think option 4 is the right answer.

Correct me if i am wrong
thanks
daniel
 
Anju
Greenhorn
Posts: 10
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Native methods are also declared that way in classes , so it need not be an abstract method. One more thing is ur not calling that method so it does not search for its implementation...if u call the native method it will throw any error
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic