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

高级的题库更新之后,专业性更强了,不是真正从事这一行的,很难做出来。本人就是个小菜鸡,有一些题,我也不想不明白。题目的答案我尽可能的找到出处,如果读者发现错误或有补充建议,欢迎评论或私信笔者。笔者这篇就当抛砖引玉,各位读者可以当作考试的一个参考

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


注:有读者反馈,题库的代码块比较多,打开文章时会卡死。所以笔者将题库拆分,以20道题为一组,题库目录如下,读者可以按需跳转。如果对您的阅读产生不便,笔者在这里向大家说声抱歉,请各位读者原谅。该题库已整理完毕,笔者不再更新。笔者连续考了三次,都过了,所以答案应该没什么太大问题。有需要题库文档的可以自取。祝各位读者好运(๑¯ω¯๑)。

序号目录:


题库文档链接(自取):https://pan.baidu.com/s/153tDk4dVv_MmLEyzOqW9hQ?pwd=xkgr


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

单选题题库 - 序号3


41、在方舟字节码的函数调用规范中,前三个参数表示的含义分别是

​ A、new.Target、this、函数对象本身

​ B、this、函数对象本身、new.Target

​ C、new.Target、函数对象本身、this

D、函数对象本身、new.Target、this

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


42、下面关于方舟字节码格式IMM16_ID16_IMM8描述正确的是

A、8位操作码,16位立即数,16位id,8位立即数

​ B、8位操作码,16位立即数,2个8位寄存器

​ C、8位操作码,16位立即数,16位id,8位寄存器

​ D、16位前缀操作码,16位立即数,8位寄存器

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


43、以下关于垂直滚动Grid组件使用cachedCount属性的说明正确的是

A、设置cachedCount为1,则Grid在显示范围上下各缓存1个Gridltem

​ B、设置cachedCount为1,则Grid在显示范围上下各缓存1行Gridltem

​ C、设置cachedCount为1,则Grid在显示范围下方缓存1行Gridltem

​ D、设置cachedCount为1,则Grid在显示范围下方缓存1个Gridltem

Grid-容器组件-ArkTS组件-ArkUI(方舟UI框架)-应用框架 - 华为HarmonyOS开发者 (huawei.com)


44、从桌面冷启动如下应用代码,点击Change按钮5次,整个过程中,代码中的2条log依次出现的次数是:(不确定,把所有选项列出)

class Data {
  num: number
  type: string

  constructor(num: number, type: string) {
    this.num = num;
    this.type = type;
  }
}

@Reusable
@Component
struct Item {
  @State data: Data | undefined = undefined;

  aboutToAppear(): void {
    console.log("Demo log1");
  }

  aboutToReuse(params: ESObject): void {
    console.log("Demo 1og2");
    this.data = params.data
  }

  build() {
    Text("num = " + this.data?.num + ", type = " + this.data?.type)
  }
}

@Entry
@Component
struct Index {
  data1: Data = new Data(1, "type1");
  data2: Data = new Data(2, "type2");
  @State data: Data = this.data1

  build() {
    Column() {
      if (this.data.type == "type1") {
        Item({ data: this.data }).reuseId(this.data.type)
      } else {
        Item({ data: this.data }).reuseId(this.data.type)
      }
      Button('Change').onClick(() => {
        if (this.data === this.data1) {
          this.data = this.data2
        } else {
          this.data = this.data1
        }
      })
    }
  }
}

A、2,4

B、6,0

C、1,0

D、1,5


45、以下哪份代码可以实现下图Grid布局

在这里插入图片描述

//	A、通过设置Gridltem的columnStart和columnEnd
@Entry
@Component
struct GridExample3 {
  numbers: String[] = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
  scroller: Scroller = new Scroller()

