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.

In C++, what is the sign of character data type by default?(a) Signed(b) Unsigned(c) Implementation dependent(d) Unsigned ImplementationI have been asked this question in an international level competition.I'm obligated to ask this question of Character Types topic in portion Types, Pointers, Arrays & Structures in C++ of C++

Answer»

The correct CHOICE is (c) Implementation dependent

To EXPLAIN: The STANDARD does not specify if plain CHAR is signed or unsigned. There are three distinct CHARACTER types according to the standard: char, signed char and unsigned char.

2.

Which function is used to check whether a character is a number?(a) isalpha()(b) isalnum()(c) isdigit()(d) isblank()I had been asked this question in an international level competition.Enquiry is from Character Classification topic in section Types, Pointers, Arrays & Structures in C++ of C++

Answer»

Right CHOICE is (c) ISDIGIT()

EXPLANATION: Character classification provides isdigit() FUNCTION to check whether a character in C++ is number or not.

3.

The pointer can point to any variable that is not declared with which of these?(a) const(b) volatile(c) both const & volatile(d) staticThe question was asked in an internship interview.The query is from Pointer to Void in section Types, Pointers, Arrays & Structures in C++ of C++

Answer»

The CORRECT ANSWER is (c) both CONST & volatile

Explanation: Pointer can point to any variable that is not declared with const & volatile.

4.

The void pointer can point to which type of objects?(a) int(b) float(c) double(d) all of the mentionedI have been asked this question in an interview.Enquiry is from Pointer to Void topic in division Types, Pointers, Arrays & Structures in C++ of C++

Answer»

Correct choice is (d) all of the mentioned

Easiest explanation - Because it doesn’t know the type of OBJECT it is POINTING to, So it can POINT to all OBJECTS.

5.

How do we represent a wide character of the form wchar_t?(a) L’a’(b) l’a’(c) L[a](d) laI have been asked this question in class test.This interesting question is from Character Types topic in section Types, Pointers, Arrays & Structures in C++ of C++

Answer»

The CORRECT answer is (a) L’a’

EXPLANATION: A wide character is always indicated by immediately PRECEDING the character LITERAL by an L.

6.

What is the size of wchar_t in C++?(a) 2(b) 4(c) 2 or 4(d) Based on the number of bits in the systemThis question was posed to me in an international level competition.This intriguing question comes from Types in section Types, Pointers, Arrays & Structures in C++ of C++

Answer» CORRECT answer is (d) Based on the number of bits in the system

The EXPLANATION is: Compiler wants to MAKE CPU as more efficient in accessing the NEXT value.
7.

What is the index number of the last element of an array with 9 elements?(a) 9(b) 8(c) 0(d) Programmer-definedI have been asked this question in quiz.The question is from Arrays topic in chapter Types, Pointers, Arrays & Structures in C++ of C++

Answer»

Right OPTION is (b) 8

The explanation: Because the first element ALWAYS starts at 0. So it is on 8 POSITION.

8.

Which of the following correctly declares an array?(a) int array[10];(b) int array;(c) array{10};(d) array array[10];This question was posed to me in a national level competition.My doubt stems from Arrays in chapter Types, Pointers, Arrays & Structures in C++ of C++

Answer»

Right ANSWER is (a) int array[10];

The EXPLANATION is: Because array variable and VALUES need to be DECLARED after the datatype only.

9.

Which of the following is a properly defined structure?(a) struct {int a;}(b) struct a_struct {int a;}(c) struct a_struct int a;(d) struct a_struct {int a;};The question was asked by my college director while I was bunking the class.The doubt is from Structures in portion Types, Pointers, Arrays & Structures in C++ of C++

Answer»

Correct OPTION is (d) struct a_struct {int a;};

Explanation: option struct {int a;} is not correct because NAME of structure and ;(after DECLARATION) are MISSING. In option struct a_struct {int a;} ; is missing. In option struct a_struct int a; {} are missing.

10.

What is the difference between references and pointers?(a) References are an alias for a variable whereas pointer stores the address of a variable(b) References and pointers are similar(c) References stores address of variables whereas pointer points to variables(d) Pointers are an alias for a variable whereas references stores the address of a variableThe question was asked by my school principal while I was bunking the class.My doubt stems from References topic in division Types, Pointers, Arrays & Structures in C++ of C++

Answer»

Right choice is (a) References are an ALIAS for a variable whereas POINTER stores the address of a variable

