HarmonyOS应用开发者高级认证,Next版本发布后最新题库 - 多选题序号5

基础认证题库请移步:HarmonyOS应用开发者基础认证题库


注:有读者反馈,题库的代码块比较多,打开文章时会卡死。所以笔者将题库拆分,单选题20个为一组,多选题10个为一组,题库目录如下,读者可以按需跳转。如果对您的阅读产生不便,笔者在这里向大家说声抱歉,请各位读者原谅。完整的md文档,等读者把题库整理完,会将网盘链接发出。

序号目录:


注:题目是乱序,每次考试,选项的顺序都不同

多选题题库 - 序号5


41、以下关于Localstorage的说法正确有哪些?

​ A、LocalStorage中的所有属性都是不可变的。

B、被@Component装饰的组件最多可以访问一个LocalStorage实例和AppStorage,未被@Entry装饰的组件不可被独立分配LocalStorage实例,只能接受父组件的LocalStorage实例。

C、组件树的根节点,即被@Entry装饰的@Component,可以被分配一个LocalStorage实例, 此组件的所有子组件实例将自动获得对该LocalStorage实例的访问权限。

D、应用程序可以创建多个LocalStorage实例,LocalStorage实例可以在页面内共享,也可以通过GetShared接口,获取在UIAbility里创建的GetShared,实现跨页面、UIAbility内共享 。

LocalStorage:页面级UI状态存储-管理应用拥有的状态-状态管理(V1稳定版)-状态管理-学习ArkTS语言-基础入门 | 华为开发者联盟 (huawei.com)


42、在基于Stage模型开发的应用项目代码下,每个模块都存在一个module.json5配置文件,用于配置模块的基本信息,以下module.json5配置文件正确的是

typescript 复制代码
//	A	
{
	"module": {
		"name": "bName",
		"type":" shared",
		"deviceTypes": [
			"default",
			"tablet"
		],
		"deliveryWithInstall": true,
		"pages": "$profile:main_pages"
    }
}
typescript 复制代码
//	B	==	缺少字段【deliveryWithInstall】
{
	"module": {
		"name": "aName",
		"type": "har"
		"deviceTypes": [
		"default", "tablet" ]
	}
}
typescript 复制代码
//	C	==	【type】字段不支持【hsp】
{
	"module": {
    	"name": "cName",
		"type": "hsp",
		"description": "$string:desc",
		"deviceTypes": [
			"default",
			"tablet"
		],
		"deliveryWithInstal1": true,
		"pages": "$profile:main_pages"
    }
}
typescript 复制代码
//	D
{
	"module": {
		"name": "application",
		"type": "feature",
		"description": "$string:module_desc",
		"mainElement": "ApplicationAbility",
		"deviceTypes": [
			"default",
			"tablet"
		],
		"deliverywithInstall": true,
		"installationFree": false,
		"pages": "$profile:main_pages",
		"abilities": [
            {
				"name": "ApplicationAbility",
				"srcEntry": "./ets/applicationability/ApplicationAbility.ets", 
				"description": "$string:ApplicationAbility_desc",
				"icon": "$media:icon",
				"label": "$string:ApplicationAbility_label",
				"startwindowIcon": "$media:startIcon",
				"startWindowBackground": "$color:start_window_background",
				"exported": true
			}
		]
    }
}

A、A

​ B、B

​ C、C

D、D

module.json5配置文件-应用配置文件(Stage模型)-开发基础知识-基础入门 | 华为开发者联盟 (huawei.com)


43、hiAppEvent提供的Watcher接口,订阅到的系统事件,哪些包含HiLog日志?

A、CPU高负载事件

B、启动耗时事件

C、卡死事件

D、崩溃事件

订阅CPU高负载事件(ArkTS)-CPU高负载事件-系统事件-事件订阅-HiAppEvent使用指导-Performance Analysis Kit(性能分析服务)-调测调优-系统 | 华为开发者联盟 (huawei.com)

订阅启动耗时事件(ArkTS)-启动耗时事件-系统事件-事件订阅-HiAppEvent使用指导-Performance Analysis Kit(性能分析服务)-调测调优-系统 | 华为开发者联盟 (huawei.com)

