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

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


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

序号目录:


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

多选题题库 - 序号2


11、在ArkTS中,以下哪些属性的声明是正确的。

class C {

  value1: number = 0;

  value2?: number = null;

  value3: number | undefined = undefined;

  value4?: number;
  
}

A、value1

​ B、value2

C、value3

D、value4


12、如下ABC 3处手势,有机会执行的是哪几处?(不确定,把所有选项列出)

@Entry
@Component
struct ListTest {
  scroller: Scroller = new Scroller()
  scroller2: Scroller = new Scroller()
  scroller3: Scroller = new Scroller()
  private arr: number[] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
  private childRecognizer: GestureRecognizer = new GestureRecognizer()
  private currentRecognizer: GestureRecognizer = new GestureRecognizer()
  private lastOffset: number = 0

  build() {
    Stack({ alignContent: Alignment.TopStart }) {
      Scroll(this.scroller) {
        Column() {
          Text("Scroll Area")
            .width('90%')
            .height(150)
            .backgroundColor(0xFFFFFF)
            .borderRadius(15)
            .fontSize(16)
            .textAlign(TextAlign.Center)
            .margin({ top: 10 })
          List({ space: 20, initialIndex: 0 }) {
            ForEach(this.arr, (item: number) => {
              ListItem() {
                Text('' + item)
                  .width('100%')
                  .height(100)
                  .fontSize(16)
                  .backgroundColor(Color.Blue)
                  .textAlign(TextAlign.Center)
                  .borderRadius(10)
              }
            },
              (item: string) => item
            )
          }
          .listDirection(Axis.Vertical) // 排列方向
          .scrollBar(BarState.Off)
          .friction(0.6)
          .divider({
            strokeWidth: 2,
            color: 0xFFFFF,
            startMargin: 20,
            endMargin: 20
          }) //每行之间的分界线
          .edgeEffect(EdgeEffect.None) // 边缘效果设置为Spring
          .height(1000)
          .width('90%')
          .id("inner")
        }.width('100%')
      }
      .id("outer")
      .height(600)
      .scrollable(ScrollDirection.Vertical) // 滚动方向纵向
      .scrollBar(BarState.On) // 滚动条常驻显示
      .scrollBarColor(Color.Gray) // 滚动条颜色
      .scrollBarWidth(10) // 滚动条宽度
      .edgeEffect(EdgeEffect.None)
      .onScroll((xOffset: number, yOffset: number) => {
        console.info(xOffset + ' ' + yOffset)
      })
      .onScrollEdge((side: Edge) => {
        console.info('To the edge')
      })
      .onScrollStop(() => {
        console.info('Scroll Stop')
      })

      //  A
      /*.gesture(
        TapGesture({ count: 2 })
          .onAction((event: GestureEvent) => {
            if (event) {
              this.value = JSON.stringify(event.fingerList[0])
            }
          })
      )*/

      //  B
      /*.gesture(
        PanGesture({PanDirection.Vertical})
          .onActionUpdate((event: GestureEvent)=>{
            console.log("zcb onActionUpdate event offsetY " + event.offsetY + "this.lastOffset " + this.lastOffset)
          })
      )*/

      //  C
      /*.parallelGesture(
        PanGesture({PanDirection.Vertical})
          .onActionUpdate((event: GestureEvent)=>{
            console.log("zcb onActionUpdate event offsetY " + event.offsetY + "this.lastOffset " + this.lastOffset)
          })
      )*/

    }.width('100%').height('100%').backgroundColor(0xDCDCDC)
  }
}

A、NA

B、A

C、B

D、C


13、以下哪些实现方式可实现文本字号20的效果

// A
@Entry
@Component
struct Index {
  build() {
    Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Start, justifyContent: FlexAlign.SpaceBetween }) {
      Text('This is the text with the height adaptive policy set')
        .width('80%')
        .height(90)
        .minFontSize(20)
    }.width('100%').height(250).padding({ left: 35, right: 35, top: 35 })
  }
}
// B
@Entry
@Component
struct SpanExample {
  build() {
    Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Start, justifyContent: FlexAlign.SpaceBetween }) {
      Text() {
        Span('span letter spacing')
          .letterSpacing(3)
          .fontSize(20)
      }.fontSize(30)
    }.width('100%').height(250).padding({ left: 35, right: 35, top: 35 })
  }
}
// C
@Entry
@Component
struct Index {
  build() {
    Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Start, justifyContent: FlexAlign.SpaceBetween }) {
      //文本水平方向对齐方式设置
      //单行文本
      Text('TextAlign set to Center.')
        .textAlign(TextAlign.Center)
        .fontSize(20)
        .border({ width: 1 })
        .padding(10)
        .width('100%')
    }.height(600).width(350).padding({ left: 35, right: 35, top: 35 })
  }
}
// D
import { LengthMetrics, LengthUnit } from '@ohos.arkui.node'