The best I can explain: References are an alias/another NAME for a variable whereas pointer stores the address of a variable. POINTERS need to be deference before use whereas references need not.

11.

Which one of the following is not a possible state for a pointer.(a) hold the address of the specific object(b) point one past the end of an object(c) zero(d) point to a typeI got this question in an international level competition.My question is based upon Pointers topic in chapter Types, Pointers, Arrays & Structures in C++ of C++

Answer»

The correct ANSWER is (d) POINT to a type

The explanation: A pointer can be in only 3 STATES a, b and C.

12.

It is guaranteed that a ____ has at least 8 bits and a ____ has at least 16 bits.(a) int, float(b) char, int(c) bool, char(d) char, shortI got this question by my school teacher while I was bunking the class.Query is from Sizes topic in division Types, Pointers, Arrays & Structures in C++ of C++

Answer»

Right choice is (d) char, SHORT

Explanation: char types in C++ require atleast 8 bits and short requires atleast 16 bits, whereas for bool only 1 bit SUFFICES and both int and float requires atleast 32 bits.

13.

The value 132.54 can be represented using which data type?(a) double(b) void(c) int(d) boolI have been asked this question during a job interview.Question is taken from Types in chapter Types, Pointers, Arrays & Structures in C++ of C++

Answer» CORRECT option is (a) DOUBLE

The explanation: The GIVEN value is with decimal points, so float or double can be used.
14.

Which data type is used to represent the absence of parameters?(a) int(b) short(c) void(d) floatI got this question by my college professor while I was bunking the class.The query is from Types topic in section Types, Pointers, Arrays & Structures in C++ of C++

Answer»

Correct option is (C) VOID

The explanation is: Because void SPECIFIES an EMPTY set of values/parameters.

15.

Is the size of character literals different in C and C++?(a) Implementation defined(b) Can’t say(c) Yes, they are different(d) No, they are not differentThis question was posed to me in a job interview.This interesting question is from Character Types in chapter Types, Pointers, Arrays & Structures in C++ of C++

Answer»

Right choice is (C) YES, they are different

Easiest EXPLANATION - In C++, SIZEOF(‘a’) == sizeof(char) == 1. In C however, sizeof(‘a’) == sizeof(INT).

16.

What will be used when terminating a structure?(a) :(b) }(c) ;(d) ;;This question was posed to me in an international level competition.Question is from Structures topic in section Types, Pointers, Arrays & Structures in C++ of C++

Answer»

The CORRECT CHOICE is (c) ;

EASIEST EXPLANATION - While terminating a structure, a semicolon is USED to end this up.

17.

The data elements in the structure are also known as what?(a) objects(b) members(c) data(d) objects & dataI got this question in semester exam.This intriguing question comes from Structures topic in portion Types, Pointers, Arrays & Structures in C++ of C++

Answer»

Right answer is (b) members

The best I can explain: VARIABLES DECLARED INSIDE a class are called as data ELEMENTS or data members.

18.

What are the references in C++?(a) An alternative name for already existing variables(b) A pointer to a variable(c) A new type of variables(d) A new type of constant variableThis question was posed to me in an internship interview.My question is based upon References in chapter Types, Pointers, Arrays & Structures in C++ of C++

Answer»

Right answer is (a) An alternative name for already existing variables

Explanation: REFERENCES are an alternative name for an already defined variable. They are DIFFERENT from POINTERS.

19.

The constants are also called as _____________(a) const(b) preprocessor(c) literals(d) variablesI had been asked this question in my homework.I'd like to ask this question from Constants in portion Types, Pointers, Arrays & Structures in C++ of C++

Answer»

Correct ANSWER is (C) literals

Easiest explanation - Other name for CONSTANTS are literals.

20.

Which of these expressions will make the rightmost set bit zero in an input integer x?(a) x = x | (x-1)(b) x = x & (x-1)(c) x = x | (x+1)(d) x = x & (x+2)I got this question in an interview for job.Question is from Integer Types in division Types, Pointers, Arrays & Structures in C++ of C++

Answer»

The correct OPTION is (b) x = x & (x-1)

The explanation: If x is odd the last bit will be 1 and last bit of x-1 will BECOME 0. If x is EVEN then last bit of x will be 0 and last bit of x-1 will become 1. In both case AND operation of 1 and 0 will be 0. Hence last bit of final x will be 0.

21.

