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.

Which of the following operator is used with this pointer to access members of a class?(a) .(b) !(c) ->(d) ~This question was posed to me in my homework.The origin of the question is C++ Concepts in portion Basics Concepts of C++ of C++

Answer»

The correct option is (C) ->

Easy explanation - this pointer is a TYPE of pointer and as we know pointer object USES the arrow(->) operator to access the MEMBERS of the CLASS, therefore, this pointer uses -> operator.

2.

Why this pointer is used?(a) To access the members of a class which have the same name as local variables in that scope(b) To access all the data stored under that class(c) To access objects of other class(d) To access objects of other variablesI had been asked this question in examination.My query is from C++ Concepts topic in chapter Basics Concepts of C++ of C++

Answer»

Correct OPTION is (a) To access the members of a class which have the same NAME as local variables in that scope

Best explanation: this POINTER is used to access the members of a class which have the same name as local variables in that part of the CODE.

3.

Which of the following is correct about static variables?(a) Static functions do not support polymorphism(b) Static data members cannot be accessed by non-static member functions(c) Static data members functions can access only static data members(d) Static data members functions can access both static and non-static data membersI have been asked this question by my school teacher while I was bunking the class.The doubt is from Static Constant Keyword topic in section Basics Concepts of C++ of C++

Answer»

The correct option is (C) STATIC data MEMBERS functions can ACCESS only static data members

Best EXPLANATION: Static member functions can access static data members only. Static member functions can be overloaded. Static data members can be accessed by non-static member functions.

4.

Which of the following is correct about this pointer in C++?(a) this pointer is passed as a hidden argument in all the functions of a class(b) this pointer is passed as a hidden argument in all non-static functions of a class(c) this pointer is passed as a hidden argument in all static functions of a class(d) this pointer is passed as a hidden argument in all static variables of a classThis question was addressed to me by my college director while I was bunking the class.My enquiry is from C++ Concepts in section Basics Concepts of C++ of C++

Answer»

Right choice is (B) this pointer is passed as a HIDDEN argument in all non-static FUNCTIONS of a class

To explain I would SAY: As static functions are a type of global function for a class so all the object shares the common instance of that static function whereas all the objects have there own instance for non-static functions and HENCE they are passed as a hidden argument in all the non-static members but not in static members.

5.

Which of the following statement is correct?(a) Structure in C allows Constructor definition(b) Structure in C++ allows Constructor definition(c) Both allow Constructor definition(d) C allows constructor definition while C++ does notI had been asked this question in quiz.Query is from C++ Concepts in portion Basics Concepts of C++ of C++

Answer»

Right option is (b) Structure in C++ ALLOWS Constructor DEFINITION

To explain I would SAY: As C does not allow the programmer to define a function INSIDE a structure and constructor itself is a function, therefore, the constructor definition is not ALLOWED in C whereas such definitions are allowed in C++.

6.

What is name mangling in C++?(a) The process of adding more information to a function name so that it can be distinguished from other functions by the compiler(b) The process of making common names for all the function of C++ program for better use(c) The process of changing the names of variable(d) The process of declaring variables of different typesI had been asked this question in final exam.Enquiry is from C++ Concepts in section Basics Concepts of C++ of C++

Answer»

The CORRECT CHOICE is (a) The process of adding more information to a function NAME so that it can be DISTINGUISHED from other functions by the compiler

The explanation is: Name mangling is the process of adding some more information to a function name so that it can be distinguished from other functions by the compiler. This is used when a programmer uses the CONCEPT of function overloading in his/her program.

7.

Which of the following is correct about static polymorphism?(a) In static polymorphism, the conflict between the function call is resolved during the compile time(b) In static polymorphism, the conflict between the function call is resolved during the run time(c) In static polymorphism, the conflict between the function call is never resolved during the execution of a program(d) In static polymorphism, the conflict between the function call is resolved only if it requiredI had been asked this question in examination.My question comes from C++ Concepts topic in division Basics Concepts of C++ of C++

Answer»

Right ANSWER is (a) In static POLYMORPHISM, the CONFLICT between the function call is resolved during the compile TIME

