programming
beginner
10 sample questions
Native Vs Hybrid Apps MCQ Practice Test
Comparing performance and development time for different app types.
Q1. When implementing a native module in a hybrid app, which of the following is a benefit of using a bridge to communicate between JavaScript and native code?
-
A. Improved performance by reducing the overhead of context switching
-
B. Simplified debugging by providing a single, unified logging system
-
C. Enhanced security by isolating sensitive data in a secure container
-
D. Increased flexibility by allowing for the use of native APIs in JavaScript code ✓
Explanation: The primary benefit of using a bridge is enabling native API access from JavaScript. Bridges actually add overhead rather than reduce it.
Q2. When using a hybrid app framework like React Native, what is the primary reason for using a library like React Native's <code>NativeModules</code>?
-
A. To enable direct communication between the JavaScript thread and the native thread
-
B. To provide a cross-platform API for accessing native device features ✓
-
C. To enable the use of native UI components within a hybrid app
-
D. To improve the performance of the hybrid app by offloading computations to native code
Explanation: In hybrid app frameworks like React Native, <code>NativeModules</code> is used to provide a cross-platform API for accessing native device features, such as camera, GPS, and contacts. This allows developers to access device-specific features from within the JavaScript thread, without having to write native code for each platform.
Q3. When using a hybrid app framework like React Native, which of the following is a limitation of using native modules?
-
A. They can only be written in JavaScript
-
B. They can only be used for simple tasks
-
C. They can lead to performance degradation due to the additional layer of abstraction ✓
-
D. They can only be used for iOS development
Explanation: When using native modules in a hybrid app framework, there is an additional layer of abstraction between the JavaScript code and the native code. This can lead to performance degradation due to the overhead of this abstraction layer.
Q4. In a hybrid app built using React Native, which of the following statements is true about the Native Module?
-
A. It is a JavaScript file that directly interacts with native platforms
-
B. It is a native code file that is executed on the native platform ✓
-
C. It is a bridge between JavaScript and native code, but only for Android
-
D. It is a framework that allows for the creation of native UI components
Explanation: A React Native Module is native code (Java/Kotlin or Objective-C/Swift) that runs on the platform and is exposed to JavaScript through the bridge - on BOTH Android and iOS, which is why the keyed "only for Android" option contradicted its own explanation. JavaScript files cannot directly touch native APIs, and creating native UI components is the separate Native Components concept.
Q5. When using a hybrid app framework like React Native, which of the following is a benefit of using a library like React Native Maps for displaying maps?
-
A. It allows for seamless integration with native map views.
-
B. It provides a more efficient use of system resources.
-
C. It enables the use of JavaScript and React components to render map views. ✓
-
D. It simplifies the process of implementing custom map gestures.
Explanation: When using a hybrid app framework like React Native, using a library like React Native Maps can provide a number of benefits. One of the key advantages is that it enables the use of JavaScript and React components to render map views, which can make it easier to integrate maps into a React Native app and can also provide a more consistent and predictable user experience.
Q6. Which of the following is a key advantage of using a hybrid app framework like React Native for building a mobile app that requires access to the device's Bluetooth Low Energy (BLE) capabilities?
-
A. Native code can be used to implement BLE functionality
-
B. Hybrid frameworks provide a more efficient way to access native APIs ✓
-
C. Hybrid apps are limited to web-based APIs and cannot access native device features
-
D. Hybrid frameworks require a separate native module for BLE implementation
Explanation: Hybrid frameworks like React Native provide a more efficient way to access native APIs, including BLE capabilities, through the use of native modules. This allows developers to build cross-platform apps that can access device features without the need for platform-specific code.
Q7. When using a hybrid app framework, which of the following is a common approach to optimize the performance of a native module written in Java/Kotlin for Android?
-
A. Use a JavaScript shim to translate the module's API to Java/Kotlin
-
B. Use the framework's built-in bridge to directly call the native module's methods ✓
-
C. Use a native wrapper to expose the module's functionality to the JavaScript runtime
-
D. Use a third-party library to automatically generate a native wrapper for the module
Explanation: Hybrid app frameworks like React Native or Flutter often provide a built-in bridge that allows developers to directly call native modules written in Java/Kotlin for Android. This approach optimizes performance by reducing the overhead of JavaScript shims or native wrappers.
Q8. When building a mobile app using React Native, which of the following is a limitation of using the Native Module API to interact with native platform components?
-
A. It provides a higher level of abstraction, allowing for more platform-agnostic code
-
B. It allows for direct access to native platform APIs, but may introduce memory leaks if not implemented correctly ✓
-
C. It enables the use of native UI components, but may require additional setup for iOS
-
D. It provides a seamless user experience across multiple platforms, without the need for platform-specific code
Explanation: When using the Native Module API in React Native, developers have direct access to native platform APIs, which can be beneficial for performance-critical code. However, if not implemented correctly, this can lead to memory leaks, which can cause the app to crash or become unresponsive.
Q9. In a hybrid app built with React Native, which of the following statements about the JavaScript engine is correct?
-
A. The JavaScript engine is executed on the native thread, which can lead to performance issues.
-
B. The JavaScript engine is executed on a separate thread from the native thread, improving performance. ✓
-
C. The JavaScript engine is executed on the native thread, but with the help of a just-in-time (JIT) compiler.
-
D. The JavaScript engine is not used in hybrid apps, only native code is executed.
Explanation: In hybrid apps built with React Native, the JavaScript engine is executed on a separate thread from the native thread, which improves performance and allows for more efficient execution of JavaScript code.
Q10. When developing a mobile app, which of the following is a key advantage of using a native app framework over a hybrid app framework when it comes to handling device hardware features such as GPS and camera?
-
A. Native app frameworks provide a higher level of abstraction from device hardware, making it easier to develop apps that work across multiple devices.
-
B. Native app frameworks require less memory and processing power compared to hybrid app frameworks, resulting in faster app performance.
-
C. Native app frameworks provide direct access to device hardware features, allowing for more efficient and accurate use of features such as GPS and camera. ✓
-
D. Native app frameworks are more secure than hybrid app frameworks, as they are less vulnerable to code injection attacks.
Explanation: Native app frameworks have direct access to device hardware features, which allows for more efficient and accurate use of features such as GPS and camera. This is because native app frameworks are written in the device's native language, which provides a more direct interface to the device's hardware.
That was just a sample. Sign up to unlock the full question bank with timed tests and certificates.
Sign Up Free