Each question below shows the correct answer with a full explanation. Use these to build conceptual understanding before attempting a timed quiz.
Functions / MethodsEasy
Q1. What is a function in programming?
- A.A reusable block performing a specific task✓ Correct
- B.A loop that iterates over a collection
- C.A named variable storing data values
- D.A primitive or composite data type name
Explanation
A function is a named, reusable block of code designed to perform a particular task, promoting modularity.
Report an error in this question
Functions / MethodsEasy
Q2. What is a function parameter?
- A.A global variable accessible from anywhere
- B.A variable that receives a passed-in value✓ Correct
- C.The return value that a function produces
- D.The identifier name given to the function
Explanation
A parameter is a variable in the function definition that acts as a placeholder for the value passed when the function is called.
Report an error in this question
Functions / MethodsEasy
Q3. What does the return statement do?
- A.Declares a variable in the function scope
- B.Sends a value back and exits the function✓ Correct
- C.Terminates the entire running program
- D.Starts a new loop inside the function
Explanation
The return statement exits the function and optionally sends a value back to the calling code.
Report an error in this question
Functions / MethodsEasy
Q4. What is the difference between a parameter and an argument?
- A.A parameter is the actual value passed during the function call
- B.A parameter is in the definition; an argument is the passed value✓ Correct
- C.They are exactly the same thing with no differences at all
- D.An argument is defined in the function formal declaration only
Explanation
Parameters are variables in the function declaration; arguments are the actual values supplied when calling the function.
Report an error in this question
Functions / MethodsEasy
Q5. What is a void function?
- A.A function that takes no input parameters
- B.A function with an empty body and no code
- C.A function that does not return any value✓ Correct
- D.A function that is syntactically invalid
Explanation
A void function performs actions but does not return a value to the caller.
Report an error in this question
Functions / MethodsEasy
Q6. What is a function call?
- A.Writing the definition of a function
- B.Invoking a function to execute its code✓ Correct
- C.Removing a function from the program
- D.Adding a comment above a function
Explanation
A function call is the act of invoking a function by its name with any required arguments, causing its code to execute.
Report an error in this question
Functions / MethodsEasy
Q7. Can a function call another function?
- A.Only void functions can call other ones
- B.Only if they are defined in the same class
- C.No, functions cannot call other functions
- D.Yes, functions can call other functions✓ Correct
Explanation
Functions can call other functions, enabling code modularization and reuse.
Report an error in this question
Functions / MethodsEasy
Q8. What is a built-in function?
- A.A function provided by the language or library✓ Correct
- B.A function that you must always write yourself
- C.A function that calls itself recursively
- D.A function defined inside a loop construct
Explanation
Built-in functions are pre-defined functions provided by the language, such as print() in Python or Math.sqrt() in Java.
Report an error in this question
Functions / MethodsEasy
Q9. What is the main function?
- A.Any function found anywhere in the program source
- B.The last function that gets called before exiting
- C.The entry point of execution in languages like C/Java✓ Correct
- D.A mathematical function for numeric calculations
Explanation
The main function is the designated entry point where program execution begins in languages like C, C++, and Java.
Report an error in this question
Functions / MethodsEasy
Q10. What happens if a function is defined but never called?
- A.It causes an error
- B.It runs at the end
- C.It runs automatically
- D.Its code is never executed✓ Correct
Explanation
A function that is defined but never called simply exists in the code without being executed.
Report an error in this question
Functions / MethodsMedium
Q11. What is function overloading?
- A.Calling a function too many times in a row
- B.Same name functions with different parameter lists✓ Correct
- C.A runtime error from excessive function calls
- D.Calling a function from within itself recursively
Explanation
Function overloading allows multiple functions with the same name but different parameter types or counts, resolved at compile time.
Report an error in this question
Functions / MethodsMedium
Q12. What is the difference between pass by value and pass by reference?
- A.Pass by value copies data; pass by reference passes address✓ Correct
- B.Pass by value uses pointers to access the original variable
- C.Pass by reference is always slower than pass by value mode
- D.They are exactly the same thing with different names only
Explanation
Pass by value creates a copy of the argument; pass by reference passes the memory address, allowing the function to modify the original variable.
Report an error in this question
Functions / MethodsMedium
Q13. What is recursion?
- A.A function calling itself✓ Correct
- B.A loop construct
- C.An error in programming
- D.A type of variable
Explanation
Recursion is a technique where a function calls itself to solve a problem by breaking it into smaller subproblems.
Report an error in this question
Functions / MethodsMedium
Q14. What is a base case in recursion?
- A.The condition that stops recursion✓ Correct
- B.The recursive call itself in code
- C.An optional function parameter
- D.The very first function call made
Explanation
The base case is the condition that terminates recursion, preventing infinite recursive calls.
Report an error in this question
Functions / MethodsMedium
Q15. What is a lambda function?
- A.An anonymous short inline function expression✓ Correct
- B.A function that returns no value at all
- C.A function that calls itself recursively
- D.A function with an explicitly declared name
Explanation
A lambda function is an anonymous function that can be defined inline, often used for short operations like sorting comparators.
Report an error in this question
Functions / MethodsMedium
Q16. What is a callback function?
- A.A function that calls itself in a recursive way
- B.A function passed as an argument for later call✓ Correct
- C.A constructor that initializes object properties
- D.A function that contacts the user directly
Explanation
A callback is a function passed to another function as an argument, which is then invoked at a specific point or when an event occurs.
Report an error in this question
Functions / MethodsMedium
Q17. What is variable scope in the context of functions?
- A.The memory size of a variable in bytes
- B.The declared data type of the variable
- C.The current assigned value of a variable
- D.The region where a variable is accessible✓ Correct
Explanation
Scope defines where a variable is visible and accessible; local variables exist only within their function, while global variables are accessible everywhere.
Report an error in this question
Functions / MethodsMedium
Q18. What are default parameters?
- A.Parameters that are always initialized to zero
- B.Parameters whose values cannot ever be changed
- C.Parameters with values used when none is passed✓ Correct
- D.Parameters that the caller must always provide
Explanation
Default parameters have pre-assigned values that are used when the caller does not provide an argument for that parameter.
Report an error in this question
Functions / MethodsMedium
Q19. What is a higher-order function?
- A.A function with high computational time complexity
- B.A function defined in a higher-level parent class
- C.A function that accepts many input parameters
- D.A function that takes or returns other functions✓ Correct
Explanation
A higher-order function either accepts functions as parameters or returns a function, enabling functional programming patterns like map, filter, and reduce.
Report an error in this question
Functions / MethodsMedium
Q20. What is method signature?
- A.Only the access modifier of the declared method
- B.The complete body of the method implementation
- C.Only the return type of the declared method
- D.The method name combined with its parameter list✓ Correct
Explanation
A method signature consists of the method name and its parameter list (number, types, and order of parameters), used to uniquely identify the method.
Report an error in this question
Functions / MethodsHard
Q21. What is function currying?
- A.Overloading a function with additional parameter types
- B.Caching the results of previous function calls
- C.Optimizing a function for better performance
- D.Transforming multi-argument function into single-argument chain✓ Correct
Explanation
Currying transforms f(a, b, c) into f(a)(b)(c), where each function takes one argument and returns a function taking the next.
Report an error in this question
Functions / MethodsHard
Q22. What is memoization?
- A.Writing descriptive comments inside function body code
- B.Caching expensive function results to avoid recomputation✓ Correct
- C.Saving a function definition to persistent disk storage
- D.Allocating additional memory for function local variables
Explanation
Memoization stores previously computed results in a cache, returning the cached result when the same inputs occur again, improving performance.
Report an error in this question
Functions / MethodsHard
Q23. What is the difference between early binding and late binding?
- A.Early binding resolves at compile time; late binding at runtime✓ Correct
- B.There is no meaningful difference between the two approaches
- C.Early binding is always slower than late binding in all cases
- D.Late binding only works in the C programming language alone
Explanation
Early (static) binding resolves the function to call at compile time, while late (dynamic) binding defers resolution to runtime, enabling polymorphism.
Report an error in this question
Functions / MethodsHard
Q24. What is a variadic function?
- A.A function that has a variable return data type
- B.A function that returns multiple values at once
- C.A function that accepts no input parameters
- D.A function accepting variable number of arguments✓ Correct
Explanation
A variadic function accepts a variable number of arguments, like printf in C or functions using *args in Python.
Report an error in this question
Functions / MethodsHard
Q25. What is partial application?
- A.Fixing some arguments to produce a new function taking the rest✓ Correct
- B.Calling a function with completely wrong argument types or values
- C.A function that only partially works and fails on some inputs
- D.An incomplete function definition that is missing its body code
Explanation
Partial application fixes some arguments of a function, returning a new function that takes the remaining arguments.
Report an error in this question
Functions / MethodsHard
Q26. What is a thunk?
- A.A runtime error in the application
- B.A wrapper delaying computation evaluation✓ Correct
- C.A pre-allocated block of heap memory
- D.A particular type of variable binding
Explanation
A thunk is a parameterless function that wraps a computation to delay (defer) its evaluation until the result is actually needed.
Report an error in this question
Functions / MethodsHard
Q27. What are first-class functions?
- A.Functions assignable to variables and passable as arguments✓ Correct
- B.Functions that have the highest execution priority level
- C.Functions that belong to the main class of the program
- D.Functions that are defined first in source code order
Explanation
First-class functions are treated as values: they can be stored in variables, passed as arguments, and returned from other functions.
Report an error in this question
Functions / MethodsHard
Q28. What is the difference between a method and a function?
- A.Methods cannot return any values while functions always can
- B.Functions cannot accept any parameters while methods always can
- C.They are always the same thing in every programming language
- D.A method belongs to an object or class; a function is standalone✓ Correct
Explanation
A method is a function that belongs to a class or object and can access the object's state, while a standalone function is independent of any object.
Report an error in this question
Functions / MethodsHard
Q29. What is a generator function?
- A.A function that creates and returns other functions
- B.A function that yields multiple values over time lazily✓ Correct
- C.A function that generates random numbers on demand
- D.A constructor that initializes a new class instance
Explanation
A generator function uses yield to produce a sequence of values lazily, pausing after each yield and resuming when the next value is requested.
Report an error in this question
Functions / MethodsHard
Q30. What is the Y combinator?
- A.A fixed-point combinator enabling anonymous recursion✓ Correct
- B.A popular comparison-based sorting algorithm
- C.A well-known startup incubator company
- D.A commonly used structural design pattern
Explanation
The Y combinator is a higher-order function that enables anonymous functions to call themselves recursively in lambda calculus where functions have no names.
Report an error in this question