订阅卡死事件(ArkTS)-卡死事件-系统事件-事件订阅-HiAppEvent使用指导-Performance Analysis Kit(性能分析服务)-调测调优-系统 | 华为开发者联盟 (huawei.com)

订阅崩溃事件(ArkTS)-崩溃事件-系统事件-事件订阅-HiAppEvent使用指导-Performance Analysis Kit(性能分析服务)-调测调优-系统 | 华为开发者联盟 (huawei.com)


44、当前动态import支持导入的模块类型有哪些?

A、动态import支持加载OHPM模块

B、动态import支持加载本地HAR模块

C、动态import支持加载HSP模块

D、动态import支持加载远程HAR模块

动态import-应用程序包开发与使用-应用程序包基础知识-开发基础知识-基础入门 | 华为开发者联盟 (huawei.com)


45、ArkTS是鸿蒙生态的应用开发语言。以下哪些选项是ArkTS的设计理念。(我感觉【satety】打错了,应该是【safety】)

A、通过规范强化静态检查和分析,减少运行时的类型检查,从而降低了运行时负载,提升执行性能。

B、通过规范强化静态检查和分析, 使得许多错误在编译时可以被检测出来,降低代码运行错误的风险。

​ C、ArkTS不支持null-satety特性 。

D、ArkTS保留 了TS大部分的语法特性,帮助开发者更容易上手ArkTS。


46、以下代码片段哪几处违反了ArkTS语法规范。

typescript 复制代码
function foo(value: number) {
  return value;
}

foo('');
foo(0);
foo(undefined);
foo(null);

A. foo(null);

B. foo(undefined);

