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.

2.460/16.514 câuCòn 14.054
AThe Platform module allows checking the platform the application is running on.
BPlatform is used to synchronize data between Android and iOS.
CPlatform.OS helps select the appropriate processing logic for a specific platform.
DPlatform is a default component of react-native for creating custom components.
Lời giải
Đáp án đúng gồm hai ý: "The Platform module allows checking the platform the application is running on." và "Platform.OS helps select the appropriate processing logic for a specific platform.". Platform là module tiện ích (không phải component) của react-native: Platform.OS trả về 'ios' hoặc 'android', Platform.Version cho phiên bản hệ điều hành, và Platform.select nhận đối tượng có khoá ios, android để chọn giá trị phù hợp, nhờ đó viết nhánh logic hay style riêng cho từng nền tảng trong cùng một tệp. "Platform is used to synchronize data between Android and iOS." sai vì Platform chỉ đọc thông tin môi trường chạy trên chính thiết bị, không truyền hay đồng bộ dữ liệu giữa các thiết bị. "Platform is a default component of react-native for creating custom components." sai vì Platform không render gì cả; component tuỳ chỉnh được tạo bằng hàm hoặc class React.
Mở trang câu hỏi này →
2442What is an API platform?4 lựa chọn
AA database management system
BA software system with tools to build, manage, publish, and consume APIs
CA type of cloud infrastructure
DA web browser
Lời giải
Đáp án đúng: "A software system with tools to build, manage, publish, and consume APIs". Nền tảng API (API platform) là hệ thống phần mềm gom công cụ cho toàn vòng đời API: thiết kế đặc tả, viết và kiểm thử, xuất bản kèm tài liệu, quản lý phiên bản và quyền, tới phía người dùng khám phá và gọi API; Postman là ví dụ quen thuộc. "A database management system" sai vì hệ quản trị cơ sở dữ liệu lưu và truy vấn dữ liệu, không quản lý API. "A type of cloud infrastructure" sai vì nền tảng API có thể chạy trên đám mây nhưng bản thân nó là bộ công cụ, không phải hạ tầng máy chủ. "A web browser" chỉ là ứng dụng hiển thị trang web, gửi được yêu cầu HTTP nhưng không có chức năng quản lý API.
Mở trang câu hỏi này →
Đề bài
import { useNavigationState } from '@react-navigation/native';

function CurrentRouteComponent() {
  const currentRoute = useNavigationState(state => state.routes[state.index].name);

  return (
    <Text>Current Route: {currentRoute}</Text>
  );
}
AThe index of the current route in the navigation stack
BThe parameters of the current route
CThe name of the current route
DThe state object of the current route
Lời giải
Đáp án đúng: "The name of the current route". useNavigationState nhận một hàm selector, gọi nó với state của navigator gần nhất và trả về kết quả, đồng thời render lại component khi kết quả đổi. Lần theo mã: state.routes là mảng các route trong navigator, state.index là vị trí route đang hiển thị, nên state.routes[state.index] là đối tượng route hiện tại, và thêm .name lấy ra tên của nó, ví dụ "Home" hay "Profile"; component in chuỗi đó trong Text. "The index of the current route in the navigation stack" sai vì đó là state.index, mã chỉ dùng index để truy cập phần tử chứ không trả về nó. "The parameters of the current route" sai vì muốn lấy tham số phải đọc .params thay vì .name. "The state object of the current route" sai vì selector đi thêm một bước tới .name, trả về chuỗi chứ không trả về cả đối tượng route.
Mở trang câu hỏi này →
ABottom Tab Navigator
BStack Navigator
CDrawer Navigator
DInline Navigator
Lời giải
Đáp án đúng: "Drawer Navigator". Drawer Navigator hiển thị một ngăn kéo menu trượt ra từ cạnh màn hình (vuốt hoặc bấm biểu tượng menu), chứa các mục dẫn tới những phần lớn của ứng dụng, nên người dùng truy cập được các khu vực toàn cục từ bất kỳ màn hình nào. "Bottom Tab Navigator" cũng chuyển giữa các khu vực nhưng bằng thanh tab cố định ở đáy, không phải menu trượt, và hợp với số ít mục dùng thường xuyên. "Stack Navigator" quản lý các màn hình theo ngăn xếp, đi tới thì đẩy màn hình mới, quay lại thì gỡ ra, không có menu. "Inline Navigator" không phải navigator có trong React Navigation.
Mở trang câu hỏi này →
AuseScrollToTop
BuseRoute
CuseNavigation
DuseLinking
Lời giải
Đáp án đúng: "useLinking". Ở React Navigation 5, hook useLinking dùng với container điều hướng để lắng nghe URL mở ứng dụng, đối chiếu với prefixes và cấu hình ánh xạ đường dẫn sang màn hình rồi điều hướng tới đúng nơi, tức là xử lý deep linking (liên kết sâu); các bản sau chuyển phần này thành prop linking của NavigationContainer. "useScrollToTop" làm danh sách cuộn lên đầu khi bấm lại tab đang mở. "useRoute" trả về đối tượng route của màn hình hiện tại để đọc name và params. "useNavigation" trả về đối tượng navigation cho component không phải màn hình, để gọi navigate hay goBack.
Mở trang câu hỏi này →
AAllows easier use in functional components.
BCompletely eliminates the need for a navigation container.
CReduces or eliminates the dependency on Higher-Order Components (HOCs).
DRequires the use of class components.
Lời giải
Đáp án đúng gồm hai ý: "Allows easier use in functional components." và "Reduces or eliminates the dependency on Higher-Order Components (HOCs).". React Navigation 5 thêm các hook như useNavigation, useRoute, useFocusEffect, useIsFocused; component hàm ở bất kỳ tầng nào gọi hook là lấy được đối tượng navigation hay route, không cần nhận qua prop. Trước đó, component con muốn điều hướng phải được bọc bằng HOC (Higher-Order Component, hàm nhận component và trả về component mới) như withNavigation hay withNavigationFocus, làm cây component rối và khó khai báo kiểu. "Completely eliminates the need for a navigation container." sai vì từ bản 5 trở đi ứng dụng vẫn phải bọc navigator trong NavigationContainer; hook không thay thế nó. "Requires the use of class components." sai vì hook chỉ dùng được trong component hàm, còn class component vẫn nhận navigation qua prop như cũ.
Mở trang câu hỏi này →
AUsing the style prop
BUsing the drawerWidth prop
CUsing the drawerStyle prop
DUsing a CSS file
Lời giải
Đáp án đúng: "Using the drawerWidth prop". DrawerLayoutAndroid là component chỉ có trên Android, bọc nội dung chính và một ngăn kéo trượt ra từ cạnh; nó có prop drawerWidth nhận một số đơn vị độc lập mật độ (dp) để quy định bề rộng ngăn kéo, cùng các prop drawerPosition, renderNavigationView. "Using the style prop" áp style cho vùng chứa của layout chứ không điều khiển bề rộng ngăn kéo. "Using the drawerStyle prop" là option của Drawer Navigator trong React Navigation, không phải prop của DrawerLayoutAndroid. "Using a CSS file" không áp dụng được vì React Native không dùng tệp CSS; style được viết bằng đối tượng JavaScript với StyleSheet.create hoặc inline.
Mở trang câu hỏi này →
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 →