Tất cả câu hỏi

Ngân hàng câu hỏi trắc nghiệm có giải thích chi tiết.

6.300/20.347 câuCòn 14.047
A<Button title="Click Me" onPress={() => alert('Pressed')} />
B<Button text="Click Me" onClick={() => alert('Pressed')} />
C<Button label="Click Me" action={() => alert('Pressed')} />
D<Button caption="Click Me" press={() => alert('Pressed')} />
Lời giải

Đáp án đúng: "

Lời giải
<Button title="Click Me" onPress={
  () =>

alert('Pressed')} />". Button lõi của React Native bắt buộc prop title là chuỗi hiển thị trên nút và nhận hàm xử lý chạm qua onPress; khi bấm, hàm mũi tên chạy và alert hiện hộp thoại chữ Pressed. "

Lời giải
<Button text="Click Me" onClick={
  () =>

alert('Pressed')} />" mang thói quen từ web: Button không có prop text, và React Native không dùng sự kiện onClick nên bấm sẽ không có gì xảy ra. "

Lời giải
<Button label="Click Me" action={
  () =>

alert('Pressed')} />" sai vì label và action không phải prop của Button, thiếu title còn gây lỗi. "

Lời giải
<Button caption="Click Me" press={
  () =>

alert('Pressed')} />" sai vì caption và press đều không có trong API, tên đúng phải là title và onPress.

Mở trang câu hỏi này →
ATextInput cannot use state to store the value entered by the user.
BTextInput is often linked to a state variable to display the current value and update when the user changes the content.
CThe onChangeText event is used to update the props of TextInput directly.
DThe value property in TextInput should be linked to a state variable so that the component can control the displayed content (controlled component).
Lời giải
Đáp án đúng gồm hai ý: "TextInput is often linked to a state variable to display the current value and update when the user changes the content." và "The value property in TextInput should be linked to a state variable so that the component can control the displayed content (controlled component).". Mẫu chuẩn là controlled component (component được điều khiển): khai báo state bằng useState, truyền state vào prop value và truyền hàm set vào onChangeText; mỗi lần người dùng gõ, onChangeText nhận chuỗi mới, state đổi, component render lại và TextInput hiển thị đúng giá trị trong state, nhờ đó dễ kiểm tra hợp lệ hay định dạng dữ liệu. "TextInput cannot use state to store the value entered by the user." sai, vì dùng state chính là cách phổ biến nhất như vừa mô tả. "The onChangeText event is used to update the props of TextInput directly." sai vì props là chỉ đọc, không thể sửa trực tiếp; onChangeText chỉ đưa chuỗi mới cho ta cập nhật state, rồi state mới được truyền lại vào value.
Mở trang câu hỏi này →
AView
BText
CImage
DScrollView
Lời giải
Đáp án đúng: "Text". Text là core component (thành phần lõi) hiển thị văn bản, được ánh xạ sang view văn bản gốc của từng nền tảng; mọi chuỗi chữ phải đặt trong Text, và Text lồng nhau kế thừa style của Text cha. "View" là khung chứa để dựng bố cục với flexbox, không tự hiển thị chữ. "Image" hiển thị ảnh từ tài nguyên cục bộ hoặc URL. "ScrollView" là vùng cuộn bao lấy nội dung khác, chính nó không hiển thị văn bản. Như vậy View, Image và ScrollView đều quan trọng nhưng mỗi cái giải quyết một nhu cầu khác, chỉ Text mới đảm nhận việc vẽ chữ lên màn hình.
Mở trang câu hỏi này →
AView is a basic container component, playing a similar role to the <div> tag in HTML, used to contain other components.
BView is a leaf component and cannot contain any child components inside.
CView is only used to display plain text and does not support layout or applying styles.
DView is mainly used to create layouts and apply style properties to the child components it contains.
Lời giải

Đáp án đúng gồm hai ý: "View is a basic container component, playing a similar role to the <div> tag in HTML, used to contain other components." và "View is mainly used to create layouts and apply style properties to the child components it contains.". View là component nền tảng, ánh xạ sang UIView trên iOS và android.view.View trên Android; nó chứa được bao nhiêu con tuỳ ý, là flex container để bố cục, nhận style như padding, backgroundColor, borderRadius, và chính các style căn chỉnh của View quyết định vị trí các con bên trong. "View is a leaf component and cannot contain any child components inside." sai vì View chính là khung chứa, hầu hết màn hình React Native là cây các View lồng nhau. "View is only used to display plain text and does not support layout or applying styles." sai vì View không hiển thị chữ trực tiếp, chữ phải nằm trong Text, còn bố cục và style lại là công dụng chính của View.