Which of these expressions will return true if the input integer v is a power of two?(a) (v | (v + 1)) == 0;(b) (~v & (v – 1)) == 0;(c) (v | (v – 1)) == 0;(d) (v & (v – 1)) == 0;I got this question in an international level competition.The query is from Integer Types topic in portion Types, Pointers, Arrays & Structures in C++ of C++

Answer»

Right answer is (d) (v & (v – 1)) == 0;

Explanation: POWER of TWO integers have a SINGLE set bit followed by unset bits.

22.

The size_t integer type in C++ is?(a) Unsigned integer of at least 64 bits(b) Signed integer of at least 16 bits(c) Unsigned integer of at least 16 bits(d) Signed integer of at least 64 bitsThis question was addressed to me in final exam.The question is from Integer Types in portion Types, Pointers, Arrays & Structures in C++ of C++

Answer»

The correct answer is (c) Unsigned INTEGER of at least 16 bits

Explanation: The size_t TYPE is used to represent the size of an OBJECT. Hence, it’s always unsigned. According to the language SPECIFICATION, it is at least 16 bits.

23.

For what values of the expression is an if-statement block not executed?(a) 0 and all negative values(b) 0 and -1(c) 0(d) 0, all negative values, all positive values except 1I have been asked this question at a job interview.My enquiry is from Booleans topic in chapter Types, Pointers, Arrays & Structures in C++ of C++

Answer» CORRECT choice is (c) 0

Best explanation: The if-statement BLOCK is only not executed when the expression evaluates to 0. its just SYNTACTIC sugar for a branch-if-zero INSTRUCTION.
24.

Pick the odd one out.(a) array type(b) character type(c) boolean type(d) integer typeI have been asked this question during an interview.Question is taken from Types topic in division Types, Pointers, Arrays & Structures in C++ of C++

Answer»

Correct ANSWER is (a) array type

Explanation: Array type is not the BASIC type and it is CONSTRUCTED USING the basic type.

25.

Identify the incorrect statement.(a) Reference is the alternate name of the object(b) A reference value once defined can be reassigned(c) A reference value once defined cannot be reassigned(d) Reference is the alternate name of the variableThis question was posed to me in exam.My enquiry is from References topic in section Types, Pointers, Arrays & Structures in C++ of C++

Answer»

Correct CHOICE is (b) A reference value once defined can be reassigned

To EXPLAIN I would say: Reference is a thing which points to the valid MEMORY address, so it can’t be redesigned.

26.

The size of an object or a type can be determined using which operator?(a) malloc(b) sizeof(c) malloc(d) callocI got this question in unit test.My question is taken from Sizes topic in portion Types, Pointers, Arrays & Structures in C++ of C++

Answer» RIGHT choice is (b) sizeof

For explanation: The sizeof operator gives the SIZE of the object or type.
27.

Which of the following statements are false?(a) bool can have two values and can be used to express logical expressions(b) bool cannot be used as the type of the result of the function(c) bool can be converted into integers implicitly(d) a bool value can be used in arithmetic expressionsThe question was posed to me by my college director while I was bunking the class.The doubt is from Booleans in portion Types, Pointers, Arrays & Structures in C++ of C++

Answer»

The CORRECT CHOICE is (b) bool cannot be USED as the type of the result of the FUNCTION

Easy explanation - BOOLEAN can be used as a return value of a function.

28.

A void pointer cannot point to which of these?(a) methods in c++(b) class member in c++(c) methods & class member in c++(d) none of the mentionedI have been asked this question in a job interview.My doubt is from Pointer to Void in portion Types, Pointers, Arrays & Structures in C++ of C++

Answer»

Right CHOICE is (d) none of the mentioned

To explain I would say: A VOID pointer can point to METHODS & CLASS member in c++.

29.

Pick the correct statement about references.(a) References can be assigned value NULL(b) References once assigned cannot be changed to refer another variable(c) Reference should not be initialized when created(d) Reference is the same as pointersThis question was posed to me during an online exam.This interesting question is from References in section Types, Pointers, Arrays & Structures in C++ of C++

Answer»

The correct option is (b) References once ASSIGNED cannot be changed to refer another variable

Easy EXPLANATION - References are should be initialized during its creation and once assigned cannot be changed to refer another variable. References cannot be assigned NULL value. References and POINTERS are TWO DIFFERENT concepts.

30.

Which reference modifier is used to define the reference variable?(a) &(b) $(c) #(d) @This question was addressed to me in an interview for job.Query is from References topic in section Types, Pointers, Arrays & Structures in C++ of C++

Answer» CORRECT ANSWER is (a) &

