nerdexam
CompTIA

FC0-U61 · Question #577

Which of the following works BEST if code needs to be reused or called by other pieces of code?

The correct answer is A. Function. A function works best if a block of code needs to be reused or called by other pieces of code.

Software Development

Question

Which of the following works BEST if code needs to be reused or called by other pieces of code?

Options

  • AFunction
  • BAnonymous block
  • CDeclaration
  • DFormula

How the community answered

(43 responses)
  • A
    91% (39)
  • B
    5% (2)
  • C
    2% (1)
  • D
    2% (1)

Why each option

A function works best if a block of code needs to be reused or called by other pieces of code.

AFunctionCorrect

Functions allow developers to define a set of instructions once and then invoke that set of instructions by calling the function's name whenever needed. This promotes modularity, reusability, and reduces code duplication by encapsulating specific tasks into named, callable blocks.

BAnonymous block

An anonymous block is a block of code that is not named and cannot be directly called or reused elsewhere by name; it executes once where it is defined.

CDeclaration

A declaration is used to state the name and type of a variable, function, or other entity, but it does not represent an executable, reusable block of code itself.

DFormula

A formula typically refers to an expression or equation used to calculate a value, not a reusable block of executable code.

Concept tested: Programming concepts - functions for reusability

Source: https://learn.microsoft.com/en-us/dotnet/csharp/programming-guide/classes-and-structs/methods

Topics

#Code reusability#Functions#Programming constructs

Community Discussion

No community discussion yet for this question.

Full FC0-U61 Practice