Mở trang câu hỏi này →
ADeploying an app to the Play Store
BInstantly seeing UI changes during development
COptimizing app performance on low-end devices
DAccessing native camera APIs
Lời giải
Đáp án đúng: "Instantly seeing UI changes during development". Hot reloading (nay là Fast Refresh) cho phép lưu tệp là thấy thay đổi giao diện ngay trên máy ảo hay điện thoại, thường giữ nguyên state hiện tại của component, nên lập trình viên chỉnh style, bố cục hay chữ mà không phải build lại hay thao tác lại từ đầu tới màn hình đang làm. "Deploying an app to the Play Store" sai vì phát hành lên cửa hàng cần build bản release, hoàn toàn nằm ngoài cơ chế nạp nóng lúc phát triển. "Optimizing app performance on low-end devices" sai vì hot reloading chỉ phục vụ chế độ phát triển, không ảnh hưởng hiệu năng bản phát hành. "Accessing native camera APIs" sai vì truy cập camera cần thư viện hoặc Native Module; thay đổi mã native còn đòi build lại, hot reloading không giúp được.
Mở trang câu hỏi này →
ArenderSectionHeader receives an element directly from the data array (i.e., the data of all sections combined) and returns a React Element to display.
BrenderItem receives an element from the data array of each individual section and renders a React Element, representing that item in the section.
CBoth props (renderItem and renderSectionHeader) receive an element from the sections array and handle them in the same way.
DrenderSectionHeader receives an element from the sections array to create and display the header for that section.
Lời giải
Đáp án đúng gồm hai ý: "renderItem receives an element from the data array of each individual section and renders a React Element, representing that item in the section." và "renderSectionHeader receives an element from the sections array to create and display the header for that section.". SectionList hiển thị danh sách chia nhóm: prop sections là mảng các đối tượng nhóm, mỗi nhóm có tiêu đề và mảng data riêng; renderItem được gọi cho từng phần tử trong data của từng nhóm, còn renderSectionHeader được gọi một lần cho mỗi đối tượng trong sections để vẽ tiêu đề nhóm. Phát biểu "receives an element directly from the data array (i.e., the data of all sections combined)" sai vì tiêu đề nhóm nhận đối tượng section chứ không nhận phần tử dữ liệu, và không có mảng gộp mọi nhóm. Phát biểu "Both props (renderItem and renderSectionHeader) receive an element from the sections array" sai vì hai prop nhận hai loại dữ liệu khác nhau và có vai trò khác nhau.
Mở trang câu hỏi này →
AIt allows developers to handle data binding more securely.
BIt simplifies the division of application functions into independent blocks.
CIt limits the app to a single platform.
DIt reduces the number of third-party plugins needed.
Lời giải
Đáp án đúng: "It simplifies the division of application functions into independent blocks.". Kiến trúc mô-đun (modular architecture) của React Native xoay quanh component: mỗi chức năng được tách thành khối độc lập có props đầu vào rõ ràng, có thể phát triển, kiểm thử và tái sử dụng riêng rồi ghép lại thành màn hình, nhờ đó ứng dụng dễ mở rộng và bảo trì. "It allows developers to handle data binding more securely." lệch chủ đề: React dùng luồng dữ liệu một chiều qua props và state, còn độ an toàn của dữ liệu không do việc chia module quyết định. "It limits the app to a single platform." sai vì React Native nhắm tới chạy đa nền tảng trên iOS và Android. "It reduces the number of third-party plugins needed." cũng không đúng, vì số thư viện cần dùng tuỳ vào tính năng của app chứ không giảm đi nhờ chia module.
Mở trang câu hỏi này →
AJavaScript lacks flexibility.
BJavaScript makes apps more expensive.
CJavaScript has lower security standards.
DJavaScript reduces community support.
Lời giải
Đáp án đúng: "JavaScript has lower security standards.". Mã JavaScript của ứng dụng React Native được đóng thành một bundle nằm trong gói cài đặt; dù đã rút gọn hoặc biên dịch sang bytecode của Hermes, kẻ xấu vẫn có thể giải nén và đọc lại logic, khoá API hay chuỗi bí mật dễ hơn nhiều so với mã native, và các gói npm bên thứ ba còn mở thêm rủi ro chuỗi cung ứng; vì vậy JavaScript bị xem là điểm yếu bảo mật, buộc phải giữ bí mật ở máy chủ hoặc Keychain/Keystore. "JavaScript lacks flexibility." sai vì linh hoạt chính là thế mạnh của JavaScript. "JavaScript makes apps more expensive." sai vì dùng chung một mã JavaScript cho hai nền tảng còn giảm chi phí. "JavaScript reduces community support." sai vì cộng đồng JavaScript thuộc loại lớn nhất.
Mở trang câu hỏi này →
AAdding a basic button to the app
BIntegrating with a platform-specific API like Google Play services
CDisplaying static text content
DAdjusting padding and margin of elements
Lời giải
Đáp án đúng: "Integrating with a platform-specific API like Google Play services". Native Module cần đến khi JavaScript phải gọi một API riêng của nền tảng mà React Native chưa bọc sẵn, như Google Play services, SDK thanh toán, cảm biến hay phần cứng đặc thù; khi đó ta viết mã Java/Kotlin hoặc Objective-C/Swift rồi export phương thức cho JS gọi. "Adding a basic button to the app" đã có sẵn Button, Pressable, TouchableOpacity trong lõi React Native nên không cần mã native. "Displaying static text content" chỉ cần component Text. "Adjusting padding and margin of elements" làm bằng thuộc tính style như padding, margin trong StyleSheet, hoàn toàn ở phía JavaScript; cả ba việc này đều là thao tác giao diện cơ bản đã được React Native hỗ trợ sẵn.
Mở trang câu hỏi này →
AIt reduces energy consumption.
BIt increases the accuracy of location data.
CIt decreases the accuracy of location data.
DIt has no effect on location accuracy.
Lời giải
Đáp án đúng: "It increases the accuracy of location data.". enableHighAccuracy là tuỳ chọn truyền vào getCurrentPosition hoặc watchPosition; khi đặt true, thiết bị ưu tiên GPS thay vì chỉ ước lượng qua Wi-Fi hay trạm di động, nên toạ độ chính xác hơn, đổi lại tốn pin hơn và có thể lâu hơn mới có kết quả. "It reduces energy consumption." sai vì GPS tốn năng lượng hơn, nên bật tuỳ chọn này làm tăng mức tiêu thụ pin. "It decreases the accuracy of location data." sai vì đi ngược ý nghĩa của tuỳ chọn; muốn tiết kiệm pin với độ chính xác thấp hơn thì đặt false. "It has no effect on location accuracy." sai vì tuỳ chọn này đổi nguồn định vị được dùng nên ảnh hưởng trực tiếp tới độ chính xác, dù ở trong nhà nơi GPS yếu thì chênh lệch có thể nhỏ.
Mở trang câu hỏi này →
AThe quality of the image or video
BThe format of text displayed on the picker
CWhether the picker accepts images, videos, or both
DThe color of the image picker interface
Lời giải
Đáp án đúng: "Whether the picker accepts images, videos, or both". Trong thư viện chọn ảnh như expo-image-picker hay react-native-image-picker, tuỳ chọn media type (mediaTypes hoặc mediaType) giới hạn loại tệp người dùng được chọn từ thư viện máy hoặc camera: chỉ ảnh, chỉ video, hoặc cả hai. "The quality of the image or video" do một tuỳ chọn riêng là quality đảm nhiệm, nhận số từ 0 tới 1. "The format of text displayed on the picker" sai vì bộ chọn dùng giao diện của hệ điều hành, tuỳ chọn này không đụng tới chữ. "The color of the image picker interface" cũng sai, màu giao diện bộ chọn không do media type quyết định.
Mở trang câu hỏi này →
AScrollView lacks touch gesture support
BScrollView renders all items at once, increasing memory usage
CFlatList automatically applies platform-specific optimizations
DScrollView requires manual key extraction
Lời giải
Đáp án đúng: "ScrollView renders all items at once, increasing memory usage". ScrollView dựng mọi phần tử con ngay khi mount, kể cả phần ở xa ngoài màn hình, nên với hàng nghìn dòng nó tốn bộ nhớ và làm chậm lần hiển thị đầu; FlatList thì ảo hoá, chỉ render vùng gần màn hình và giải phóng phần đã cuộn qua. "ScrollView lacks touch gesture support" sai vì ScrollView xử lý cử chỉ cuộn, kéo, thu phóng bình thường. Phát biểu "FlatList automatically applies platform-specific optimizations" không phải lý do: ưu thế của FlatList đến từ cơ chế ảo hoá dùng chung cho cả hai nền tảng. "ScrollView requires manual key extraction" sai vì ScrollView không có khái niệm keyExtractor; đó là prop của FlatList.
Mở trang câu hỏi này →
AUsing global state management
BPassing props
CUsing AsyncStorage
DUsing the Metro bundler
Lời giải