  build() {
    Column({ space: 5 }) {
      Grid(this.scroller) {
        ForEach(this.numbers, (day: string) => {
          if (day === '0' || day === '5') {
            GridItem() {
              Text(day)
                .fontSize(16)
                .backgroundColor(0xF9CF93)
                .width('100%')
                .height(80)
                .textAlign(TextAlign.Center)
            }.columnStart(1).columnEnd(4)
          } else {
            GridItem() {
              Text(day)
                .fontSize(16)
                .backgroundColor(0xF9CF93)
                .width('100%')
                .height(80)
                .textAlign(TextAlign.Center)
            }
          }
        }, (day: string) => day)
      }
      .columnsTemplate('1fr 1fr 1fr 1fr')
      .columnsGap(10)
      .rowsGap(10)
      .scrollBar(BarState.Off)
      .width('100%')
      .backgroundColor(0xFAEEE0)
      .height(350)
    }
  }
}
//	B、通过设置不同Gridltem的宽度
@Entry
@Component
struct GridExample3 {
  numbers: String[] = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
  scroller: Scroller = new Scroller()
  columnGap: number = 10
  gridItemWidth: number = 80

  build() {
    Column({ space: 5 }) {
      Grid(this.scroller) {
        ForEach(this.numbers, (day: string) => {
          if (day === '0' || day === '5') {
            GridItem() {
              Text(day)
                .fontSize(16)
                .backgroundColor(0xF9CF93)
                .width(this.gridItemWidth * 4 + this.columnGap * 3)
                .height(80)
                .textAlign(TextAlign.Center)
            }
          } else {
            GridItem() {
              Text(day)
                .fontSize(16)
                .backgroundColor(0xF9CF93)
                .width(this.gridItemWidth)
                .height(80)
                .textAlign(TextAlign.Center)
            }
          }
        }, (day: string) => day)
      }
      .columnsTemplate('1fr 1fr 1fr 1fr')
      .columnsGap(this.columnGap)
      .rowsGap(10)
      .scrollBar(BarState.Off)
      .width('100%')
      .backgroundColor(0xFAEEE0)
      .height(350)
    }
  }
}
//	C、通过GridLayoutOptions
@Entry
@Component
struct GridExample3 {
  numbers: String[] = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
  scroller: Scroller = new Scroller()
  layoutOptions1: GridLayoutOptions = {
    regularSize: [1, 1],
    irregularIndexes: [0, 5],
  }

  build() {
    Column({ space: 5 }) {
      Grid(this.scroller, this.layoutOptions1) {
        ForEach(this.numbers, (day: string) => {
          GridItem() {
            Text(day)
              .fontSize(16)
              .backgroundColor (0xF9CF93)
              .width('100%')
              .height(80)
              .textAlign(TextAlign.Center)
          }
        }, (day: string) => day)
      }
      .columnsTemplate('1fr 1fr 1fr 1fr')
      .columnsGap(10)
      .rowsGap(10)
      .scrollBar(BarState.Off)
      .width('100%')
      .backgroundColor(0xFAEEE0)
      .height(350)
    }.align(Alignment.Center)
  }
}

​ A、通过设置Gridltem的columnStart和columnEnd

​ B、通过设置不同Gridltem的宽度

C、通过GridLayoutOptions


46、已知下列代码PageOne页面为navigation中的某一子页面,依次点击PageOne页面中toPageTwo按钮,PageTwo页面中toPageOne按钮,此时获取当前页面的路由栈数量为多少(不确定,把所有选项列出)

// PageOne.ets
@Component
export struct PageOneTmp {
  @Consume('pageInfos') pageInfos: NavPathStack;

  build() {
    NavDestination() {
      Column() {
        Button('toPageTwo', { stateEffect: true, type: ButtonType.Capsule })
          .width('80%')
          .height(40)
          .margin(20)
          .onClick(() => {
            this.pageInfos.pushPathByName('pageTwo',"")
          })
      }.width('100%').height('100%')     
    }.title('pageOne')
    .onBackPressed(() => {
      const popDestinationInfo = this.pageInfos.pop()
      console.log('pop返回值' + JSON.stringify(popDestinationInfo))
      return true
    })
  }
}
// PageTwo.ets
export class Pages{
  names: string = ""
  values: NavPathStack | null = null
}