@Entry
@Component
struct Index {
  fontStyleAttr: TextStyle = new TextStyle({fontSize:LengthMetrics.vp(20)});
  mutableStyledString: MutableStyledString = new MutableStyledString("hello", [{
    start: 0,
    length: 5,
    styledKey: StyledStringKey.FONT,
    styledValue: this.fontStyleAttr
  }]);
  controller: TextController = new TextController();

  async onPageShow() {
    this.controller.setStyledString(this.mutableStyledString)
  }

  build() {
    Column() {
      //显示属性字符串
      Text(undefined, { controller: this.controller })
    }.width('100%')
  }
}

​ A、A

B、B

C、C

​ D、D


14、依次点击A、B、C、D四个按钮,其中不会触发UI刷新的是:

@Entry
@Component
struct Index {
  @State count: number = 0;
  @State @Watch('onValueChange') value: number = 50;

  onValueChange() {
    this.count = this.value;
  }
  build() {
    Column() {
      Text(`${this.count}`)
      Button("A")
        .onClick(() => {
          this.count = 0;
        })
      Button("B")
        .onClick(() => {
          for (let i = 0; i < 1000; i++) {
            this.count = i;
          }
          for (let i = 1000; i > 0; i--){
            this.count = i;
          }
          this.count--;
        })
      Button("C")
        .onClick(() => {
          this.value = 100;
        })
      Button("D" )
        .onClick(() => {
          setInterval(()=>{
            this.count++;
          }, 1000)
        })
    }
  }
}

A、A

B、B

​ C、C

​ D、D


15、如何实现类似下图布局(不确定,把所有选项列出)

//	图略
//	A
@Entry
@Component
struct Demo {
  //忽略其他辅助代码
  dataSource: ItemDataSource = new ItemDataSource(100)
  itemHeightArray: number[] = []
  colors: number[] = [0xFFC0CB, 0xDA70D6, 0x6B8E23, 0x6A5ACD, 0x00FFFF, 0x00FF7F]
  scroller: Scroller = new Scroller()

  aboutToAppear() {
    this.getItemSizeArray()
  }

  build() {
    Scroll() {
      Column() {
        Grid() {
          GridItem() {
            Text('GoodsTypeList')
          }
          .backgroundColor(this.colors[0])

          GridItem() {
            Text('AppletService')
          }
          .backgroundColor(this.colors[1])

          GridItem() {
            Text('ReloadData')
          }
          .backgroundColor(this.colors[2])
        }
        .rowsGap(10)
        .columnsTemplate('1fr')
        .rowsTemplate('1fr 1fr 1fr')
        .width('100%')
        .height(100)
        .margin({
          top: 10,
          left: 5,
          bottom: 10,
          right: 5
        })

        Grid() {
          LazyForEach(this.datasource, (item: number) => {
            GridItem() {
              //使用可复用自定义组件
              ReusableItem({ item: item })
            }
            .width('100%')
            .height(this.itemHeightArray[item % 100])
            .backgroundColor(this.colors[item % 5])
          }, (item: number) => '' + item + this.itemHeightArray[item % 100])
        }
        .columnsTemplate("1fr 1fr")
        .columnsGap(10)
        .rowsGap(5)
        .width('100%')
        .nestedScroll({
          scrollForward: NestedScrollMode.PARENT_FIRST,
          scrollBackward: NestedScrollMode.SELF_FIRST
        })
      }
    }
    .scrollBar(BarState.Off)
    .edgeEffect(EdgeEffect.None)
  }
}
//	B
@Entry
@Component
struct Demo {
  //忽略其他辅助代码
  dataSource: ItemDataSource = new ItemDataSource(100)
  itemHeightArray: number[] = []
  colors: number[] = [0xFFC0CB, 0xDA70D6, 0x6B8E23, 0x6A5ACD, 0x00FFFF, 0x00FF7F]
  scroller: Scroller = new Scroller()

  @State sections: WaterFlowSections = new WaterFlowSections()
  sectionMargin: Margin = { top: 10, left: 5, bottom: 10, right: 5 }
  oneColumnSection: SectionOptions = {
    itemsCount: 3,
    crossCount: 1,
    rowsGap: 10,
    margin: this.sectionMargin,
    onGetItemMainSizeByIndex: (index: number) => {
      return this.itemHeightArray[index % 100]
    }
  }

  lastSection: SectionOptions = {
    itemsCount: 97,
    crossCount: 2,
    margin: this.sectionMargin,
    onGetItemMainSizeByIndex: (index: number) => {
      return this.itemHeightArray[index % 100]
    }
  }

  aboutToAppear() {
    this.setItemSizeArray()
    //	初始化瀑布流分组信息
    let sectionOptions: SectionOptions[] = []
    sectionOptions.push(this.oneColumnSection)
    sectionOptions.push(this.lastSection)
    this.sections.splice(0, 0, sectionOptions)
  }