Explanation: The conflict between which function to call is resolved during the compile time in static polymorphism i.e. before the execution of the program starts.

8.

What is the other name of compile-time polymorphism?(a) Static polymorphism(b) Dynamic polymorphism(c) Executing polymorphism(d) Non-executing polymorphismThis question was posed to me in an online quiz.My query is from C++ Concepts in division Basics Concepts of C++ of C++

Answer»

Correct CHOICE is (a) STATIC polymorphism

The best I can EXPLAIN: Compile-time polymorphism is ALSO known as static polymorphism as it is implemented during the compile-time.

9.

Which of the following is correct?(a) struct tag is required in both C and C++ while declaring an object of the structure(b) struct is not required in C but required in C++ while declaring an object of the structure(c) struct is not required in C++ but required in C while declaring an object of the structure(d) struct tag is not required in both C and C++ while declaring an object of the structureThe question was asked during an internship interview.I'm obligated to ask this question of C++ Concepts in chapter Basics Concepts of C++ of C++

Answer» CORRECT answer is (c) STRUCT is not required in C++ but required in C while declaring an OBJECT of the structure

For explanation: C++ does not require struct keyword while declaring an object of the structure whereas in C we require struct TAG for declaring an object.
10.

Which of the following operator has left to right associativity?(a) Unary operator(b) Logical not(c) Array element access(d) addressofI had been asked this question in a job interview.Question is taken from C++ Concepts in chapter Basics Concepts of C++ of C++

Answer»

Correct OPTION is (C) Array ELEMENT access

Best EXPLANATION: Array element has left to right associativity i.e. expressions are EVALUATED from left to right in case of array element access.

11.

Which of the following syntax for declaring a variable of struct STRUCT can be used in both C and C++?(a) struct STRUCT S;(b) STRUCT S;(c) Both struct STRUCT S; and STRUCT S;(d) Both C and C++ have different syntaxI had been asked this question during an interview.This interesting question is from C++ Concepts topic in section Basics Concepts of C++ of C++

Answer»

The correct choice is (a) struct STRUCT S;

To explain: C PROGRAM REQUIRES struct keyword while DEFINING a variable of any structure, therefore, we cannot use the second STRUCT S; definition to DECLARE a variable.

12.

What is the other name of run-time polymorphism?(a) Static polymorphism(b) Dynamic polymorphism(c) Executing polymorphism(d) Non-executing polymorphismI had been asked this question in examination.This intriguing question originated from C++ Concepts in division Basics Concepts of C++ of C++

Answer»

The correct CHOICE is (b) Dynamic polymorphism

Best EXPLANATION: Run-time polymorphism is also known as dynamic polymorphism as it is implemented during the run-time of the PROGRAM.

13.

How many types of polymorphism are there?(a) 1(b) 2(c) 3(d) 4I had been asked this question in exam.My doubt is from C++ Concepts in chapter Basics Concepts of C++ of C++

Answer» RIGHT option is (b) 2

To EXPLAIN: There are two types of polymorphism in C++ namely compile-time polymorphism and run-time polymorphism.
14.

What is the size of a character type in C and C++?(a) 4 and 1(b) 1 and 4(c) 1 and 1(d) 4 and 4I had been asked this question in examination.This interesting question is from C++ Concepts in section Basics Concepts of C++ of C++

Answer»

Right choice is (c) 1 and 1

The best explanation: The size of a character type in both C and C++ is 1. You can do PRINTF(“%d”, (int)SIZEOF(char)); in both C and C++ to CHECK this.

15.

What is the size of a character literal in C and C++?(a) 4 and 1(b) 1 and 4(c) 1 and 1(d) 4 and 4The question was posed to me in final exam.This interesting question is from C++ Concepts in section Basics Concepts of C++ of C++

Answer» RIGHT choice is (a) 4 and 1

To explain I would say: The size of a character literal is 4 in case of C but it is ONE in case of C++. You can do printf(“%d”, (int)sizeof(‘a’)); in both C and C++ to check this.
16.