@Builder
export function pageTwoTmp(info: Pages){
  NavDestination() {
    Column(){
      Button('toPageOne', { stateEffect: true, type: ButtonType.Capsule })
        .width('80%')
        .height(40)
        .margin(20)
        .onClick(() => {
          (info.values as NavPathStack).pushPathByName('pageOne', null)
        })
    }.width('100%').height('100%')
  }.title('pageTwo')
  .onBackPressed(() => {
    (info.values as NavPathStack).pop()
    return true
  })
}

A、1

B、2

C、3

D、4


47、在HarmonyOS应用开发中,当开发者遇到需要分析Release版本应用的崩溃或异常堆栈信息时,为了准确地将堆栈追踪信息对应到源代码的具体位置,以下哪个描述是正确的做法或理解

​ A、开发者需手动将Release构建生成的so文件与源代码进行映射,配合第三方工具进行堆栈信息还原,虽然过程繁琐,但最终能定位到问题代码位置

​ B.因为Release应用经过优化和去除Debug信息 ,直接从堆栈跟踪到源代码行号是不可能的,开发者只能依靠日志信息手工推测问题所在

C、DevEco Studio提供的Release应用堆栈解析功能,要求开发者在遇到问题时,需上传构建产物中的特定文件(如so、source map、nameCache等)到指定工具或界面,借助这些文件辅助解析堆栈信息,实现从Release堆栈到源码的映射,便于快速定位问题

​ D、DevEco Studio通过集成的Release应用堆栈解析功能,自动利用构建时产生的so文件、source map文件、nameCache文件等,无需额外操作即可直接在Release应用中提供详细的源码级堆栈追踪信息

堆栈轨迹分析-故障分析-应用/服务调试-DevEco Studio | 华为开发者联盟 (huawei.com)


48、小李正在使用DevEco Studio进行Harmony0S应用的开发工作,他需要对一个频繁被调用的函数calculateData()进行重构,为了帮助小李高效地找到calculateData()函数的所有引用位置,并确保重构时考虑周全,以下哪个步骤是正确的使用DevEco Studio的“Find Usages”功能的操作方法

​ A、小李应将光标置于calculateData()函数的名称上,按下Ctrl + Shift + F(macOS为Command + Shift + F)全局搜索该函数名,然后在搜索结果中筛选出真正的调用位置。

​ B、小李应该在菜单栏中选择“Navigate” > “Class”来打开类浏览器, 从中找到calculateData()函数, 并在此界面中手动检查所有引用。

C、小李只需将光标定位在calculateData()函数名上,右键点击并选择“Find Usages",或者直接使用快捷键Alt+ F7(macOS为Option+ F7),DevEco Studio会自动列出该函数在项目中的所有引用位置。

​ D、小李应当在项目目录树中找到calculateData()函数所在的文件, 直接双击打开文件,然后逐行扫描代码以手动查找该函数的所有调用位置。

代码阅读-代码编辑-DevEco Studio | 华为开发者联盟 (huawei.com)


49、在使用DevEco Studio的Profiler进行HarmonyOS应用或服务性能分析时,面对应用出现卡顿、加载慢等性能瓶颈问题,以下哪个描述最贴切地说明了“Time场景分析任务”的功能及其对开发者优化流程的帮助

​ A、Time场景分析任务仅提供应用/服务运行时的CPU使用率概览,帮助开发者粗略判断性能瓶颈,但不提供深入分析

​ B、Time场景分析任务专注于内存管理,帮助开发者监控应用内存泄漏,但对解决卡顿和加载耗时问题帮助有限

​ C、Time场景分析任务在应用运行时,通过显示所有函数执行的耗时排序列表,辅助开发者手动对比寻找耗时最短的函数进行优化

