Java Programming - Language Fundamentals - Discussion

Discussion Forum : Language Fundamentals - General Questions (Q.No. 4)
4.
Which is a reserved word in the Java programming language?
method
native
subclasses
reference
array
Answer: Option
Explanation:

The word "native" is a valid keyword, used to modify a method declaration.

Option A, D and E are not keywords. Option C is wrong because the keyword for subclassing in Java is extends, not 'subclasses'.

Discussion:
25 comments Page 1 of 3.

Naresh Reddy said:   8 years ago
'native' is a reserved keyword in Java. It is used to modify the methods and implementation of code can be done in other languages (c, c++).

Where to use this 'native' keyword?

When You need to call a library from Java that is written in other languages. Because while developing any application (or) something.

In such cases Java may not support your needs, then we can write code in other language and add it to the Java library.

Now we can access that library by using 'native' keyword. (ie. JNI) Java native interface.

I hope that this will make you understand a till bit better.
(14)

Shubhrendu said:   1 decade ago
Its the example of native method............


import java.util.*;

class ReadFile {
//Native method declaration
native byte[] loadFile(String name);
//Load the library
static {
System.loadLibrary("nativelib");
}

public static void main(String args[]) {
byte buf[];
//Create class instance
ReadFile mappedFile=new ReadFile();
//Call native method to load ReadFile.java
buf=mappedFile.loadFile("ReadFile.java");
//Print contents of ReadFile.java
for(int i=0;i<buf.length;i++) {
System.out.print((char)buf[i]);
}
}
}

Prashant said:   10 years ago
Can any one please briefly explain the concept of native keyword? So that we can understand the exact use of native in Java programming please and thanks in advance.

Shibasis nayak said:   1 decade ago
Native is a keyword that is used in java which identify that a method whose body can be implemented by outside of java class.

Syntax: Native return type method();

Mahendra said:   1 decade ago
The word "native" is a valid keyword, used to modify a method declaration.

Explanation is like this then where did you modify method declaration in that program.

Rajeev said:   9 years ago
In the question it's about reserved word and the reserved words in java are goto and const.

Kathirozhi said:   1 decade ago
Program cannot be run write by Shubhrendu.

please tell the output of that program.

Vishal kumar singh said:   1 decade ago
When we can modify the method declaration using "native" keyword in java ?

Disha said:   1 decade ago
Hey, could you please give an example of using "native" keyword?.

Bharathi said:   1 decade ago
Can you please give clear explanation about of native keyword ?


Post your comments here:

Your comments will be displayed after verification.