Đáp án đúng: "Passing props". Trong React, dữ liệu chảy một chiều từ cha xuống con: cha truyền giá trị qua thuộc tính JSX như

Lời giải
<Profile name={
  user.name
}
/>

, con nhận qua tham số props và chỉ đọc chứ không sửa. Đây là cách trực tiếp, rõ ràng và dễ kiểm thử nhất cho quan hệ cha con. "Using global state management" như Redux hay Context hợp với dữ liệu dùng chung ở nhiều tầng cách xa nhau; áp cho quan hệ cha con trực tiếp là phức tạp hoá không cần thiết. "Using AsyncStorage" sai vì đó là kho lưu trữ bền vững trên thiết bị, bất đồng bộ và chậm, dùng để giữ dữ liệu qua các lần mở app chứ không để truyền dữ liệu giữa component. "Using the Metro bundler" sai vì Metro chỉ đóng gói mã JavaScript khi phát triển và build, không liên quan tới truyền dữ liệu lúc chạy.

Mở trang câu hỏi này →
AArrays
BBuffers
CKey-value pairs
DTrees
Lời giải
Đáp án đúng: "Key-value pairs". AsyncStorage là kho lưu trữ bền, bất đồng bộ theo mô hình khoá–giá trị: mỗi khoá là một chuỗi gắn với một giá trị cũng là chuỗi, đọc ghi qua setItem, getItem, removeItem; dữ liệu phức tạp phải JSON.stringify khi ghi và JSON.parse khi đọc. "Arrays" không phải cấu trúc gốc, mảng chỉ lưu được sau khi chuyển thành chuỗi JSON. "Buffers" là dữ liệu nhị phân, AsyncStorage không hỗ trợ lưu trực tiếp. "Trees" là cấu trúc phân cấp, AsyncStorage không có cơ chế lưu cây hay truy vấn theo quan hệ cha con.
Mở trang câu hỏi này →
Aprops are used to pass data from a parent component to a child component, while state is used to manage the internal data of a component.
Bstate can be changed by the component itself, while props are read-only for the receiving component.
Cprops allow the component to automatically update the displayed data based on user interactions.
Dstate should only be passed as a parameter between components and should not be used to store internal data.
Lời giải
Đáp án đúng gồm hai ý: "props are used to pass data from a parent component to a child component, while state is used to manage the internal data of a component." và "state can be changed by the component itself, while props are read-only for the receiving component.". props là dữ liệu component cha truyền xuống con, phía con chỉ được đọc; state là dữ liệu nội bộ do chính component sở hữu, được đổi bằng this.setState hoặc hàm set của useState, và mỗi lần đổi sẽ khiến component render lại. "props allow the component to automatically update the displayed data based on user interactions." sai vì tương tác của người dùng được phản ánh bằng cách cập nhật state; props chỉ đổi khi component cha truyền xuống giá trị mới. "state should only be passed as a parameter between components and should not be used to store internal data." đảo ngược bản chất: state chính là nơi lưu dữ liệu nội bộ, còn khi muốn chia sẻ thì giá trị state được truyền xuống con dưới dạng props.
Mở trang câu hỏi này →
AIt uses more memory
BIt reduces I/O overhead
CIt slows down access
DIt requires extra permissions
Lời giải
Đáp án đúng: "It reduces I/O overhead". multiGet của AsyncStorage nhận một mảng khoá và trả về các cặp khoá–giá trị trong một lần gọi, nên chỉ qua tầng native và truy cập kho lưu trữ một lần thay vì lặp lại cho từng getItem; chi phí vào–ra (I/O overhead) và số lần chờ bất đồng bộ đều giảm. "It uses more memory" sai vì gom lệnh không làm tốn thêm bộ nhớ đáng kể, lượng dữ liệu đọc ra vẫn như cũ. "It slows down access" ngược với thực tế, một lời gọi gom nhanh hơn nhiều lời gọi rời. "It requires extra permissions" sai vì AsyncStorage dùng vùng lưu trữ riêng của ứng dụng, getItem hay multiGet đều không cần cấp quyền nào.
Mở trang câu hỏi này →
Arow
Bcolumn
Crow-reverse
Dcolumn-reverse
Lời giải
Đáp án đúng: "column". flexDirection xác định trục chính để xếp các phần tử con trong một flex container. React Native dùng engine bố cục Yoga, và Yoga chọn column làm mặc định cho mọi View, nên các con xếp từ trên xuống dưới nếu không khai báo gì; đây là điểm khác với CSS trên trình duyệt, nơi mặc định là row. Hệ quả là justifyContent mặc định căn theo trục dọc, còn alignItems căn theo trục ngang. "row" sai vì muốn xếp ngang phải khai báo flexDirection: 'row' rõ ràng. "row-reverse" sai vì đây là giá trị xếp ngang đảo chiều, chỉ áp dụng khi được gán. "column-reverse" sai vì nó xếp dọc từ dưới lên, cũng không phải mặc định mà phải gán chủ động.
Mở trang câu hỏi này →
AA developer needs to center-align text in their app. They decide to create a Native Module for this.
BA developer needs to integrate fingerprint authentication, which requires access to native device APIs for both iOS and Android. By implementing this as a Native Module, they can efficiently leverage platform-specific APIs to provide secure authentication without compromising performance.
CA developer wants to add a button with a color change on press, so they create a Native Module for this.
DA developer creates a Native Module to handle static images, even though no platform-specific functionality is needed.
Lời giải
Đáp án đúng: "A developer needs to integrate fingerprint authentication, which requires access to native device APIs for both iOS and Android. By implementing this as a Native Module, they can efficiently leverage platform-specific APIs to provide secure authentication without compromising performance.". Native Module đáng làm khi ứng dụng cần một khả năng của nền tảng mà JavaScript không tự truy cập được; xác thực vân tay phải gọi API sinh trắc học riêng của từng hệ điều hành (BiometricPrompt trên Android, LocalAuthentication trên iOS), nên viết module gốc rồi đưa ra một hàm chung cho JavaScript là lựa chọn hợp lý. Tình huống "center-align text in their app" sai vì căn giữa chữ chỉ cần textAlign: 'center' trong style. Tình huống "add a button with a color change on press" sai vì Pressable hay TouchableOpacity cùng state đã làm được, không cần mã gốc. Tình huống "to handle static images, even though no platform-specific functionality is needed" sai vì component Image với require đã hiển thị ảnh tĩnh, và chính mô tả cho biết không cần tính năng riêng của nền tảng.
Mở trang câu hỏi này →
AAsyncStorage
BSecureStore
CLocalStorage
DRedux Store
Lời giải
Đáp án đúng: "SecureStore". SecureStore (gói expo-secure-store) lưu cặp khoá–giá trị đã được mã hoá, dựa trên Keychain của iOS và Keystore của Android, nên phù hợp để cất mật khẩu, token truy cập hay khoá bí mật. "AsyncStorage" lưu dữ liệu dạng văn bản thường, không mã hoá, ai lấy được tệp dữ liệu của app là đọc được, nên chỉ dùng cho dữ liệu không nhạy cảm. "LocalStorage" là API của trình duyệt web, không có sẵn trong React Native và vốn cũng không mã hoá. "Redux Store" chỉ giữ state trong bộ nhớ khi app đang chạy và mất khi tắt app; nếu kèm redux-persist thì dữ liệu lại được ghi xuống kho không mã hoá, nên đây không phải nơi an toàn cho mật khẩu.
Mở trang câu hỏi này →
AVisual Studio Code
BAndroid Studio
CXcode
DSublime Text
Lời giải
Đáp án đúng: "Xcode". Mã native iOS của dự án React Native (Objective-C, Swift, cấu hình target, CocoaPods qua tệp xcworkspace) được mở và biên dịch bằng Xcode, IDE (môi trường phát triển tích hợp) chính thức của Apple; chỉ Xcode có bộ SDK iOS, trình giả lập Simulator và công cụ ký ứng dụng, nên việc này phải làm trên macOS. "Visual Studio Code" rất phổ biến để viết phần JavaScript của React Native, nhưng không biên dịch được dự án iOS và thiếu công cụ cho mã native của Apple. "Android Studio" sai vì đây là IDE cho phần native Android (Java/Kotlin, Gradle), không dùng cho iOS. "Sublime Text" sai vì đây chỉ là trình soạn thảo văn bản, không có trình biên dịch, giả lập hay công cụ ký cho iOS.
Mở trang câu hỏi này →