What is std in C++?(a) std is a standard class in C++(b) std is a standard namespace in C++(c) std is a standard header file in C++(d) std is a standard file reading header in C++I got this question during an interview for a job.Enquiry is from C++ Concepts in portion Basics Concepts of C++ of C++

Answer»

Right answer is (b) std is a standard namespace in C++

Best explanation: std is a standard namespace present in C++ which CONTAINS different stream classes and OBJECTS like cin, cout, ETC. and other standard functions.

17.

Which of the following is accessed by a member function of a class?(a) The object of that class(b) All members of a class(c) The public part of a class(d) The private part of a classI have been asked this question during an interview for a job.My question is based upon C++ Concepts topic in chapter Basics Concepts of C++ of C++

Answer»

The correct choice is (b) All MEMBERS of a class

The EXPLANATION is: A MEMBER function of a class can access all the members of its class whether they are PRIVATE, protected or public.

18.

Which of the following is correct about dynamic polymorphism?(a) In dynamic polymorphism, the conflict between the function call is resolved during the compile time(b) In dynamic polymorphism, the conflict between the function call is resolved during the run time(c) In dynamic polymorphism, the conflict between the function call is never resolved during the execution of the program(d) In dynamic polymorphism, the conflict between the function call is resolved at the beginning of the programI had been asked this question during a job interview.Origin of the question is C++ Concepts topic in section Basics Concepts of C++ of C++

Answer»

Correct CHOICE is (b) In DYNAMIC polymorphism, the conflict between the function call is resolved during the RUN TIME

The explanation is: The conflict between which function to call is resolved during the run time in dynamic polymorphism i.e. the conflict is resolved when the execution REACHES the function call statement.

19.

Which of the following is an entry-controlled loop?(a) for(b) while(c) do-while(d) both while and forI have been asked this question during a job interview.This intriguing question comes from C++ Concepts in chapter Basics Concepts of C++ of C++

Answer»

The correct OPTION is (d) both while and for

The BEST I can explain: Both while and for LOOPS are called entry controlled loop because in both of them the termination condition is checked before we enter the BODY of the loop hence they are called entry controlled loop.

20.

Which of the following is correct?(a) Friend functions can access public members of a class(b) Friend functions can access protected members of a class(c) Friend functions can access private members of a class(d) All of the mentionedThe question was asked by my school principal while I was bunking the class.Enquiry is from OOPs Concept topic in division Basics Concepts of C++ of C++

Answer»

The CORRECT choice is (d) All of the mentioned

The best explanation: Friend functions can ACCESS any member of a CLASS without caring about the type of member i.e. without caring whether it is private, protected or PUBLIC.

21.

Which of the following explains the overloading of functions?(a) Virtual polymorphism(b) Transient polymorphism(c) Ad-hoc polymorphism(d) Pseudo polymorphismI had been asked this question during an online exam.This intriguing question originated from OOPs Concept topic in section Basics Concepts of C++ of C++

Answer» RIGHT choice is (c) Ad-hoc POLYMORPHISM

The BEST I can EXPLAIN: Ad-hoc polymorphism is a type of polymorphism in which a function denotes heterogeneous implementation depending upon the TYPES of argument.
22.

Which concept means the addition of new components to a program as it runs?(a) Data hiding(b) Dynamic binding(c) Dynamic loading(d) Dynamic typingThis question was posed to me in a job interview.I'd like to ask this question from OOPs Concept topic in portion Basics Concepts of C++ of C++

Answer»

Correct answer is (C) Dynamic LOADING

The BEST I can explain: Dynamic loading is the concept of adding NEW COMPONENTS to a program as it runs.

23.

What is the other name used for functions inside a class?(a) Member variables(b) Member functions(c) Class functions(d) Class variablesThe question was asked during an interview for a job.I'd like to ask this question from OOPs Concept in chapter Basics Concepts of C++ of C++

Answer»

Right option is (b) Member functions

The EXPLANATION: Functions of a CLASS are also KNOWN as member functions of a class.

24.

Who created C++?(a) Bjarne Stroustrup(b) Dennis Ritchie(c) Ken Thompson(d) Brian KernighanI had been asked this question in homework.The origin of the question is Basics in portion Basics Concepts of C++ of C++

