题目详情

已知函数f( )、g( )的定义如下所示,调用函数f时传递给形参x的值是5。若g(a)采用引用调用(callbyreference)方式传递参数,则函数f的返回值为(请作答此空);若g(a)采用值调用(callbyvalue)的方式传递参数,则函数f的返回值( )。其中,表达式“x>>1”的含义是将x的值右移1位,相当于x除以2。

中级软件设计师,模拟考试,2021年软件设计师模拟题2

  • A.35
  • B.32
  • C.11
  • D.7

正确答案及解析

正确答案
C
解析

传值调用:形参取的是实参的值,形参的改变不会导致调用点所传的实参的值发生改变。引用(传址)调用:形参取的是实参的地址,即相当于实参存储单元的地址引用,因此其值的改变同时就改变了实参的值。本题中,a=x>>1,x值为5,则 a=2;采用传值调用时,由于 g(a)对数据x的运算不会影响原来x的值,所以a+x=5+2=7;采用传值调用时,由于 g(a)对数据x的运算会影响原来x的值,当执行g(a)后x的值为6,所以a+x=5+6=11 。

包含此试题的试卷

你可能感兴趣的试题

单选题

Advancements in ( )have contributed to the growth of the automotive industry through the creation and evolution of self-driving vehicles.

  • A.Artificial Intelligence
  • B.Cloud Computing
  • C.Internet of Things
  • D.Big Data
查看答案
单选题

In project human resource management , ( )is not a source of power for the project manager.

  • A.referent power
  • B.expert power
  • C.reward power
  • D.audit power
查看答案
单选题

At the project establishment stage , the feasibility study mainly includes techinical feasibility analysis , ( ), operation environment feasibility analysis and other aspects of feasibility analysis.

  • A.detail feasibility analysis
  • B.opportunity analysis
  • C.economic feasibility analysis
  • D.risk analysis
查看答案
单选题

( )is a grid that shows the project resources assigned to each work package.

  • A.Stakeholder engagement assessment matrix
  • B.Requirements traceability matrix
  • C.Probability and impact matrix
  • D.Responsibility assignment matrix
查看答案
单选题

Xinhua News Agency reported in January 2022,Chian will further promote the developmet of a digital economy during the 14th Five-Year Plan eriod(2021-2025). The plan also emphasized industrial ( )transformation.

  • A.digital
  • B.networking
  • C.intelligentize
  • D.informatization
查看答案

相关题库更多 +