#1
What is the main purpose of a function in programming?
To execute a specific task or set of tasks
ExplanationFunctions perform defined tasks in code.
#2
In programming, what does the acronym 'DRY' stand for?
Don't Repeat Yourself
Explanation'DRY' promotes code reusability by avoiding redundancy.
#3
What is recursion in programming?
A function calling itself
ExplanationRecursion involves a function repeatedly calling itself.
#4
What is the difference between 'function declaration' and 'function expression' in JavaScript?
Function declaration is hoisted, while function expression is not
ExplanationFunction declarations are processed before execution, while expressions are not.
#5
What is the purpose of the 'super' keyword in object-oriented programming?
To call the constructor of the parent class
Explanation'super' invokes the parent class constructor from a subclass.
#6
What is polymorphism in object-oriented programming?
The ability of a class to have multiple methods with the same name but different implementations
ExplanationPolymorphism enables different classes to be treated uniformly.
#7
What is the purpose of the 'volatile' keyword in Java?
To indicate that a variable's value may be changed by multiple threads
Explanation'volatile' ensures visibility of shared variables across threads.
#8
What is the purpose of the 'try', 'catch', and 'finally' blocks in exception handling?
To handle and manage exceptions in a controlled manner
Explanation'try', 'catch', and 'finally' help manage exceptional situations.
#9
What is the role of the 'this' keyword in JavaScript?
To refer to the current object instance
Explanation'this' refers to the context in which a function is called.
#10
What is the purpose of the 'const' keyword in JavaScript?
To define a constant variable with a value that cannot be reassigned
Explanation'const' creates variables that cannot be reassigned.
#11
What is the role of an 'index' in the context of arrays?
To represent the position of an element in an array
ExplanationIndexes indicate the position of elements within arrays.
#12
What is a lambda function in programming?
An anonymous function
ExplanationLambda functions are unnamed and used for short tasks.
#13
What is the purpose of the 'yield' keyword in Python?
To pause the execution of a generator function
Explanation'yield' temporarily suspends execution and produces a value.
#14
What is method overloading in Java?
Creating multiple methods with the same name but different parameters in a class
ExplanationMethod overloading allows methods to have the same name but different parameters.
#15
In Python, what is the purpose of the 'with' statement?
To simplify exception handling using context managers
Explanation'with' provides a cleaner syntax for resource management.
#16
What is a closure in programming?
A function that has access to variables from its outer scope
ExplanationClosures retain access to their defining environment's variables.
#17
What is a design pattern in software development?
A standard solution to common programming problems
ExplanationDesign patterns offer proven solutions to recurring design problems.
#18
In C++, what is the 'virtual' keyword used for in relation to functions?
To indicate that a function may be overridden in a derived class
Explanation'virtual' functions can be redefined in derived classes.
#19
What is the difference between pass by value and pass by reference in programming?
Pass by value makes a copy of the actual parameter, while pass by reference passes the actual parameter itself
ExplanationPass by value sends a copy of the value; pass by reference sends the variable's location.
#20
What is memoization in the context of programming?
A technique to cache and reuse previously computed results to optimize function performance
ExplanationMemoization speeds up computation by storing previous results.
#21
In Python, what is the purpose of the 'map' function?
To apply a function to each item in an iterable and return a map object
Explanation'map' applies a function to each item in an iterable.
#22
What is method chaining in programming?
A technique where multiple methods are called in sequence on the same object
ExplanationMethod chaining simplifies code by executing methods consecutively.
#23
What is the 'Big O' notation used for in computer science?
To analyze the efficiency of algorithms and their growth rates
Explanation'Big O' notation quantifies algorithm efficiency.
#24
In object-oriented programming, what is encapsulation?
A process of bundling data and methods that operate on the data into a single unit
ExplanationEncapsulation hides implementation details, bundling data and methods.
#25
What is the purpose of the 'async' and 'await' keywords in JavaScript?
To execute asynchronous operations in a synchronous-looking manner
Explanation'async' and 'await' simplify asynchronous code in JavaScript.