Answer» CORRECT answer is (a) Bjarne Stroustrup

The best I can explain: Bjarne Stroustrup is the original CREATOR of C++ during 1979 at AT&T BELL Labs.
25.

Which of the following is a correct identifier in C++?(a) 7var_name(b) 7VARNAME(c) VAR_1234(d) $var_nameThis question was posed to me during an interview.My enquiry is from Basics topic in portion Basics Concepts of C++ of C++

Answer»

The correct choice is (C) VAR_1234

For explanation: The rules for writing an identifier is as follows:

i) may CONTAIN lowercase/uppercase letters, digits or UNDERSCORE(_) only

ii) should START with a non-digit character

iii) should not contain any SPECIAL characters like @, $, etc.

26.

What is the size of a boolean variable in C++?(a) 1 bit(b) 1 byte(c) 4 bytes(d) 2 bytesThe question was asked by my school principal while I was bunking the class.My question is from C++ Concepts topic in chapter Basics Concepts of C++ of C++

Answer»

The correct option is (a) 1 bit

The EXPLANATION: BOOLEAN uses only 1 bit as it STORES only TRUTH values which can be true(1) or FALSE(0).

27.

Which operator is overloaded for a cout object?(a) >>(b)

Answer»

The CORRECT choice is (B) <<

Explanation: COUT in C++ uses << operator to print anything so << operator is overloaded for a cout OBJECT.

28.

Which of the following is an abstract data type?(a) int(b) float(c) class(d) stringI got this question in unit test.I'd like to ask this question from OOPs Concept in portion Basics Concepts of C++ of C++

Answer»

The correct OPTION is (C) class

The explanation: Class is used as an abstract DATA TYPE as it can be used to give implementation independent view WHEREAS no other data type can be used to provide this.

29.

How many types of polymorphism are there in C++?(a) 1(b) 2(c) 3(d) 4This question was posed to me in an online interview.My question is based upon OOPs Concept in section Basics Concepts of C++ of C++

Answer»

The CORRECT choice is (B) 2

The EXPLANATION: There are two types of polymorphism in C++ NAMELY run-time and compile-time POLYMORPHISMS.

30.

Which of the following escape sequence represents tab?(a) \t(b) \t\r(c) \b(d) \aThis question was posed to me in a national level competition.Query is from Basics in division Basics Concepts of C++ of C++

Answer» CORRECT option is (a) \t

Best EXPLANATION: \t is used to represent TAB which MEANS a SET of blank spaces in a line.
31.

Which of the following is correct in C++?(a) Classes cannot have protected data members(b) Structures can have member functions(c) Class members are public by default(d) Structure members are private by defaultI have been asked this question during an online exam.I'd like to ask this question from OOPs Concept topic in section Basics Concepts of C++ of C++

Answer»

Right option is (b) STRUCTURES can have MEMBER functions

Explanation: THOUGH C does not allows member functions in structures but C++ allows structures to have member functions. Members of structures are public by default and those of classes are private by default. Classes can have PROTECTED data members.

32.

Which of the following cannot be used with the virtual keyword?(a) Class(b) Member functions(c) Constructors(d) DestructorsThe question was asked in my homework.My question is based upon OOPs Concept in division Basics Concepts of C++ of C++

Answer»

The correct answer is (c) CONSTRUCTORS

The best explanation: Virtual keyword cannot be USED with constructors as constructors are defined to initialized an object of particular class hence no other class NEEDS CONSTRUCTOR of other class.

33.

How compile-time polymorphisms are implemented in C++?(a) Using Inheritance(b) Using Virtual functions(c) Using Templates(d) Using Inheritance and Virtual functionsThe question was posed to me during an online interview.I'm obligated to ask this question of OOPs Concept in chapter Basics Concepts of C++ of C++

Answer»

Correct option is (c) Using Templates

Explanation: Compile-time polymorphism is IMPLEMENTED using templates in which the TYPES(which can be checked during compile-time) are USED DECIDES which function to be called.

34.

