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.

51.

How many maximum number of parameters does a string constructor can take?(a) 1(b) 2(c) 3(d) 4This question was addressed to me in an interview.This key question is from Basic String topic in section Strings, Streams & Numerics in C++ of C++

Answer» CORRECT CHOICE is (c) 3

To explain: string(other_string, position, COUNT). It is a type of constructor for the string.
52.

Which of the following is the default mode of the opening using the ofstream class?(a) ios::in(b) ios::out(c) ios::app(d) ios::truncThe question was posed to me during an interview for a job.My question is based upon File Handling topic in division Strings, Streams & Numerics in C++ of C++

Answer»

Correct OPTION is (B) ios::out

Explanation: By default, the FILE is opened in ios::out mode if the file object we are USING is of ofstream class.

53.

What is the use of ios::trunc mode?(a) To open a file in input mode(b) To open a file in output mode(c) To truncate an existing file to half(d) To truncate an existing file to zeroThis question was posed to me in an internship interview.I'm obligated to ask this question of File Handling topic in section Strings, Streams & Numerics in C++ of C++

Answer»

Right option is (d) To TRUNCATE an existing FILE to ZERO

Easy explanation - In C++ file HANDLING, IOS::trunc mode is used to truncate an existing file to zero length.

54.

Which of the following is used to create an output stream?(a) ofstream(b) ifstream(c) iostream(d) fsstreamI have been asked this question in class test.My enquiry is from File Handling in chapter Strings, Streams & Numerics in C++ of C++

Answer»

Right choice is (a) ofstream

The explanation: ofstream is used to create an output stream in C++ FILE handling operations. Ofstream OBJECTS are used to read FILES.

55.

Which operator is used to produce a certain number in a specific range?(a) $(b) %(c) modulo operator(d) both % and modulo operatorI have been asked this question in my homework.This interesting question is from Random Numbers topic in chapter Strings, Streams & Numerics in C++ of C++

Answer»

The correct answer is (d) both % and MODULO OPERATOR

The EXPLANATION: In C++, modulo operator is DENOTED by %.

56.

Which header file is used to create the pseudo random generator?(a) random(b) cstdlib(c) rand(d) both random and cstdlibThis question was posed to me in an online quiz.My question is taken from Random Numbers topic in section Strings, Streams & Numerics in C++ of C++

Answer»

The correct answer is (d) both RANDOM and cstdlib

The explanation is: cstdlib header file is used to create PSEUDO random number. C++11 STANDARD added random header file as well to generate random NUMBERS.

57.

Which objects information is loaded in locale object?(a) facet object(b) instead object(c) Both facet & instead object(d) secant objectThis question was posed to me in exam.My question is from Locale in division Strings, Streams & Numerics in C++ of C++

Answer»

The correct choice is (a) FACET object

The best EXPLANATION: A locale object contains information about which facet objects CONSTITUTE a locale, and is each one of these facet objects that IMPLEMENTS specific features as member functions.

58.

Which member function is used to determine whether the stream object is currently associated with a file?(a) is_open(b) buf(c) string(d) is_outThis question was addressed to me in homework.My enquiry is from File Streams and String Streams topic in division Strings, Streams & Numerics in C++ of C++

Answer»

Right option is (a) is_open

To explain: The MEMBER function is_open can be USED to DETERMINE whether the STREAM object is CURRENTLY associated with a file.

59.

How does the limits.h header file can be represented in C++?(a) limits(b) limit(c) climits(d) dlimitsI got this question during an online interview.This intriguing question comes from C Standard Library in division Strings, Streams & Numerics in C++ of C++

Answer»

Correct option is (c) climits

For explanation: Any STANDARD LIBRARY of C can be WRITTEN in C++ by using ‘c’ in front of header FILE name and omitting the ‘.h’. for example can be written as .

60.

How many parameters are available in srand function?(a) 1(b) 2(c) 3(d) 4This question was posed to me during an interview.My doubt stems from Random Numbers topic in chapter Strings, Streams & Numerics in C++ of C++

Answer»

The CORRECT answer is (a) 1

The explanation is: There is one parameter available in srand function. That is an INTEGER value to be USED as seed by the pseudo-random number GENERATOR algorithm.

61.

Which operator is used to insert the data into file?(a) >>(b)

Answer» CORRECT choice is (b) <<

The explanation is: You can write information to a FILE from your program using the STREAM insertion operator <<.>
62.

Which header file is used to operate on numeric sequences?(a) number(b) numeric(c) algorithm(d) digitI got this question in unit test.I want to ask this question from Generalized Numeric Algorithms in section Strings, Streams & Numerics in C++ of C++

Answer»

Correct CHOICE is (b) NUMERIC

For explanation: HEADER file is used to operate on numeric sequences that SUPPORT certain operations.

63.

Which function is used to reposition the file pointer?(a) moveg()(b) seekg()(c) changep()(d) go_p()I had been asked this question in an interview.This interesting question is from File Handling topic in division Strings, Streams & Numerics in C++ of C++

Answer»

Correct CHOICE is (b) SEEKG()

Explanation: seekg() function is used to reposition a file POINTER in a file. The function takes the offset and relative position from where we NEED to SHIFT out pointer.

64.

Which is a constant defined in header file?(a) RAND_MAX(b) Rand(c) Srand(d) BlitzThis question was addressed to me in homework.Asked question is from Random Numbers topic in section Strings, Streams & Numerics in C++ of C++

Answer»

The correct ANSWER is (a) RAND_MAX

Best EXPLANATION: RAND_MAX is a constant defined in for deciding the maximum RANDOM number that can be PRODUCED.

65.

How many indicators are available in c++?(a) 4(b) 3(c) 2(d) 1The question was posed to me in semester exam.My doubt is from C Input Output topic in section Strings, Streams & Numerics in C++ of C++

Answer»

Right option is (B) 3

Easiest explanation - There are THREE indicators are AVAILABLE in C++. They are Error indicator, End-Of-File indicator and Position indicator.

66.

Pick out the correct objects about the instantiation of output stream.(a) cout(b) cerr(c) clog(d) all of the mentionedI have been asked this question in a job interview.Asked question is from Output Stream topic in section Strings, Streams & Numerics in C++ of C++

Answer»

Correct ANSWER is (d) all of the mentioned

To explain I would say: cout, cerr and CLOG are the STANDARD OBJECTS for the instantiation of output stream class.

67.

Which header file is used to manipulate the string?(a) iostream(b) iomanip(c) string(d) containerThe question was posed to me by my school teacher while I was bunking the class.The origin of the question is Basic String topic in chapter Strings, Streams & Numerics in C++ of C++

Answer»

Right OPTION is (c) string

Best explanation: To USE the string CLASS, We have to use #INCLUDE header FILE.