Java Programming - Language Fundamentals - Discussion

Discussion :: Language Fundamentals - General Questions (Q.No.4)

4. 

Which is a reserved word in the Java programming language?

[A]. method
[B]. native
[C]. subclasses
[D]. reference
[E]. array

Answer: Option B

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'.


Disha said: (Oct 1, 2010)  
Hey, could you please give an example of using "native" keyword?.

Ijaz said: (Feb 27, 2011)  
I want simple program for 'native' keyword?

Shubhrendu said: (Mar 22, 2011)  
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]);
}
}
}

Kathirozhi said: (Sep 19, 2011)  
Program cannot be run write by Shubhrendu.

please tell the output of that program.

Vishal Kumar Singh said: (May 9, 2012)  
When we can modify the method declaration using "native" keyword in java ?

Bharathi said: (Aug 8, 2012)  
Can you please give clear explanation about of native keyword ?

Yogesh Pawar said: (Mar 5, 2013)  
What is use of native method, where we will be use it?

Anuj said: (Apr 6, 2013)  
May you tell me where do we use native keyword?

Mahendra said: (Jul 5, 2013)  
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.

Rahul Yadav said: (Aug 26, 2013)  
All machine code define inside native.

Nandhini said: (Oct 18, 2014)  
Native is like different in java keyword.

Shibasis Nayak said: (Dec 6, 2014)  
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();

Prashant said: (Aug 23, 2015)  
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.

Rajeev said: (Feb 24, 2016)  
In the question it's about reserved word and the reserved words in java are goto and const.

Papuagri Rama Devi said: (Aug 29, 2016)  
Tell me, how to use keyword native in programming?

Vishnu said: (Sep 1, 2016)  
In which way, 'native' is a reserved word in Java?

M.Samuel said: (Sep 10, 2016)  
Excellent explanation, Thank you.

Priya said: (Dec 16, 2016)  
What is the use of native keyword?

Why we use native?

Naresh Reddy said: (Feb 20, 2017)  
'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.

Shubham said: (Feb 26, 2017)  
Thanks @Naresh.

Hitesh said: (Jun 12, 2017)  
Thanks @Naresh.

Mahendra said: (Sep 16, 2017)  
Thank you friends.

Rushikesh said: (Jun 6, 2018)  
native is the return type of method or function.

Manupriya said: (Oct 18, 2018)  
Thanks for the answer @Naresh.

Jaswanth Nelam said: (Jan 12, 2021)  
@Rushikesh.

No, it's not a return type, it is a keyword.

Post your comments here:

Name *:

Email   : (optional)

» Your comments will be displayed only after manual approval.