Functions interview questions

20 questions. Tap “Show answer” to check yourself.

Advertisement
  1. ____ are the building blocks C++ programs.

    1. Switch
    2. For
    3. If-else
    4. Functions
    Show answer

    D. Functions

  2. How many types of scopes in C++?

    1. 2
    2. 3
    3. 4
    4. 5
    Show answer

    C. 4

  3. Which function executes faster but requires more memory space?

    1. Inline function
    2. Regular function
    3. Void function
    4. Normal function
    Show answer

    A. Inline function

  4. A variable declared above all blocks and functions has the ___

    1. Class scope
    2. Function scope
    3. Local scope
    4. Scope of a file
    Show answer

    D. Scope of a file

  5. The starting point for the execution of a program is ___

    1. Class
    2. Public
    3. Void ()
    4. Main()
    Show answer

    D. Main()

  6. The return type of the function prototype float power (float,.int) is ___

    1. Int
    2. Float
    3. Double
    4. Char
    Show answer

    B. Float

  7. The lifetime of a ___ variable is the life time of a program.

    1. Global scope
    2. Local scope
    3. File scope
    4. Function scope
  8. In call by value method, the flow of data is always from the ___ statement to the function definition.

    1. Call
    2. Return
    3. Function
    4. Go to
    Show answer

    A. Call

  9. A block of code begins and ends with ___

    1. {}
    2. []
    3. ()
    4. {]
    Show answer

    A. {}

  10. The scope of any variable used in the entire program is ___

    1. Class
    2. Function
    3. File
    4. Local
    Show answer

    C. File

  11. The lifetime of a ___ variable, is the life time of the function block.

    1. Function scope
    2. File scope
    3. Local scope
    4. Global scope
    Show answer

    A. Function scope

  12. A function can be invoked from another function using its ___

    1. Value
    2. Return
    3. Name
    4. Variables
    Show answer

    C. Name

  13. Advertisement
  14. The ___ reveals the hidden scope of a variable.

    1. ++
    2. *
    3. %
    4. Scope operator
    Show answer

    D. Scope operator

  15. In ___ a local variable is defined within a block.

    1. Class scope
    2. Local scope
    3. Function scope
    4. File scope
    Show answer

    B. Local scope

  16. The calling function parameters are called as ___

    1. Actual parameters
    2. Dummy parameters
    3. Duplicate parameters
    4. Formal parameters
    Show answer

    A. Actual parameters

  17. The functions that return no value is declared as ___

    1. Null
    2. Void
    3. Static
    4. Public
    Show answer

    B. Void

  18. In ___ method any change in the formal parameters is not reflected back to the actual parameter.

    1. Call by value
    2. Call by reference
    3. Call
    4. Return
    Show answer

    B. Call by reference

  19. The main purpose of function prototype is to help the ____ to check the data requirement of the function.

    1. Object
    2. Linker
    3. Interpreter
    4. Compiler
    Show answer

    D. Compiler

  20. An ___ looks like a normal function in the source file but inserts the function’s code directly into the calling program.

    1. Inline
    2. Online
    3. Mainline
    4. Line
    Show answer

    A. Inline

  21. Inline keyword is just a request to the ___

    1. Object
    2. Linker
    3. Interpreter
    4. Compiler
    Show answer

    D. Compiler

Advertisement