D、Time场景分析任务展示热点区域内的CPU和进程级调用栈耗时情况,支持代码跳转,助力开发者快速定位并优化耗时较长的代码段

基础耗时分析:Time分析-性能分析-DevEco Studio | 华为开发者联盟 (huawei.com)


50、开发者小林正在使用DevEco Studio开发一款HarmonyOS应用, 并在真机上进行调试。他在运行应用的过程中突然发现一处UI布局需要微调,希望在不中断当前应用运行的情况下看到调整效果,基于DevEco Studio提供的Hot Reload (热重载)能力,以下哪一种做法能让小林最有效地实现他的需求

​ A、继续运行应用,手动重启应用后检查布局是否符合预期

B、在不关闭应用的情况下,直接修改代码并保存,借助Hot Reload功能在真机上实时查看布局调整的效果

​ C、使用模拟器替代真机进行调试,因为Hot Reload仅在模拟器上支持代码改动的即时生效

​ D、立即停止应用,修改代码后重新编译并部署到真机上

Hot Reload-代码调试-应用/服务调试-DevEco Studio | 华为开发者联盟 (huawei.com)


51、项目需要为不同的设备形态(如手机、智能手表)提供定制化构建。请说明如何在DevEco studio中设置不同的构建配置,以生成针对不同设备的hap包?(不确定,把所有选项列出)

A、在工程级别build-profile.json5定义多个product,在每个product的config/distributionFilter中定义不同的设备类型

B、在工程级别build-profile.json5定义多个product,在每个product的config/deviceType中定义不同的设备类型

C、在模块级别build-profile.json5定义多个target,在每个target的config/deviceType中定义不同的设备类型

D、在模块级别build-profile.json5定义多个target,在每个target的config/distributionFilter中定义不同的设备类型


52、一个复杂的项目,该项目不仅包含主入口模块(Entry Module),还有多个特性的功能模块(Feature Modules/HSP),并且这些模块存在着相互调用关系。为了确保在调试过程中能够完整地测试所有交互逻辑,需要将涉及到的所有模块的HAP包都部署到目标设备上。请从以下选项中选择正确的操作步骤来配置DevEco Studio,以便一次性部署和调试项目中的多个模块

​ A、无需特殊配置,DevEco Studio会自动检测到项目中的所有模块依赖,并在每次调试运行时自动部署所有相关HAP包。

​ B、在项目结构界面手动选择每个模块,单独编译并逐一将生成的HAP包通过HDC命令推送到设备上。

C、进入“Run > Edit Configurations”菜单,“Deploy Multi Hap”选项卡下,勾选“Deploy Multi Hap Packages”,随后在列表中选择需要部署的模块。

​ D、直接点击运行按钮,DevEco Studio会弹出对话框询问需要部署哪些模块,从中选择需要的模块后开始调试。

自定义运行/调试配置-应用/服务调试-DevEco Studio | 华为开发者联盟 (huawei.com)


53、项目中涉及多个类的继承与重写。为了快速实现子类对父类方法的重写,小华想利用DevEco Studio提供的便捷功能来提高开发效率。他了解到,通过一个特定的操作流程,可以直接依据父类的模板生成子类中需要重写的方法代码,而无需手动编写完整方法体,在DevEco Studio中,如何正确使用Override Methods功能来快速生成子类需要重写的方法代码

​ A、将光标放置于任何代码行,按下Ctrl+B,然后在弹出菜单中选择Override Methods,之后勾选需要重写的方法并确认。

​ B、在项目结构视图中找到目标子类,双击打开后直接在代码编辑区输入重写方法的签名,DevEco Studio将自动完成剩余代
码。

​ C、通过菜单栏File > Settings,配置Override Methods快捷方式,之后在代码中仅需选中父类方法名,即可自动在子类中生
成重写代码。

D、将光标定位到子类的定义处,按下Ctrl+O(或右键单击选择Generate... > Override Methods),在弹出的对话框中选择 要重写的方法,点击OK完成生成。


