InterviewSolution
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. |
Why are functions extern by default?(a) Because functions are always private(b) Because those are not visible throughout the program(c) Because those can’t be accessed in all parts of the program(d) Because those are visible throughout the programThis question was addressed to me in an international level competition.This intriguing question originated from Extern Variable in portion Memory Allocation & Scope of Variable of Object Oriented Programming |
|
Answer» The correct choice is (a) Because functions are always private |
|
| 2. |
If extern variable is initialized with the declaration then _______________________(a) Also the header file with definition is required(b) The header file with definition must be included(c) There is no need to include any other header file for definition(d) The extern variable produces compile time errorThis question was addressed to me during an interview.This question is from Extern Variable in portion Memory Allocation & Scope of Variable of Object Oriented Programming |
|
Answer» Correct CHOICE is (c) There is no need to include any other HEADER FILE for definition |
|
| 3. |
If the definition is given in the header file that we include then ________________(a) The program can run successfully(b) Also the program should define the extern variable(c) The extern variable must contain two definitions(d) Extern variable can’t be used in the programThe question was asked by my school teacher while I was bunking the class.This question is from Extern Variable topic in chapter Memory Allocation & Scope of Variable of Object Oriented Programming |
|
Answer» The correct option is (a) The program can run successfully |
|
| 4. |
Which is the correct syntax for extern function declaration?(a) extern function_name(argument_list);(b) extern return_type function_name(argument_list);(c) extern (return_type)function_name(argument_list);(d) return_type extern function_name(argument_list);This question was posed to me in unit test.My question is based upon Extern Variable topic in chapter Memory Allocation & Scope of Variable of Object Oriented Programming |
|
Answer» The correct choice is (b) extern return_type function_name(argument_list); |
|
| 5. |
Which is the correct syntax for extern variable declaration?(a) extern data_type variable_name;(b) extern variable_name;(c) data_type variable_name extern;(d) extern (data_type)variable_name;I have been asked this question in unit test.Question is taken from Extern Variable topic in section Memory Allocation & Scope of Variable of Object Oriented Programming |
|
Answer» The correct answer is (a) extern data_type variable_name; |
|
| 6. |
Which of the following results in the allocation of memory for the extern variables?(a) Declaration(b) Definition(c) Including file(d) Memory is not allocated for extern variablesI have been asked this question in my homework.Asked question is from Extern Variable in chapter Memory Allocation & Scope of Variable of Object Oriented Programming |
|
Answer» Correct ANSWER is (b) Definition |
|
| 7. |
Even if a variable is not declared as extern, it is extern by default.(a) True(b) FalseI got this question by my school principal while I was bunking the class.This question is from Extern Variable in chapter Memory Allocation & Scope of Variable of Object Oriented Programming |
|
Answer» The correct option is (b) FALSE |
|
| 8. |
Whenever a function is declared in a program _____________________(a) extern can be used only in some special cases(b) extern can’t be used(c) function is extern by default(d) it can’t be made externI got this question in examination.This intriguing question comes from Extern Variable in chapter Memory Allocation & Scope of Variable of Object Oriented Programming |
|
Answer» Right answer is (C) function is extern by DEFAULT |
|
| 9. |
Which condition is true if the extern variable is used in a file?(a) All the header files declare it(b) Only few required files declare it(c) All header files declared it if required(d) Only one header file should declare itThis question was addressed to me in semester exam.My doubt is from Extern Variable topic in division Memory Allocation & Scope of Variable of Object Oriented Programming |
|
Answer» The CORRECT choice is (d) Only one header file should declare it |
|
| 10. |
What does a header file contain for an extern variable?(a) Only declaration of variables(b) Only definition of variables(c) Both declaration and definition of variables(d) Neither declaration nor definitionThis question was posed to me in examination.Enquiry is from Extern Variable in division Memory Allocation & Scope of Variable of Object Oriented Programming |
|
Answer» Right option is (a) Only declaration of variables |
|
| 11. |
To use extern variable _____________________(a) The source file must not be included in the new file code(b) The source file itself must be used for a new program(c) The source file must be included in the new file(d) The source file doesn’t matter for extern variablesI had been asked this question in an interview for internship.This is a very interesting question from Extern Variable topic in chapter Memory Allocation & Scope of Variable of Object Oriented Programming |
|
Answer» The correct choice is (c) The source file must be INCLUDED in the new file |
|
| 12. |
Which among the following is true for the variables?(a) Variable can be defined only once(b) Variable can be defined any number of times(c) Variable must be defined more than one time(d) Variable can be defined in different filesI had been asked this question during an interview for a job.I need to ask this question from Extern Variable in chapter Memory Allocation & Scope of Variable of Object Oriented Programming |
|
Answer» Correct answer is (a) Variable can be defined only once |
|
| 13. |
Which among the following is a correct statement for variables?(a) Variable can be declared many times(b) Variable can be declared only one time(c) Variable declaration can’t be done more than ones(d) Variable declaration is always done more than one timeThis question was addressed to me in my homework.My question is taken from Extern Variable in section Memory Allocation & Scope of Variable of Object Oriented Programming |
|
Answer» Right CHOICE is (a) Variable can be DECLARED MANY times |
|
| 14. |
What is extern variable?(a) Variables to be used that are declared in another object file(b) Variables to be used that are declared in another source file(c) Variables to be used that are declared in another executable file(d) Variables to be used that are declared in another programThis question was addressed to me in my homework.My doubt is from Extern Variable in division Memory Allocation & Scope of Variable of Object Oriented Programming |
|
Answer» Correct choice is (B) VARIABLES to be used that are declared in another source file |
|
| 15. |
How are automatic variables different from the instance variables?(a) Automatic variables are initialized automatically but instances are not(b) Automatic variables are given zero values initially and not instances(c) Instance variables have to be initialized explicitly and automatic implicitly(d) Instance variables are initialized implicitly while automatic are notThe question was posed to me in my homework.This intriguing question originated from Automatic Variable in chapter Memory Allocation & Scope of Variable of Object Oriented Programming |
|
Answer» Correct choice is (d) Instance variables are initialized IMPLICITLY while AUTOMATIC are not |
|
| 16. |
In Perl, using which operator are the local variables created?(a) Dot(b) Arrow(c) Scope resolution(d) myThe question was posed to me at a job interview.My question is from Automatic Variable topic in portion Memory Allocation & Scope of Variable of Object Oriented Programming |
|
Answer» The correct option is (d) my |
|
| 17. |
Which error is produced if the automatic variables are used without declaration?(a) Undefined symbol(b) Memory error(c) Type mismatch(d) Statement missingI got this question in my homework.This intriguing question comes from Automatic Variable topic in portion Memory Allocation & Scope of Variable of Object Oriented Programming |
|
Answer» The CORRECT option is (a) Undefined symbol |
|
| 18. |
The automatic variables _________________________(a) Must be declared after its use(b) Must be declared before using(c) Must be declared, can be anytime(d) Must not be initializedI have been asked this question at a job interview.This key question is from Automatic Variable topic in chapter Memory Allocation & Scope of Variable of Object Oriented Programming |
|
Answer» RIGHT OPTION is (b) Must be declared before using For explanation: All the automatic VARIABLES in a program must be declared before their use. The COMPILER won’t allow any use of variable if those are not declared before their use. |
|
| 19. |
Does java contain auto or register keywords?(a) Yes, for declaring every type of variable(b) Yes, only to declare cache registers(c) No, because java doesn’t support automatic variables(d) No, java supports local variable conceptI have been asked this question in homework.My query is from Automatic Variable in chapter Memory Allocation & Scope of Variable of Object Oriented Programming |
|
Answer» Correct choice is (d) No, java supports local VARIABLE concept |
|
| 20. |
Constructor of automatic variables is called ____________________(a) When execution reaches the place of declaration of automatic variables(b) When the program is compiled(c) When the execution is just started(d) Just before the execution of the programThis question was addressed to me in an interview for job.I'd like to ask this question from Automatic Variable topic in section Memory Allocation & Scope of Variable of Object Oriented Programming |
|
Answer» Right CHOICE is (a) When execution reaches the place of declaration of automatic variables |
|
| 21. |
What values does uninitialized automatic variables contain?(a) Null value(b) Void value(c) Undefined/Garbage(d) Zero valueI have been asked this question in homework.Query is from Automatic Variable in section Memory Allocation & Scope of Variable of Object Oriented Programming |
|
Answer» The correct OPTION is (c) Undefined/GARBAGE |
|
| 22. |
All variables declared within a block ____________________(a) Are not always automatic(b) Can be made non-automatic(c) Are static by default(d) Are automatic by defaultI had been asked this question during an online exam.The query is from Automatic Variable in section Memory Allocation & Scope of Variable of Object Oriented Programming |
|
Answer» RIGHT answer is (d) Are AUTOMATIC by default To EXPLAIN: The variables declared inside a block, are make automatic by default. This is to ensure that the variables get destroyed when not REQUIRED. The variables REMAIN live only till those are required, the life is dependent on the scope of a variable. |
|
| 23. |
The static variables of a function ________________(a) Are also automatic variables(b) Are not automatic variables(c) Are made automatic by default(d) Can be made automatic explicitlyThis question was posed to me in final exam.My doubt stems from Automatic Variable topic in division Memory Allocation & Scope of Variable of Object Oriented Programming |
|
Answer» CORRECT answer is (b) Are not automatic variables Easiest explanation - The STATIC members can’t be automatic. This is because the automatic variables are created and destroyed with each CALL to a specific function. But the static members REMAIN THROUGHOUT the execution of program once created. |
|
| 24. |
Where are the automatic variables stored if another function is called in between the execution of the program?(a) Heap(b) Queue(c) Stack(d) Temp variableI had been asked this question at a job interview.I need to ask this question from Automatic Variable in portion Memory Allocation & Scope of Variable of Object Oriented Programming |
|
Answer» The correct answer is (c) STACK |
|
| 25. |
If an automatic variable is created and then a function is called then ________________(a) The automatic variable created gets destroyed(b) The automatic variable doesn’t get destroyed(c) The automatic variable may or may not get destroyed(d) The automatic variable can’t be used in this caseI got this question in my homework.My doubt stems from Automatic Variable in division Memory Allocation & Scope of Variable of Object Oriented Programming |
|
Answer» RIGHT choice is (b) The AUTOMATIC variable doesn’t get destroyed To explain: The automatic VARIABLES are saved till the called FUNCTION gets executed. This is done so as to ensure that the program can continue its execution after the called function is returned. The automatic variables gets destroyed only if those go out of scope. |
|
| 26. |
Which among the following is true for automatic variables in general?(a) Automatic variables are invisible to called function(b) Automatic variables are always visible to the called function(c) Automatic variables can’t interact with the called function(d) Automatic variables can’t be variableI got this question during an interview.Enquiry is from Automatic Variable topic in section Memory Allocation & Scope of Variable of Object Oriented Programming |
|
Answer» The CORRECT answer is (a) Automatic variables are invisible to called FUNCTION |
|
| 27. |
Scope of an automatic variable _______________(a) Is actually the whole program(b) Is actually never fixed(c) Is always equal to the whole program execution(d) Is actually function or block in which it is definedThe question was posed to me during an interview.Question is from Automatic Variable topic in chapter Memory Allocation & Scope of Variable of Object Oriented Programming |
|
Answer» Correct answer is (d) Is actually function or BLOCK in which it is defined |
|
| 28. |
The memory for automatic variables ___________________(a) Have to be allocated and deallocated explicitly(b) Are allocated and deallocated automatically(c) Is never actually allocated(d) Are never safeThe question was asked by my college professor while I was bunking the class.This interesting question is from Automatic Variable in portion Memory Allocation & Scope of Variable of Object Oriented Programming |
|
Answer» The correct choice is (B) Are allocated and DEALLOCATED automatically |
|
| 29. |
What are automatic variables?(a) Global variables(b) Implicit/temporary variables(c) Local variables(d) System variablesThis question was addressed to me by my school teacher while I was bunking the class.This intriguing question comes from Automatic Variable in portion Memory Allocation & Scope of Variable of Object Oriented Programming |
|
Answer» RIGHT option is (c) Local variables To EXPLAIN: The local variables are also known as automatic variables. The variables in any local SCOPE that are CREATED and destroyed as the program executes its scope. |
|
| 30. |
The delete operator __________________________(a) Can be defined for each class(b) Can’t be defined for each class(c) Can be defined globally only(d) Can’t be defined in a program explicitlyThe question was asked in my homework.The doubt is from Delete Operator in section Memory Allocation & Scope of Variable of Object Oriented Programming |
|
Answer» RIGHT option is (a) Can be DEFINED for each CLASS The best I can EXPLAIN: The delete operator can be defined for each class EXPLICITLY. If there is a class for which delete is not defined then the global delete operator is used. The definition of delete operator for each class is not necessary. |
|
| 31. |
For objects that are not of class type ______________(a) Global delete operator is invoked(b) Local delete operator is invoked(c) Global user defined function is invoked(d) Local function to delete object is calledI got this question in homework.My doubt stems from Delete Operator topic in portion Memory Allocation & Scope of Variable of Object Oriented Programming |
|
Answer» The correct option is (a) Global delete OPERATOR is invoked |
|
| 32. |
The delete operator __________________(a) Invokes function operator delete(b) Invokes function defined by user to delete(c) Invokes function defined in global scope to delete object(d) Doesn’t invoke any functionI have been asked this question in an international level competition.My query is from Delete Operator in portion Memory Allocation & Scope of Variable of Object Oriented Programming |
|
Answer» Right answer is (a) INVOKES function operator delete |
|
| 33. |
Which cases among the following produces the undefined result?(a) delete [] on an independent object(b) delete on an object array(c) delete [] on an object and delete on object array(d) Undefined result is never producedThe question was posed to me in examination.This key question is from Delete Operator topic in chapter Memory Allocation & Scope of Variable of Object Oriented Programming |
|
Answer» Right answer is (c) DELETE [] on an object and delete on object ARRAY |
|
| 34. |
Which is the correct syntax to delete an array of objects?(a) delete [] objectName;(b) delete * objectName;(c) objectName[] delete;(d) delete objectName[];I got this question in my homework.This question is from Delete Operator in chapter Memory Allocation & Scope of Variable of Object Oriented Programming |
|
Answer» Right OPTION is (a) DELETE [] objectName; |
|
| 35. |
Which is the correct syntax to delete a single object?(a) delete *objectName;(b) objectName delete;(c) delete objectName;(d) objectName *delete;This question was posed to me in an international level competition.I'd like to ask this question from Delete Operator topic in division Memory Allocation & Scope of Variable of Object Oriented Programming |
|
Answer» The correct answer is (c) DELETE objectName; |
|
| 36. |
How many variants of delete operator are available?(a) Only 1(b) Only 2(c) Only 3(d) Only 4I got this question in my homework.I want to ask this question from Delete Operator topic in chapter Memory Allocation & Scope of Variable of Object Oriented Programming |
|
Answer» The correct answer is (b) Only 2 |
|
| 37. |
If delete is applied to an object whose l-value is modifiable, then _______________ after the object is deleted.(a) Its value is defined as null(b) Its value is defined as void(c) Its value is defined as 0(d) Its value is undefinedThe question was asked by my college director while I was bunking the class.Asked question is from Delete Operator topic in chapter Memory Allocation & Scope of Variable of Object Oriented Programming |
|
Answer» Correct CHOICE is (d) Its value is undefined |
|
| 38. |
When delete operator is used ___________________ (If object has a destructor)(a) Object destructor is called after deallocation(b) Object destructor is called before deallocation(c) Object destructor is not used(d) Object destructor can be called anytime during destructionThis question was posed to me in semester exam.This key question is from Delete Operator topic in division Memory Allocation & Scope of Variable of Object Oriented Programming |
|
Answer» Right choice is (b) Object destructor is called before deallocation |
|
| 39. |
Delete operator _________________(a) Can be used on pointers with null value(b) Can be used on pointers with void value(c) Can be used on pointer with value 0(d) Can be used on pointer with any valueThis question was addressed to me in a job interview.My query is from Delete Operator topic in division Memory Allocation & Scope of Variable of Object Oriented Programming |
|
Answer» The correct option is (c) Can be USED on pointer with value 0 |
|
| 40. |
If delete is used to delete an object which was not allocated using new _______________(a) Then out of memory error arises(b) Then unreachable code error arises(c) Then unpredictable errors may arise(d) Then undefined variable error arisesThe question was posed to me by my college director while I was bunking the class.The query is from Delete Operator in portion Memory Allocation & Scope of Variable of Object Oriented Programming |
|
Answer» The correct answer is (c) Then unpredictable ERRORS may arise |
|
| 41. |
Which type of value has resulted from the delete operator?(a) void(b) void pointer(c) null pointer(d) nullThis question was addressed to me during an internship interview.The query is from Delete Operator in portion Memory Allocation & Scope of Variable of Object Oriented Programming |
|
Answer» CORRECT choice is (a) void Easiest explanation - The RESULT of the delete OPERATOR is void. The values returned is of no use to the PROGRAM or any other system FUNCTION hence the return type is not defined for the delete operator. |
|
| 42. |
Does delete return any value?(a) Yes, positive value(b) Yes, negative value(c) Yes, zero value(d) NoI have been asked this question during an online interview.My query is from Delete Operator topic in section Memory Allocation & Scope of Variable of Object Oriented Programming |
|
Answer» Correct answer is (d) No |
|
| 43. |
If an object is allocated using new operator ____________(a) It should be deleted using delete operator(b) It can’t be deleted using delete operator(c) It may or may not be deleted using delete operator(d) The delete operator is not applicableI got this question at a job interview.My enquiry is from Delete Operator topic in section Memory Allocation & Scope of Variable of Object Oriented Programming |
|
Answer» Right option is (a) It should be DELETED USING delete operator |
|
| 44. |
What is a delete operator?(a) Deallocates a block of memory(b) Deallocates whole program memory(c) Deallocates only primitive data memory(d) Deallocates all the data reserved for a classThis question was addressed to me in a job interview.This intriguing question comes from Delete Operator topic in portion Memory Allocation & Scope of Variable of Object Oriented Programming |
|
Answer» The correct answer is (a) Deallocates a block of memory |
|
| 45. |
How does compiler convert “::operator new” implicitly?(a) ::operator new( sizeof( type ) )(b) ::operator new( sizeof( ) )(c) new operator :: type sizeof( type )(d) new sizeof( type ) operatorThe question was asked in an international level competition.The question is from New Operator topic in division Memory Allocation & Scope of Variable of Object Oriented Programming |
|
Answer» The CORRECT answer is (a) ::operator new( sizeof( type ) ) |
|
| 46. |
If a new operator is defined for a class and still global new operator have to be used, which operator should be used with the keyword new?(a) Colon(b) Arrow(c) Dot(d) Scope resolutionI have been asked this question during an online exam.Query is from New Operator in division Memory Allocation & Scope of Variable of Object Oriented Programming |
|
Answer» The correct ANSWER is (d) Scope resolution |
|
| 47. |
The new operator _________________(a) Invokes function operator new(b) Doesn’t invoke function operator new(c) Invokes function operator only if required(d) Can’t invoke function operator new implicitlyThis question was addressed to me in class test.The above asked question is from New Operator in division Memory Allocation & Scope of Variable of Object Oriented Programming |
|
Answer» The correct choice is (a) INVOKES FUNCTION operator NEW |
|
| 48. |
The objects allocated using new operator ________________(a) Are destroyed when they go out of scope(b) Are not destroyed even if they go out of scope(c) Are destroyed anytime(d) Are not destroyed throughout the program executionThis question was posed to me in exam.Query is from New Operator in portion Memory Allocation & Scope of Variable of Object Oriented Programming |
|
Answer» The CORRECT OPTION is (b) Are not destroyed even if they go out of scope |
|
| 49. |
Which among the following is added in grammar of new operator?(a) Finalize(b) Arg(c) Initializer(d) AllocatorThe question was posed to me during a job interview.This question is from New Operator topic in section Memory Allocation & Scope of Variable of Object Oriented Programming |
|
Answer» Right option is (c) INITIALIZER |
|
| 50. |
Initializers __________________(a) Are used for specifying arrays(b) Are used to defined multidimensional arrays(c) Can’t be specified for arrays(d) Can’t be specified for any dataThis question was addressed to me during an interview.I'm obligated to ask this question of New Operator topic in section Memory Allocation & Scope of Variable of Object Oriented Programming |
|
Answer» Correct answer is (C) Can’t be SPECIFIED for ARRAYS |
|