Test Series - cpp

Test Number 95/102

Q: Which operator is used to insert the data into file?
A. >>
B. <<
C. <
D. >
Solution: You can write information to a file from your program using the stream insertion operator <<.
Q: Which function is used to position back from the end of file object?
A. seekg
B. seekp
C. both seekg & seekp
D. seekf
Solution: The member function seekg is used to position back from the end of file object.
Q: How many objects are used for input and output to a string?
A. 1
B. 2
C. 3
D. 4
Solution: The stringstream, ostringstream, and istringstream objects are used for input and output to a string.
Q: 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_out
Solution: The member function is_open can be used to determine whether the stream object is currently associated with a file.
Q: Which header file is used for reading and writing to a file?
A. #include
B. #include
C. #include
D. #include
Solution:  header file contains all the file reading and writing functions. Also  and  contains functions only reading and only writing to files related functions respectively.
Q: Which one is always faster in writing on C++?
A. Writing to a file
B. Writing to memory
C. Reading from the network
D. Deleting a file
Solution: For the stand of file operations, writing to memory (RAM) is always faster than writing to the file on the disk directly.
Q: How many tests are available in read and write operations?
A. 1
B. 2
C. 3
D. 4
Solution: There are two types of read and write tests. They are throughput in random reads and throughput in contiguous reads.
Q: What will act as a intermediate between i/o operations and physical file?
A. Memory
B. Ram
C. Stream buffer
D. Storage
Solution: A stream buffer is a block of data that acts as intermediary between the i/o operations and the physical file associated to the stream.
Q: By using which function does the buffer are automatically flushed?
A. fopen
B. copy
C. compare
D. fclose
Solution: fclose() is used to close the file and flush it out of memory for safe closing of files opened during the execution of program. In short to avoid memory faults during the execution of the program.
Q: How many parameters are available in the function setbuf?
A. 1
B. 2
C. 3
D. 4
Solution: There are two parameters that are used in setbuf. They are stream and buffer.

You Have Score    /10