54、下面的配置存在有几处错误()

//	module.json5配置文件:
{
	"module": {
		"name": "entry",
		// ...
		"abilities": [
			{
				"name": "EntryAbility",
				"srcEntry": "./ets/entryability/EntryAbility.ets",
				// ...
				"skills": [
					{
						"entities": [
							"entity.system.home"
						],
						"actions": [
							"ohos.want.action.home"
						]
					}
				],
				"metadata": [
					{
						"name": "ohos.entry.shortcuts",
						"resource": "$profile:shortcuts_config"
					}
				]
			}
		]
    }
}
//	在/resources/base/profile/目录下配置shortcuts_config.json配置文件:
{
	"shortcuts": [
		{
			"shortcutId": "id_test1",
            //	==========================	【shortcutLabel】字符串不符合匹配规则
			"label": "shortcutLabel",
			"icon": "$media:shortcutIcon",
			"wants": [
				{
					"bundleName": "com.ohos.hello",
					"moduleName": "entry",
					"abilityName": "EntryAbility"
				}
			]
		}
	]
}

A、1

​ B、2

​ C、3

​ D、4

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


55、下面的配置存在有几处错误()(不确定,把所有选项列出)

//	app.json5配置文件:
{
  "app": {

    "bundleName": "com.example.myapplication",

    "vendor": "example",

    "versionCode": 1000000,

    "versionName": "1.0.2",

    "icon": "$media:app_icon",

    "label": "$string:app_name",

    "bundleType": "app"
  }
}
// module.json5配置文件:
{
    
	"module": {
        
		"name": "feature",

   		//...
        
		"atomicService": {
        
			"preloads":[
            
				{
                
					"moduleName": "feature"
                
				}
			]
		}
	}
}

A、1

B、2

C、3

D、4

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

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


56、(1)在UIAbility的onCreate生命周期中通过EventHub的on注册“event1”和“event2”事件。

import { hilog } from '@kit.PerformanceAnalysisKit';
import { UIAbility, Want, AbilityConstant } from '@kit.AbilityKit';

const DOMAIN_NUMBER: number = 0xFF00;
const TAG: string = '[EventAbility]';

export default class EntryAbility extends UIAbility {

  onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void {

    //获取UlAbility实例的上下文
    let context = this.context;

    //获取eventHub
    let eventhub = this.context.eventHub;

    //执行订阅操作
    eventhub.on('event1', this.eventFunc);
    eventhub.on('event2', this.eventFunc);

    hilog.info(DOMAIN_NUMBER, TAG, '%{public}s', 'Ability onCreate');
  }

  // ..

  eventFunc(argOne: Context, argTwo: Context): void {
    hilog.info(DOMAIN_NUMBER, TAG, 'receive.' + `${argOne},${argTwo}`);
    return;
  }

}

(2)在UI组件的click处理事件中调用如下的eventHubFunc,连续点击2次该控件后,运行日志输出是什么:

// 题目获取上下文的方式是错的,要导这个common包才行
import common from '@ohos.app.ability.common';
import { promptAction } from '@kit.ArkUI';

@Entry
@Component
struct Page_EventHub {

  private context = getContext(this) as common.UIAbilityContext;

  eventHubFunc(): void {
    this.context.eventHub.emit('event1');
    this.context.eventHub.emit('event2', 2, 'test2');
    this.context.eventHub.off('event1');
  }

  build() {
    Column() {
      //...
      List({ initialIndex: 0 }) {
        ListItem() {
          Row() {
            //...
          }
          .onClick(() => {
            this.eventHubFunc();
            promptAction.showToast({
              message: $r('app.string.EventHubFuncA')
            });
          })
        }
      }
      //...
    }
    //...
  }
}

​ A、

[Example].[Entry].[EntryAbility] receive. []
[Examp1e].[Entry].[EntryAbility] receive. [2,"test2" ]
[Examp1e].[Entry].[EntryAbility] receive. []
[Example].[Entry].[EntryAbility] receive. [2,"test2"]

