Sample questions
Question 1Easy
Which languages are typically used for the native side of a module on iOS?
- Kotlin or Java
- Python or Ruby
- TypeScript only
- Swift or Objective-C
Answer: D. Swift or Objective-C
Explanation
iOS native code is written in Swift or Objective-C, with C++ also used for shared cross-platform code.
Step-by-step solution
- IOS native modules are written in Swift or Objective-C.
- C++ is also used for code shared across platforms.
- Option D is the correct answer.
Why the other options are wrong
- A. Kotlin and Java are Android languages.
- B. Python and Ruby are not used for the native side of React Native iOS modules.
- C. TypeScript is JavaScript-side code, not native code.
Tip: IOS uses Swift or Objective-C; Android uses Kotlin or Java.
Question 2Easy
In the legacy architecture, how is a native module named Battery accessed from JS?
- NativeModules.Battery
- require('native:Battery')
- Platform.modules.Battery
- global.Battery
Answer: A. NativeModules.Battery
Explanation
Legacy modules are registered with the bridge and exposed on the NativeModules object by their exported name.
Step-by-step solution
- In the legacy architecture, native modules are exposed on the NativeModules object.
- A module is looked up by its exported name, here Battery.
- So NativeModules.Battery is the correct answer, which is option A.
Why the other options are wrong
- B. require('native:Battery') is not a legacy React Native access pattern.
- C. Platform.modules is not an API in React Native.
- D. Legacy modules are not exposed as global variables.
Tip: Legacy modules are read from NativeModules by name; the new architecture uses TurboModuleRegistry.
Question 3Easy
When is writing a native module the right choice?
- To style a component with flexbox properties
- To store a value in component state
- To use a platform API or SDK with no JS library
- To navigate between two JS screens
Answer: C. To use a platform API or SDK with no JS library
Explanation
If an API (such as a vendor payment SDK) is not reachable from JS or an existing library, a native module bridges it.
Step-by-step solution
- A native module is needed when the feature lives only in native code.
- A platform API or SDK with no JavaScript library must be bridged by native code.
- Option C matches this, so it is the correct answer.
Why the other options are wrong
- A. Styling with flexbox is done in JavaScript and needs no native code.
- B. Component state is handled in JavaScript and needs no native code.
- D. Navigation between JS screens is handled by a JavaScript navigation library.
Tip: Write a native module only when no JavaScript library covers the platform feature.
Question 4Easy
Which languages are typically used for the native side of a module on Android?
- Swift or Objective-C
- Dart or Go
- C# or F#
- Kotlin or Java
Answer: D. Kotlin or Java
Explanation
Android native code is written in Kotlin or Java (or C++ for shared code).
Swift and Objective-C are for iOS.
Step-by-step solution
- Android native code is written in Kotlin or Java, with C++ for shared code.
- Swift and Objective-C are for iOS, not Android.
- Option D, Kotlin or Java, is the correct answer.
Why the other options are wrong
- A. Swift and Objective-C are iOS languages.
- B. Dart and Go are not used for the native side of React Native modules.
- C. C# and F# are not used for the native side of React Native modules.
Tip: Android uses Kotlin or Java; iOS uses Swift or Objective-C.
Question 5Medium
A native method rejects its promise with code 'E_NO_GPS'. What happens to const loc = await Location.get() in JS?
- loc is set to the string 'E_NO_GPS'
- loc is set to undefined with no error
- The await throws an error with that code
- The app crashes in native code
Answer: C. The await throws an error with that code
Explanation
Rejecting the native promise rejects the JS Promise, so await throws and the error's code property holds 'E_NO_GPS'.
Step-by-step solution
- When a native promise is rejected, the JS promise is rejected too.
- Await on a rejected promise throws an error.
- The error carries the code 'E_NO_GPS', so option C is the correct answer.
Why the other options are wrong
- A. The error code is not returned as the value of loc.
- B. Loc is not set to undefined; the promise is rejected and an error is thrown.
- D. A rejected promise is a JavaScript error, not a native crash.
Tip: Wrap native calls in try and catch, then read error.code.
Question 6Medium
What is the difference between a native module and a native UI component?
- A module renders views; a component exposes functions
- A module offers functions; a component renders a view
- They are identical; the names are interchangeable
- Modules work only on iOS; components only on Android
Answer: B. A module offers functions; a component renders a view
Explanation
A module like a file picker offers methods. A UI component like a map view is rendered in the JSX tree.
Step-by-step solution
- A native module offers functions that JS calls, such as a file picker's open method.
- A native UI component renders a view in the JSX tree, such as a map.
- Option B states this, so it is the correct answer.
Why the other options are wrong
- A. This is reversed: modules offer functions and components render views.
- C. The two are different kinds of native code, not interchangeable names.
- D. Neither kind is limited to one platform by what it is.
Tip: Ask whether it is a function call (module) or something drawn on screen (component).
Question 7Medium
A library with native code was just installed. Why doesn't reloading the JS bundle make it work?
- The JS bundle must be reinstalled from npm again
- The device must be restarted to load new modules
- Native code is compiled in, so rebuild the app
- Native libraries only work in release builds
Answer: C. Native code is compiled in, so rebuild the app
Explanation
A JS reload only refreshes JavaScript. New native code must be compiled and linked, which means rebuilding the app (and running pod install on iOS).
Step-by-step solution
- A JS reload only refreshes the JavaScript code.
- New native code must be compiled and linked into the app.
- So rebuild the app, and run pod install on iOS; option C is the correct answer.
Why the other options are wrong
- A. Reinstalling the JS bundle from npm does not compile native code.
- B. Restarting the device does not compile new native code.
- D. Native libraries are not limited to release builds.
Tip: A JS-only change needs a reload; a new native dependency needs a rebuild.
Question 8Medium
What does autolinking do for libraries that contain native code?
- Updates every installed library to its newest release
- Converts native code into JS so no rebuild is needed
- Links their native parts into the build automatically
- Links two apps so they can share the same modules
Answer: C. Links their native parts into the build automatically
Explanation
The CLI scans dependencies and wires their native code into the Android and iOS projects, so manual linking steps are not needed.
Step-by-step solution
- Autolinking scans the installed dependencies.
- It wires their native code into the Android and iOS projects automatically.
- So option C is the correct answer, and no manual linking is needed.
Why the other options are wrong
- A. Autolinking does not update packages; it links the ones already installed.
- B. Native code is not converted to JS; it stays native and is linked into the build.
- D. It links a library into one app's build, not two apps to each other.
Tip: After installing a native library, rebuild the app; manual linking is no longer needed.
Question 9Hard
In a legacy Android native module, which annotation exposes a Java or Kotlin method to JavaScript?
- @JsExport
- @NativeMethod
- @ReactProp
- @ReactMethod
Answer: D. @ReactMethod
Explanation
Methods marked @ReactMethod in a ReactContextBaseJavaModule subclass are callable from JS. @ReactProp is for view props on native UI components.
Step-by-step solution
- Legacy Android modules mark callable methods with @ReactMethod.
Why the other options are wrong
- A. There is no @JsExport.
- B. There is no @NativeMethod.
- C. @ReactProp is for view props.
Tip: @ReactMethod.
Question 10Hard
In a TurboModule's TypeScript spec file, what must the Spec interface extend?
- NativeModule
- TurboModule
- React.Component
- HostObject
Answer: B. TurboModule
Explanation
export interface Spec extends TurboModule { ... } marks it as a module spec, which Codegen then reads to generate native code.
Step-by-step solution
- A TurboModule spec is a TypeScript file read by Codegen.
- The Spec interface must extend TurboModule from react-native.
- Codegen then generates native interface code.
Why the other options are wrong
- A. NativeModule is not the spec base type.
- C. Specs are not components.
- D. HostObject is a C++ JSI concept, not the spec base.
Tip: Spec extends TurboModule.
Practise all 14 questions free
The full question bank with timed practice, progress tracking and Vidya, your AI tutor. Free, no ads.
Open this topic in the app →