Introduction to Java Native Interface (JNI) Basics
A beginner's quiz to understand the fundamentals of Java Native Interface (JNI).
Questions in this quiz
15 questions on Introduction to Java Native Interface (JNI) Basics. Work through them here, then start the quiz to answer them and see your score.
1.What is the primary purpose of Java Native Interface (JNI)?
- ATo compile Java code into native machine code
- BTo enable Java code to call native applications and libraries
- CTo convert Java bytecode into JavaScript
- DTo provide a graphical user interface for Java applications
2.Which of the following is a valid use case for JNI?
- AAccessing hardware-specific features
- BCreating web applications
- CBuilding RESTful APIs
- DDeveloping mobile applications
3.In JNI, what does the 'native' keyword indicate in a Java method declaration?
- AThe method is implemented in a language other than Java
- BThe method is deprecated
- CThe method is abstract
- DThe method is synchronized
4.Which file extension is commonly associated with JNI header files?
- A.jni
- B.class
- C.java
- D.h
5.What is the role of the 'javah' tool in JNI?
- ATo run Java applications
- BTo compile Java code into bytecode
- CTo generate C header files from Java classes
- DTo convert Java code into JavaScript
6.Which of the following is a common challenge when using JNI?
- AMemory management issues
- BLack of support for object-oriented programming
- CLimited support for multithreading
- DInability to use third-party libraries
7.What is a JNI Environment Pointer (JNIEnv)?
- AA pointer to a native library
- BA pointer to a Java object
- CA pointer that provides access to JNI functions
- DA pointer to a Java class
8.Which of the following is a valid JNI function call?
- AFindClass(env, "MyClass")
- B(*env)->FindClass(env, "MyClass")
- Cenv->FindClass("MyClass")
- Denv.FindClass("MyClass")
9.What is the purpose of the 'System.loadLibrary' method in JNI?
- ATo compile Java code into native code
- BTo convert native code into Java bytecode
- CTo load a native library into the Java application
- DTo unload a native library from the Java application
10.Which of the following is NOT a benefit of using JNI?
- AAccess to native system resources
- BPerformance optimization
- CReuse of existing native libraries
- DPlatform independence
11.What is the typical file extension for a compiled native library used with JNI on Windows?
- A.dylib
- B.lib
- C.so
- D.dll
12.Which JNI function is used to call a static method in a Java class?
- ACallObjectMethod
- BCallStaticVoidMethod
- CCallNonVirtualVoidMethod
- DCallVoidMethod
13.What is the purpose of the 'JNI_OnLoad' function?
- ATo perform initialization when a native library is loaded
- BTo unload a native library
- CTo convert native code into Java bytecode
- DTo compile Java code into native code
14.Which JNI function is used to create a new Java object from native code?
- ANewGlobalRef
- BNewWeakGlobalRef
- CNewObject
- DNewLocalRef
15.Which of the following is a potential risk when using JNI?
- ASimplified code structure
- BSecurity vulnerabilities
- CIncreased portability
- DImproved performance