  build() {
    WaterFlow({ scroller: this.scroller, sections: this.sections }) {
      LazyForEach(this.dataSource, (item: number) => {
        FlowItem() {
          ReusableFlowItem({ item: item })
        }
        .width('100%')
        .backgroundColor(this.colors[item % 5])
      }, (item: string) => item)
    }
    .columnsGap(10)
    .rowsGap(5)
    .backgroundColor(0xFAEEE0)
    .width('100%')
    .height('100%')
  }
}
//	C
@Entry
@Component
struct Demo {
  //忽略其他辅助代码
  dataSource: ItemDataSource = new ItemDataSource(100)
  itemHeightArray: number[] = []
  colors: number[] = [0xFFC0CB, 0xDA70D6, 0x6B8E23, 0x6A5ACD, 0x00FFFF, 0x00FF7F]
  scroller: Scroller = new Scroller()

  aboutToAppear() {
    this.getItemSizeArray()
  }

  build() {
    Column() {
      List({ scroller: this.scroller, space: 10 }) {
        ListItem(){
          Grid() {
            GridItem() {
              Text('GoodsTypeList')
            }.backgroundColor(this.colors[0])

            GridItem() {
              Text('AppletService')
            }.backgroundColor(this.colors[1])

            GridItem() {
              Text('ReloadData')
            }.backgroundColor(this.colors[2])
          }
          .rowsGap(10)
          .columnsTemplate('1fr')
          .rowsTemplate('1fr 1fr 1fr')
          .width('100%')
          .height(100)
        }

        ListItem() {
          WaterFlow(){
            LazyForEach(this.datasource, (item: number, index: number) => {
              FlowItem() {
                //使用可复用自定义组件
                ReusableItem({ item: item + index })
              }
              .width('100%')
              .height(this.itemHeightArray[item % 100])
              .backgroundColor(this.colors[item % 5])
            }, (item: number) => '' + item + this.itemHeightArray[item % 100])
          }
          .id('Waterflow')
          .columnsTemplate("1fr 1fr")
          .columnsGap(10)
          .rowsGap(5)
          .width('100%')
          .height('100%')
          .nestedScroll({
            scrollForward: NestedScrollMode.PARENT_FIRST,
            scrollBackward: NestedScrollMode.SELF_FIRST
          })
        }
      }
      .scrollBar(BarState.Off)
      .edgeEffect(EdgeEffect.None)
    }
    .width('100%')
    .padding({ left: 10, right: 10 })
  }
}

A、A

B、B

C、C


16、Code Linter针对ArkTS/TS代码进行最佳实践/编程规范方面的检查,最佳实践/编程规范方面的检查规则可以配置,针对codelinter的配 置项一下哪些说法是正确的

​ A、rules:可以基于ruleSet配置的规则集,新增额外规则项,但是无法修改ruleSet中规则默认配置