In which part of the for loop termination condition is checked?for(I;II;III){IV}(a) I(b) II(c) III(d) IVThe question was asked during an internship interview.My doubt is from C++ Concepts in portion Basics Concepts of C++ of C++

Answer»

Right choice is (b) II

The explanation: In II PART the termination CONDITION of the for loop is CHECKED.

35.

Which function is used to write a single character to console in C++?(a) cout.put(ch)(b) cout.putline(ch)(c) write(ch)(d) printf(ch)I had been asked this question at a job interview.The question is from Basics topic in section Basics Concepts of C++ of C++

Answer»

Right choice is (a) cout.put(ch)

Explanation: C++ provides cout.put() FUNCTION to WRITE a single character to console whereas others are used to write EITHER a single or multiple CHARACTERS.

36.

Which of the following is used to make an abstract class?(a) By using virtual keyword in front of a class declaration(b) By using an abstract keyword in front of a class declaration(c) By declaring a virtual function in a class(d) By declaring a pure virtual function in a classI have been asked this question in exam.The above asked question is from OOPs Concept in section Basics Concepts of C++ of C++

Answer»

Right answer is (d) By DECLARING a pure virtual FUNCTION in a class

Best EXPLANATION: Abstract class should have at least one pure virtual function. Therefore to declare an abstract class one should declare a pure virtual function in a class.

37.

Which concept is used to implement late binding?(a) Virtual functions(b) Operator functions(c) Constant functions(d) Static functionsThe question was asked in an internship interview.The question is from OOPs Concept in section Basics Concepts of C++ of C++

Answer»

Right option is (a) Virtual functions

Explanation: Virtual functions are used to implement the concept of LATE BINDING i.e. binding actual functions to their calls.

38.

Which of the following escape sequence represents carriage return?(a) \r(b) \n(c) \n\r(d) \cI have been asked this question during an internship interview.This question is from Basics in division Basics Concepts of C++ of C++

Answer»

Right choice is (a) \r

Best explanation: \r is USED to represent CARRIAGE return which MEANS move the cursor to the beginning of the next line.

39.

What are the escape sequences?(a) Set of characters that convey special meaning in a program(b) Set of characters that whose use are avoided in C++ programs(c) Set of characters that are used in the name of the main function of the program(d) Set of characters that are avoided in cout statementsI had been asked this question in homework.My question is based upon Basics in chapter Basics Concepts of C++ of C++

Answer» RIGHT answer is (a) Set of characters that CONVEY special meaning in a program

Easiest explanation - Escape SEQUENCE is a set of characters that convey a special meaning to the program. They are used to convey a meaning which cannot be conveyed directly.
40.

Which of the following is C++ equivalent for scanf()?(a) cin(b) cout(c) print(d) inputI got this question by my college director while I was bunking the class.This intriguing question comes from C++ Concepts in division Basics Concepts of C++ of C++

Answer»

Correct answer is (a) CIN

The BEST I can EXPLAIN: C++ uses cin to read INPUT FORM uses. However C++ also uses scanf().

41.

Which of the following is not a fundamental type is not present in C but present in C++?(a) int(b) float(c) bool(d) voidThis question was addressed to me in quiz.Asked question is from C++ Concepts in division Basics Concepts of C++ of C++

Answer» RIGHT ANSWER is (c) BOOL

Easy explanation - Boolean type is not present as a FUNDAMENTAL type in C. int type is used as boolean in C whereas in C++ bool is defined as a fundamental type for handling boolean outputs.
42.

What is static binding?(a) The process of linking the actual code with a procedural call during run-time(b) The process of linking the actual code with a procedural call during compile-time(c) The process of linking the actual code with a procedural call at any-time(d) All of the mentionedThe question was posed to me in my homework.My query is from C++ Concepts topic in chapter Basics Concepts of C++ of C++

Answer»

Right answer is (b) The process of linking the actual code with a procedural call during compile-time

The BEST explanation: BINDING of calls and VARIABLES with actual code at compile-time is called static binding. For example normally whenever we declare a variable we DEFINE its TYPE hence compiler knows what type should be binded to that variable i.e. compiler can decide about that variable this is called static binding.