B、答案↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓

[Example].[Entry].[EntryAbility] receive. []
[Example].[Entry].[EntryAbility] receive. [2,"test2"]
[Examp1e].[Entry].[EntryAbility] receive. [2,"test2"]

​ C、

[Examp1e].[Entry].[EntryAbility] receive. []
[Example].[Entry].[EntryAbility] receive. [2,"test2"]

​ D、

[Example].[Entry].[EntryAbility] receive. []
[Example].[Entry].[EntryAbility] receive. [2,"test2"]
[Example].[Entry].[EntryAbility] receive. []

57、singleton模式的UIAbility,在冷启动时生命周期的执行顺序是:

A、onCreate->onWindowStageCreate->onForeground

​ B、onCreate->onBackground->onForeground

​ C、onCreate ->onForeground->onWindowStageCreate

​ D、onCreate->onBackground->onWindowStageCreate

UIAbility组件生命周期-UIAbility组件-Stage模型应用组件-Stage模型开发指导-Ability Kit(程序框架服务)-应用框架 | 华为开发者联盟 (huawei.com)


58、开发者开发了一个应用,该应用只有一个hap包,其module.json5中abilities的配置如下所示,包含1个UlAbility(无Web组件)、1个FormExtensionAbility组件 、1个WorkSchedulerExtensionAbility组件,那么该应用在运行过程中,最多会存在几个应用进程:(不确定,把所有选项列出)

"abilities": [
    
	{
        
		"name": "EntryAbility",
        
		"srcEntry": "./etc/entryability/EntryAbility.ts",
        
		"description": "$string:EntryAbility_desc",
        
		"exported": ture
        
	}
    
],
    
"extensionAbilities": [
    
	{	
        
		"name": "ClockFormExtensionAbility",
        
		"srcEntrance": "./ets/form/ClockFormExtensionAbility.ts",
    	    
		"type": "form"
        
	},
    
	{
        
		"name": "TipWorkSchedulerExtensionAbility",

		"srcEntrance": "./ets/service/TipWorkSchedulerExtensionAbility.ts",
        
		"type": "workScheduler"
        
	}
    
]

A、1个

B、2个

C、3个

D、4个


59、hiAppEvent提供的Watcher接口,需要订阅到OS的崩溃事件,正确的实现方式()

//	A
hiAppEvent.addWatcher({
	name: "watcher",
	appEventFilters: [
        {
			names: [hiAppEvent.event.APP_FREEZE]
        }
	],
	onReceive: (domain: string, appEventGroups: Array<hiAppEvent.AppEventGroup>) => {
	}
})
//	B
hiAppEvent.addWatcher({
	name: "watcher",
	onReceive: (domain: string, appEventGroups: Array<hiAppEvent.AppEventGroup>) => {
	}
})
//	C
hiAppEvent.addWatcher({
	name: "watcher",
	appEventFilters: [
		{
			domain: hiAppEvent.domain.OS,
			names: [hiAppEvent.event.APP_CRASH]
		}
	],
	onReceive: (domain: string, appEventGroups: Array<hiAppEvent.AppEventGroup>) => {
	}
})
//	D
hiAppEvent.addWatcher({
	name: "watcher",
	appEventFilters: [
		{
			domain: hiAppEvent.domain.OS,
			names: [hiAppEvent.event.APP_CRASH]
		}
	]
})

​ A、A

​ B、B

C、C

​ D、D

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


60、当标记了@Reuseable的自定义组件实现了组件复用后,这个组件的复用范围是什么?

​ A、标记了@Reuseable的自定义组件的外层容器节点范围内

B、标记了@Reuseable的自定义组件的父组件范围内

​ C、整个页面都可以复用

​ D、整个应用内都可以复用

组件复用最佳实践-开发高性能ArkUI-性能优化-性能 | 华为开发者联盟 (huawei.com)


评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值