B、files:配置待检查的文件名单,如未指定目录,规则适用于所有文件,例如: [“**/*.ets”,“**/*.js”,“**/*.ts”]。

C、ignore:配置无需检查的文件目录,其指定的目录或文件需使用相对路径格式,相对于code-linter.json5所在工程根目录,例如:build/**/*。

D、ruleSet:配置检查使用的规则集,规则集支持一次导入多条规则。

代码Code Linter检查-代码检查-代码编辑-DevEco Studio | 华为开发者联盟 (huawei.com)


17、一个应用通常会包含多种功能,将不同的功能特性按模块来划分和管理是一种良好的设计方式。在开发过程中,我们可以将每个功能模块作为一个独立的Module进行开发,下面关于Module的说法正确的是

A、Library类型的Module,用于实现代码和资源的共享,有两种类型,分别为Static Library和Shared Library两种类型。

B、entry类型的Module,是应用的主模块,一个应用只能包含唯一一个entry类型的HAP。

C、Ability类型的Module,用于实现应用的功能和特性,有两种类型,分别为entry和feature。

D、feature类型的Module,应用的动态特性模块,一个应用中可以包含一个或多个feature类型的模块,也可以不包

应用程序包概述-应用程序包基础知识-开发基础知识-基础入门 | 华为开发者联盟 (huawei.com)


18、在大型软件工程中,一般会伴随着多团队开发,各团队开发自己的业务模块,最后再由集成交付团队集成到一起,下面哪些是大型应用模块化开发最佳实践

A、避免用户首次下载应用耗时过长,及过多占用用户空间,不常用功能做成按需加载。

​ B、若多个模块依赖了不同版本的HAR,使用OHPM的overrides机制配置指定使用哪个版本的HAR,以减少包大小。

C、使用路由表进行模块间解耦。

D、一次上架多端部署。


19、通过如下openLink的接口启动,如下哪些配置的UIAbility不可能被拉起(不确定,把所有选项列出)

import { hilog } from '@kit.PerformanceAnalysisKit';
import { UIAbility, common, OpenLinkOptions } from '@kit.AbilityKit';
import { BusinessError } from '@kit.BasicServicesKit';

export default class MyAbility extends UIAbility {
  onForeground() {
    let link: string = "https://www.example.com"
    let openLinkOptions: OpenLinkOptions = {
      applinkingOnly: true,
      parameters: {demo_key: "demo_value"}
    };
    try {
      this.context.openLink(
        link,
        openLinkOptions,
        (err, result) => {
          hilog.error(DOMAIN, TAG, 'openLink callback error.code:' + JSON.stringify(err));
        }
      ).then(()=>{
        hilog.info(DOMAIN, TAG, 'open link success.');
      }).catch((err: BusinessError)=>{
        hilog.error(DOMAIN, TAG, 'open link failed, errCode ' + JSON.stringify(err.code));
      })
    }
    catch (e) {
      hilog.error(DOMAIN, TAG, 'exception occured, errCode ' + JSON.stringify(e.code));
    }
  }
}
// A
{
	"name": "TargetAbility",
	"skills": [
		{
            "actions": [
            	"ohos.want.action.vieData",
            ],
            "entities": [
                "entity.system.browsable",
            ],
            "uris": [
                {
                    "scheme": "http",
                    "host": "www.test.com",
                    "port": "8080",
                    "path": "path"
                }			
            ]
    	}
	]
}
//	B
{
	"name": "TargetAbility",
	"skills": [
		{
            "actions": [
            	"ohos.want.action.viewData",
            ],
            "entities": [
                "entity.system.browsable",
            ],
            "uris": [
                {
                    "scheme": "https",
                    "host": "www.test.com",
                    "port": "8080",
                    "path": "path",
                    "autoVerify": ture
                }			
            ]
    	}
	]
}
//	C
{
	"name": "TargetAbility",
	"skills": [
		{
            "actions": [
            	"ohos.want.action.sendData",
            ],
            "entities": [
                "entity.system.browsable",
            ],
            "uris": [
                {
                    "scheme": "http",
                    "host": "www.test.com",
                    "port": "8080",
                    "path": "path",
                    "autoVerify": ture
                }			
            ]
    	}
	]
}
//	D
{
	"name": "TargetAbility",
	"skills": [
		{
            "actions": [
            	"ohos.want.action.SendData",
            ],
            "entities": [
                "entity.system.browsable",
            ],
            "uris": [
                {
                    "scheme": "https",
                    "host": "www.test.com",
                    "port": "8080",
                    "path": "path",
                     "autoVerify": ture
                }			
            ]
    	}
	]
}

A、A

B、B

C、C

D、D


20、某个应用的启动框架配置文件详细信息如下,以下说法正确的是:

{
    
    "startupTasks": [
        
        {

            "name": "StartupTask_001",

            "srcEntry": "./ets/startup/StartupTask_001.ets",

            "dependencies": [

                "StartupTask_002",

                "StartupTask_003"

            ],

            "runOnThread": "taskpool",

            "waitOnMainThread": false

        },
    
        {

            "name": "StartupTask_002",

            "srcEntry": "./ets/startup/StartupTask_002.ets",

            "dependencies": [

                "StartupTask_004"

            ],

            "runOnThread": "taskpool",

            "waitOnMainThread": false

        },

        {

            "name": "StartupTask_003",

            "srcEntry": "./ets/startup/StartupTask_003.ets",

            "runOnThread": "taskpool",

            "waitOnMainThread": false

        },
 
        {

            "name": "StartupTask_004",

            "srcEntry": "./ets/startup/StartupTask_004.ets",

            "runOnThread": "taskpool",

            "waitOnMainThread": false

        },
  
        {

            "name": "StartupTask_005",

            "srcEntry": "./ets/startup/StartupTask_005.ets",

            "runOnThread": "mainThread",

            "waitOnMainThread": true

        },
 
        {

            "name": "StartupTask_006",

            "srcEntry": "./ets/startup/StartupTask_006.ets",

            "runOnThread": "mainThread",

            "waitOnMainThread": false,

            ”excludeFromAutoStart": true

        }
	],
        
    "configEntry": "./ets/startup/StartupConfig.ets"
    
}

A、StartupTask_005会在主线程执行

B、StartupTask_006会在AbilityStage的onCreate前初始化完成

C、StartupTask_001会在StartupTask_004之后执行;

​ D、StartupTask_003会在StartupTask_004之后执行

应用启动框架AppStartup-Stage模型应用组件-Stage模型开发指导-Ability Kit(程序框架服务)-应用框架 | 华为开发者联盟 (huawei.com)


  • 5
    点赞
  • 13
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值