The EXPLANATION: & aka ‘AMPERSAND’ used to define a reference variable.
31.

The difference between x and ‘x’ is?(a) The first one refers to a variable whose identifier is x and the second one refers to the character constant x(b) The first one is a character constant x and the second one is the string literal x(c) Both are same(d) Both are string literalI had been asked this question in exam.This key question is from Constants topic in portion Types, Pointers, Arrays & Structures in C++ of C++

Answer»

The correct answer is (a) The first one refers to a variable whose identifier is x and the SECOND one refers to the character CONSTANT x

For explanation: In a C++ code, names with quotes like ‘x’ REPRESENT a character or STRING(in CASE of a collection of characters) whereas without quotes they represent an identifier.

32.

Identify the incorrect option.(a) enumerators are constants(b) enumerators are user-defined types(c) enumerators are same as macros(d) enumerator values start from 0 by defaultI got this question by my college professor while I was bunking the class.I need to ask this question from Enumerations in chapter Types, Pointers, Arrays & Structures in C++ of C++

Answer» CORRECT choice is (C) enumerators are same as MACROS

The EXPLANATION is: Enumerators are used in order to CREATE our own types whereas macros are textual substitutions.
33.

Which function is used to check whether a character is an alphabet or number?(a) isalpha()(b) isalnum()(c) isdigit()(d) isblank()This question was addressed to me during an online interview.The doubt is from Character Classification topic in section Types, Pointers, Arrays & Structures in C++ of C++

Answer»

The correct choice is (B) isalnum()

The EXPLANATION is: Character classification provides isalnum() function to check WHETHER a character in C++ is ALPHABET or number.

34.

What will happen when defining the enumerated type?(a) it will not allocate memory(b) it will allocate memory(c) it will not allocate memory to its variables(d) allocate memory to objectsThis question was posed to me in a national level competition.The above asked question is from Enumerations topic in section Types, Pointers, Arrays & Structures in C++ of C++

Answer»

Right CHOICE is (a) it will not allocate MEMORY

Easiest EXPLANATION - Enumerator will allocate the memory when its variables are DEFINED.

35.

Implementation dependent aspects about an implementation can be found in ____(a) (b) (c) (d) I got this question in a job interview.Query is from Sizes in division Types, Pointers, Arrays & Structures in C++ of C++

Answer» CORRECT ANSWER is (B)

For EXPLANATION: The limit header holds the details of the machine dependent details.
36.

Which of the following is a valid floating-point literal?(a) f287.333(b) F287.333(c) 287.e2(d) 287.3.e2I have been asked this question in semester exam.My doubt stems from Floating Point Types topic in section Types, Pointers, Arrays & Structures in C++ of C++

Answer» RIGHT CHOICE is (c) 287.e2

Explanation: To make a floating point literal, we should attach a suffix of ‘f’ or ‘F’ and there should not be any BLANK space.
37.

Which of three sizes of floating point types should be used when extended precision is required?(a) float(b) double(c) long double(d) extended floatThe question was posed to me in semester exam.My enquiry is from Floating Point Types topic in division Types, Pointers, Arrays & Structures in C++ of C++

Answer»

The correct ANSWER is (c) LONG double

Explanation: FLOAT for SINGLE PRECISION, double for double precision and long double for extended precision.

38.

What is the range of the floating point numbers?(a) -3.4E+38 to +3.4E+38(b) -3.4E+38 to +3.4E+34(c) -3.4E+38 to +3.4E+36(d) -3.4E+38 to +3.4E+32This question was addressed to me in examination.The query is from Floating Point Types topic in portion Types, Pointers, Arrays & Structures in C++ of C++

Answer»

The correct choice is (a) -3.4E+38 to +3.4E+38

Best EXPLANATION: This is the defined RANGE of floating type number sin C++. Also range for +ve and -ve SIDE should be same so the answer is -3.4E+38 to +3.4E+38.

39.

Which of the following is not one of the sizes of the floating point types?(a) short float(b) float(c) long double(d) doubleThis question was addressed to me by my school teacher while I was bunking the class.Enquiry is from Floating Point Types in portion Types, Pointers, Arrays & Structures in C++ of C++

Answer»

Right choice is (a) SHORT float

The best explanation: FLOATING POINT TYPES occur in only three sizes-float, long double and double.

40.

Is bool a fundamental data type in C++?(a) Yes(b) No, it is a typedef of unsigned char(c) No, it is an enum of {false, true}(d) No, it is expanded from macrosThis question was posed to me by my school teacher while I was bunking the class.This key question is from Booleans topic in chapter Types, Pointers, Arrays & Structures in C++ of C++

