Explore topic-wise InterviewSolutions in .

This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.

1.

What does the first parameter of the main function represent?(a) Number of command line arguments(b) List of command line arguments(c) Dictionary of command line arguments(d) Stack of command line argumentsThe question was asked during an online interview.The question is from Command Line Arguments topic in section C++ Advanced of C++

Answer»

The correct answer is (a) Number of command LINE arguments

The explanation is: The FIRST ARGUMENT of the main() function REPRESENTS the number of command line arguments that are PASSED.

2.

In how many ways we can capture the external variables in the lambda expression?(a) 1(b) 2(c) 3(d) 4This question was posed to me by my school principal while I was bunking the class.The question is from Lambda Expressions topic in portion C++ Advanced of C++

Answer»

The CORRECT ANSWER is (c) 3

To EXPLAIN: There are three WAYS in which we can capture the external VARIABLES inside the lambda expression namely capture by reference, capture by value and capture by both that is mixed capture.

3.

To use command line arguments in C++, how many parameters are passed to the main function?(a) 1(b) 2(c) 3(d) 4I have been asked this question during an interview for a job.Question is taken from Command Line Arguments topic in chapter C++ Advanced of C++

Answer»

The correct answer is (b) 2

The explanation is: 2 ARGUMENTS are needed to be PASSED to main() FUNCTION while using command line arguments. The first one represents a number of strings in the argument LIST and the second list represents the list of string arguments.

4.

Which of the following operator is used to capture all the external variable by value?(a) &(b) =(c) *(d) &&I have been asked this question in unit test.I want to ask this question from Lambda Expressions in chapter C++ Advanced of C++

Answer»

Correct answer is (b) =

Explanation: The LAMBDA EXPRESSION USES = operator to capture the external VARIABLE by VALUE.

5.

What is the syntax of defining lambda expression?(a) [capture clause](parameters) -> return_type { body of the function }(b) [parameters](capture clause) -> return_type { body of the function }(c) [parameters:capture clause]() -> return_type { body of the function }(d) [capture clause:parameters]() -> return_type { body of the function }I had been asked this question in an interview.My query is from Lambda Expressions topic in portion C++ Advanced of C++

Answer»

Correct answer is (a) [capture CLAUSE](parameters) -> return_type { body of the FUNCTION }

The best explanation: The correct syntax of DEFINING a lambda expression is GIVEN below:

6.

What are command line arguments?(a) Arguments passed to main() function(b) Arguments passed to any function(c) Arguments passed to class functions(d) Arguments passed to structure functionsI got this question during an interview.My question is from Command Line Arguments in section C++ Advanced of C++

Answer»

Correct option is (a) ARGUMENTS passed to main() FUNCTION

Easy explanation - COMMAND line arguments are the arguments that passed to the main function when the program is starting its EXECUTION.

7.

What is the correct statement about lambda expression?(a) The return type of lambda expression can be neglected in some cases(b) The return type of lambda expression must be specified in all cases(c) Lambda expression should be very large functions(d) Lambda expression is also available in CThis question was posed to me in an interview for internship.This intriguing question comes from Lambda Expressions in division C++ Advanced of C++

Answer»

Correct answer is (a) The return type of lambda expression can be neglected in some cases

Explanation: Return type in lambda expression can be ignored in some cases as the COMPILER will itself FIGURE that out but not in all cases. Lambda expression is used to define small FUNCTIONS, not large functions. Lambda expression is introduced in C++.

8.

What is the signature of math in function using command line arguments?(a) int main(int argc, char const *argv[]);(b) int main(int argc, char const **argv);(c) int main(int argc, char **argv);(d) all of the mentionedThis question was posed to me in examination.This interesting question is from Command Line Arguments in portion C++ Advanced of C++

Answer»

Right ANSWER is (d) all of the mentioned

Easy explanation - Any of the above signature can be USED while USING command LINE arguments in C++ programs.

9.

Which of the following operator is used to capture all the external variable by reference?(a) &(b) =(c) *(d) &&The question was asked during an interview.This intriguing question originated from Lambda Expressions topic in portion C++ Advanced of C++

Answer»

The correct option is (a) &

The best explanation: The LAMBDA expression uses & operator to capture the EXTERNAL variable by REFERENCE.

10.

What is lambda expression in C++?(a) A technique of C++ that allows us to write inline functions without a name(b) A technique of C++ that allows us to write overloaded functions(c) A technique of C++ that allows us to write functions that are called more than once(d) A technique of C++ that allows us to write functions without parametersI have been asked this question by my school principal while I was bunking the class.The query is from Lambda Expressions in section C++ Advanced of C++

Answer»

Right OPTION is (a) A technique of C++ that allows us to write inline functions without a name

Easy explanation - Lambda EXPRESSION is a technique available in C++ that HELPS the PROGRAMMER to write inline functions that will be used once in a program and so there is no need of providing names TOP them. Hence they are a type of inline functions without names.