43.

Which of the following is correct?(a) C++ allows static type checking(b) C++ allows dynamic type checking.(c) C++ allows static member function to be of type const.(d) C++ allows both static and dynamic type checkingI have been asked this question by my college director while I was bunking the class.My doubt is from OOPs Concept in division Basics Concepts of C++ of C++

Answer»

Correct option is (d) C++ allows both static and dynamic type CHECKING

Easy explanation - C++ allows both static and dynamic type checking i.e. TYPES are checked by the COMPILER.

44.

Which of the following class allows to declare only one object of it?(a) Abstract class(b) Virtual class(c) Singleton class(d) Friend classI got this question during a job interview.Query is from OOPs Concept in section Basics Concepts of C++ of C++

Answer»

Right option is (C) Singleton class

Explanation: Singleton class allows the programmer to declare only ONE OBJECT of it, If one TRIES to declare more than one object the program RESULTS into error.

45.

What are the actual parameters in C++?(a) Parameters with which functions are called(b) Parameters which are used in the definition of a function(c) Variables other than passed parameters in a function(d) Variables that are never used in the functionThis question was addressed to me in unit test.My question comes from Basics in division Basics Concepts of C++ of C++

Answer»

Correct choice is (a) PARAMETERS with which functions are called

Explanation: ACTUAL parameters are those using which a FUNCTION CALL is made i.e. which are actually passed in a function when that function is called.

46.

Why references are different from pointers?(a) A reference cannot be made null(b) A reference cannot be changed once initialized(c) No extra operator is needed for dereferencing of a reference(d) All of the mentionedThis question was addressed to me during a job interview.My doubt stems from OOPs Concept topic in division Basics Concepts of C++ of C++

Answer»

The correct answer is (d) All of the mentioned

Easiest EXPLANATION - References cannot be made null whereas a pointer can be. References cannot be changed whereas pointers can be modified.

 Pointers need * operator to dereference the VALUE PRESENT INSIDE it whereas reference does not need an operator for dereferencing.

47.

Which of the following is a static polymorphism mechanism?(a) Function overloading(b) Operator overloading(c) Templates(d) All of the mentionedThe question was posed to me in class test.I need to ask this question from OOPs Concept in portion Basics Concepts of C++ of C++

Answer» CORRECT choice is (d) All of the MENTIONED

Best explanation: All the options mentioned above uses static POLYMORPHISM mechanism. As the CONFLICTS in all these types of FUNCTIONS are resolved during compile-time.
48.

Which of the following supports the concept that reusability is a desirable feature of a language?(a) It reduces the testing time(b) It reduces maintenance cost(c) It decreases the compilation time(d) It reduced both testing and maintenance timeThis question was posed to me in a national level competition.Query is from OOPs Concept in chapter Basics Concepts of C++ of C++

Answer»

Correct answer is (d) It reduced both testing and maintenance TIME

The EXPLANATION: As we will be using the existing code THEREFORE we don’t need to check the code again and again so testing and maintenance time decreases but the compiler time may increase or remains same because though we are reusing the code but every PART needs to be compiled and EXTRA include statement needs to be executed therefore compilation time may remain same or increases.

49.

How run-time polymorphisms are implemented in C++?(a) Using Inheritance(b) Using Virtual functions(c) Using Templates(d) Using Inheritance and Virtual functionsThis question was addressed to me at a job interview.This interesting question is from OOPs Concept topic in portion Basics Concepts of C++ of C++

Answer»

Correct ANSWER is (d) Using Inheritance and Virtual functions

Easy EXPLANATION - Run-time POLYMORPHISM is IMPLEMENTED using Inheritance and virtual in which object decides which function to call.

50.

Which of the following is not a type of Constructor?(a) Friend constructor(b) Copy constructor(c) Default constructor(d) Parameterized constructorThis question was posed to me during an online interview.The origin of the question is OOPs Concept topic in portion Basics Concepts of C++ of C++

Answer» CORRECT ANSWER is (a) FRIEND constructor

The explanation is: Friend function is not a constructor WHEREAS others are a type of constructor used for object initialization.