C. foo(");

​ D.foo(0);


47、以下哪些是可以在Navigation中使用pushPathByName接口传递的params的参数类型(不确定,把所有选项列出)

A、arrayBuffer

B、map<string,string>

C、record<string,string>

D、string


48、HSP支持导出ArkUl组件、接口,供应用内的其他HAP/HSP引用,下面正确的是(不确定,把所有选项列出)

typescript 复制代码
//	A

//  library/src/main/ets/components/MyTitleBar.ets
@Component
export struct MyTitleBar {
  build() {
    Row() {
      Text($r('app.string.library_title' ))
        .id('library')
        .fontFamily('HarmonyHeiTi')
        .fontWeight(FontWeight.Bold)
        .fontSize(32)
        .fontColor($r('app.color.text_color'))
    }
    .width('100%')
  }
}
//	对外暴露的接口,需要在入口文件index.ets中声明:
//	library/index.ets
export { MyTitleBar } from './src/main/ets/components/MyTitleBar';
typescript 复制代码
//	B

//  library/src/main/ets/utils/nativeTest.ts
import native from 'liblibrary.so';
export function nativeMulti(a: number, b: number): number {
  let result: number = native.multi(a, b);
  return result;
}
//  对外暴露的接口,需要在入口文件index.ets中声明:
//  library/index.ets
export { nativeMulti } from './ src/main/ets/utils/nativeTest';
typescript 复制代码
//  C

//  library/src/main/ets/utils/test.ts
export class Log {
  static info(msg: string): void {
    console.info(msg);
  }
}
export function add(a: number, b: number): number {
  return a + b;
}
export function minus(a: number, b: number): number {
  return a - b;
}
//  对外暴露的接口,需要在入口文件index.ets中声明:
//  library/index.ets
export { Log, add, minus } from './src/main/ets/utils/test';

A、导出ArkUI组件

B、导出native方法,在HSP中也可以包含C++编写的so。对于so中的native方法,HSP通过间接的方式导出,以导出liblibrary.so的乘法接口multi为例

C、导出ts类和方法


49、下面关于方舟字节码文件格式描述正确的是

​ A、方舟字节码文件中数据类型uint32_t表示32-bit无符号整数,采用大端字节序

​ B、方舟字节码文件中不包含字节码文件内容的adler32校验和

C、方舟字节码文件是ArkTS/TS/JS编译后的二进制产物

D、方舟字节码文件中数据类型uint16_t表示16-bit无符号整数,采用小端字节序

方舟字节码文件格式-学习ArkTS语言-基础入门 | 华为开发者联盟 (huawei.com)


50、在开发HarmonyOS应用的多元化测试环境中,DevEco Studio引入了本地模拟器(Local Emulator)作为重要工具,旨在帮助开发者在个人开发机器上高效模拟HarmonyOS环境,进行应用或服务的快速运行与细致调试。请根据本地模拟器的实际应用场景与系统要求,选出所有正确的描述选项

​ A、开发者需要注意的是,DevEco Studio的本地模拟器可以在虚拟机内部进一步运行,以节省硬件资源。

B、为了保证流畅的运行和调试体验,本地模拟器推荐macOS系统版本至少为12.5以上。

C、DevEco Studio的本地模拟器允许开发者在个人电脑上模拟HarmonyOS环境,便于应用或服务的运行与调试。

D、mac计算机配置方面,为了确保本地模拟器的稳定运行,推荐至少配备8GB RAM。

使用环境-概述-使用模拟器运行应用/服务-应用/服务运行-DevEco Studio | 华为开发者联盟 (huawei.com)


51、下面关于混淆的描述正确的是

A、支持顶层作用域名称、 属性名称、文件名称等多种混淆功能

B、修改应用混淆配置,新配置需要重新全量编译应用才能生效

​ C、在工程build-profile.json5中的obfuscation.ruleOptions.files字段中配置该工程的混淆配置,该配置仅在编译该工程时生

效。

​ D、可以在HAR模块工程的build-profile.json5中的obfuscation.consumerFiles字段中配置导出的混淆配置,该配置仅在编译

依赖该HAR的模块时生效。

代码混淆-ArkTS(方舟编程语言)-应用框架 | 华为开发者联盟 (huawei.com)


52、如下哪些方式可实现图片动态播放?(不确定,不知道代码是不是故意给错了)

typescript 复制代码
//	A
import {AnimationOptions, AnimatedDrawableDescriptor} from '@ohos.arkui.drawableDescriptor'
import image from '@ohos.multimedia.image'

@Entry
@Component
struct ImageExample {
  pixelmaps: Array<PixelMap> = [];
  options: AnimationOptions = {duration:2000, iterations:1};
  @State animated: AnimatedDrawableDescriptor | undefined = undefined;

  async aboutToAppear() {
    this.pixelmaps = await this.getPixelMaps();
    this.animated = new AnimatedDrawableDescriptor(this.pixelmaps, this.options);
  }

  build() {
    Column() {
      Row() {
        Image(this.animated)
          .width('500px').height('280px')
      }.height('50%')
      Row() {
        Button('once').width(100).padding(5).onClick(() => {
          this.options = {duration:2000, iterations:1};
          this.animated = new AnimatedDrawableDescriptor(this.pixelmaps, this.options);
        }).margin(5)
      }
    }.width('50%')
  }

  private async getPixmapFromMedia(resource: Resource) {
    let unit8Array = await getContext(this)?.resourceManager?.getMediaContent({
      bundleName: resource.bundleName,
      moduleName: resource.moduleName,
      id: resource.id
    })
    let imageSource = image.createImageSource(unit8Array.buffer.slice(0, unit8Array.buffer.byteLength))
    let createPixelMap: image.PixelMap = await imageSource.createPixelMap({
      desiredPixelFormat: image.PixelMapFormat.RGBA_8888
    })
    await imageSource.release()
    return createPixelMap
  }

  private async getPixelMaps() {   
    //	====================	怎么没有定义Mypixelmaps????????
    Mypixelmaps.push(await this.getPixmapFromMedia($r('app.media.icon'))) //对应资源图片名后缀为png
    return Mypixelmaps;
  }
}
typescript 复制代码
//	B
import {AnimationOptions, AnimatedDrawableDescriptor} from '@ohos.arkui.drawableDescriptor'
import image from '@ohos.multimedia.image'

@Entry
@Component
struct ImageExample {
  pixelmaps: Array<PixelMap> = [];
  options: AnimationOptions = { duration: 2000, iterations: 1 };
  @State animated: AnimatedDrawableDescriptor | undefined = undefined;

  async aboutToAppear() {
    this.pixelmaps = await this.getPixelMaps();
    this.animated = new AnimatedDrawableDescriptor(this.pixelmaps, this.options);
  }

  build() {
    Column() {
      Row() {
        Image(this.animated)
          .width('500px').height('280px')
      }.height('50%')

      Row() {
        Button('once').width(100).padding(5).onClick(() => {
          this.options = { duration: 2000, iterations: 1 };
          this.animated = new AnimatedDrawableDescriptor(this.pixelmaps, this.options);
        }).margin(5)
      }
    }.width('50%')
  }

  private async getPixmapListFromMedia(resource: Resource) {
    let unit8Array = await getContext(this)?.resourceManager?.getMediaContent({
      bundleName: resource.bundleName,
      moduleName: resource.moduleName,
      id: resource.id
    })
    let imageSource = image.createImageSource(unit8Array.buffer.slice(0, unit8Array.buffer.byteLength))
    let createPixelMap: Array<image.PixelMap> = await imageSource.createPixelMapList({
      desiredPixelFormat: image.PixelMapFormat.RGBA_8888
    })
    await imageSource.release()
    return createPixelMap
  }

  private async getPixelMaps() {
    let Mypixelmaps: Array<PixelMap> = await this.getPixmapListFromMedia($r('app.media.icon')) //对应资源图片为gif
    return Mypixelmaps;
  }
}
typescript 复制代码
//	C
@Entry
@Component
struct ImageExample {
  build() {
    Column({ space: 10 }) {
      Image($r('app.media.earth')) //对应资源图片名后缀为gif
        .width(100)
        .height(100)
    }
  }
}
typescript 复制代码
//	D
@Entry
@Component
struct ImageAnimatorExample {
  @State iterations: number = 1

  build() {
    Column({ space: 10 }) {
      ImageAnimator()
        .images([
          {
            src: $r('app media.img1')
          },
          {
            src: $r('app media.img2')
          },
          {
            src: $r('app media.img3')
          },
          {
            src: $r('app media.img4')
          }
        ])
        .duration(2000)
        .fillMode(FillMode.None).iterations(this.iterations).width(340).height(240)
        .margin({ top: 100 })
    }.width('100%').height('100%')
  }
}

A、A

B、B

C、C

D、D


53、下面关于混淆规则描述正确的是

​ A、-keep-global-name [,idetifies,...]: 指定想保留的属性名

B、-keep-file-name [,identifirs,...]:指定要保留的文件/文件夹的名称

​ C、-keep-property-name [,idetifies,...]:指定要保留的顶层作用域的名称

D、-print-namecache filepath:将名称缓存保存 到指定的文件路径。

代码混淆-ArkTS(方舟编程语言)-应用框架 | 华为开发者联盟 (huawei.com)


54、下面关于Node-API数据类型描述正确的是

​ A、napi_status:是一个枚举数据类型,表示Node-API接口返回的状态信息

​ B、napi_threadsafe_function_release_mode:该枚举类型定义了两个常量,用于指定线程安全函数的调用模式

​ C、napi_env:用于表示Node-API执行时的上下文

​ D、napi_threadsafe_function_call_mode:该枚举类型定义了两个常量,用于指定在何时释放线程安全函数的回调函数

Node-API支持的数据类型和接口-使用Node-API实现跨语言交互-代码开发-NDK开发 | 华为开发者联盟 (huawei.com)


55、以下数据类型中,哪些是Sendable数据 。(不确定,题目代码又双叒叕给错了)

typescript 复制代码
import { lang } from '@kit.ArkTS';

class C {}

interface I extends lang.ISendable {}

A、interface I

B、class C

C、string

D、number



相关推荐
猫林老师2 天前
HarmonyOS数据持久化:Preferences轻量级存储实战
华为·harmonyos
Devil枫2 天前
鸿蒙深链落地实战:从安全解析到异常兜底的全链路设计
安全·华为·harmonyos
广州腾科助你拿下华为认证2 天前
华为考试:HCIE数通考试难度分析
大数据·华为
与天仙漫步星海2 天前
华为基本命令
华为
低调小一3 天前
Android传统开发 vs Android Compose vs HarmonyOS ArkUI 对照表
android·华为·harmonyos
猛码Memmat3 天前
华为HarmonyOS开发文档
华为·harmonyos
流影ng3 天前
【HarmonyOS】MVVM与三层架构
华为·架构·harmonyos
爱笑的眼睛113 天前
HarmonyOS Stage 模型与 ArkUI 声明式开发深度实践:构建高效稳定的应用
华为·harmonyos