Answer»

The correct OPTION is (a) Yes

To explain: C++ has BOOL as a FUNDAMENTAL DATA TYPE.

41.

What are the parts of the literal constants?(a) integer numerals(b) floating-point numerals(c) strings and boolean values(d) all of the mentionedThis question was posed to me in class test.The question is from Constants topic in division Types, Pointers, Arrays & Structures in C++ of C++

Answer»

The CORRECT answer is (d) all of the mentioned

Explanation: Because these are the types USED to declare variables and so these can be DECLARED as CONSTANTS.

42.

Which of the following accesses the seventh element stored in array?(a) array[6];(b) array[7];(c) array(7);(d) array;This question was addressed to me during an online exam.The above asked question is from Arrays topic in section Types, Pointers, Arrays & Structures in C++ of C++

Answer»

Right answer is (a) ARRAY[6];

Easiest EXPLANATION - The array LOCATION STARTS from zero, So it can accessed by array[6].

43.

To which of these enumerators can be assigned?(a) integer(b) negative(c) enumerator(d) all of the mentionedThis question was addressed to me in an interview.Question is from Enumerations topic in chapter Types, Pointers, Arrays & Structures in C++ of C++

Answer»

Correct OPTION is (d) all of the mentioned

The best explanation: Since ENUMERATORS EVALUATE to integers, and integers can be assigned to enumerators, enumerators can be assigned to other enumerators.

44.

Which of the following will not return a value?(a) null(b) void(c) empty(d) freeI have been asked this question in homework.I want to ask this question from Void in section Types, Pointers, Arrays & Structures in C++ of C++

Answer»

The correct OPTION is (b) void

The EXPLANATION: Because void represents an EMPTY set of values so NOTHING will be return.

45.

Find the odd one out.(a) std::vector(b) std::vector(c) std::vector(d) std::vectorThe question was posed to me in an internship interview.My query is from Booleans topic in section Types, Pointers, Arrays & Structures in C++ of C++

Answer»

Right answer is (d) std::VECTOR

The explanation is: std::vector is a specialized version of vector, which is used for elements of TYPE bool and optimizes for SPACE. It behaves like the unspecialized version of vector and the storage is not necessarily an array of bool values, but the library IMPLEMENTATION may optimize storage so that each VALUE is stored in a single bit.

46.

Which value can we not assign to reference?(a) integer(b) floating(c) unsigned(d) nullI had been asked this question in final exam.This question is from References in portion Types, Pointers, Arrays & Structures in C++ of C++

Answer»

The correct choice is (d) NULL

Explanation: If it can be ASSIGNED with a null value means, it is a COPY of the POINTER.

47.

When a language has the capability to produce new data type mean, it can be called as(a) overloaded(b) extensible(c) encapsulated(d) reprehensibleThis question was posed to me during an online exam.The question is from Types in portion Types, Pointers, Arrays & Structures in C++ of C++

Answer»

Right CHOICE is (b) EXTENSIBLE

Best explanation: Extensible is used to ADD new features to C++.

48.

Which of the following is illegal?(a) int *ip;(b) string s, *sp = 0;(c) int i; double* dp = &i;(d) int *pi = 0;I have been asked this question in an international level competition.The above asked question is from Pointers in chapter Types, Pointers, Arrays & Structures in C++ of C++

Answer»

Correct ANSWER is (c) INT i; DOUBLE* DP = &i;

The best explanation: dp is INITIALIZED int value of i.

49.

______________ have the return type void.(a) all functions(b) constructors(c) destructors(d) none of the mentionedI have been asked this question during an interview.This interesting question is from Void in division Types, Pointers, Arrays & Structures in C++ of C++

Answer»

The correct OPTION is (d) none of the mentioned

To EXPLAIN: Constructor CREATES an OBJECT and DESTRUCTOR destroys the object. They are not supposed to return anything, not even void.

50.

Size of C++ objects are expressed in terms of multiples of the size of a ____ and the size of a char is _______(a) char, 1(b) int, 1(c) float, 8(d) char, 4The question was posed to me in semester exam.I'd like to ask this question from Sizes in portion Types, Pointers, Arrays & Structures in C++ of C++

Answer»

Right OPTION is (a) char, 1

Best explanation: Each object in C++ is expressed in terms of char type and size of char type is ONE BYTE.