File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Question from Marcus Green mock exam.. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Question from Marcus Green mock exam.." Watch "Question from Marcus Green mock exam.." New topic
Author

Question from Marcus Green mock exam..

prakash sodhani
Greenhorn

Joined: Nov 04, 2004
Posts: 11
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

Joined: Nov 06, 2004
Posts: 7
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


Satyam Kothapally<br />SCJP,SCMAD
Fisher Daniel
Ranch Hand

Joined: Sep 14, 2001
Posts: 582
Hi Prakash,
I think option 4 is the right answer.

Correct me if i am wrong
thanks
daniel
Anju
Greenhorn

Joined: Nov 08, 2004
Posts: 10
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
 
wood burning stoves
 
subject: Question from Marcus Green mock exam..