wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

File in C++

Total questions: 25

Worksheet time: 7mins

Name
Class
Date
1.

By default all the files are opened in_____mode

a)

Binary

b)

Text

c)

can't say

2.

It is not possible to combine two or more file opening mode in open() method

a)

True

b)

False

3.

Which of the following is not a file opening mode

a)

ios::ate

b)

ios::nocreate

c)

ios::noreplace

d)

ios::truncate

4.

Due to ios::trunc mode the file is truncated to zero length

a)

False

b)

True

5.

If we have object from of stream class then default mode of opening the file is__________

a)

ios::in

b)

ios::out

c)

ios::in\ios::trunc

d)

ios::out\ios::trunk

6.

_______is return tyoe of is_open() function

a)

int

b)

bool

c)

float

d)

char*

7.

If we have object from fstream class, then what is default mode of opening the file

a)

ios::in\ios::out

b)

ios::in\ios::trunc

c)

default mode depends on compiler

8.

To create an output stream we must declare the stream to be of class

a)

ofstream

b)

ifstream

c)

iostream

d)

none of these

9.

Streams that will be performing both input and output operation must be declared as class

a)

iostream

b)

f stream

c)

stdtream

d)

stdiostream

10.

To perform file I/O operations,we must use ________header file

a)

<if stream>

b)

<of stream>

c)

<f stream>

d)

none of these

11.

Which of the following is not used to seek a file pointer

a)

ios::cur

b)

ios::set

c)

ios::end

d)

los::begl

12.

ios::trunc is used for

a)

if the file is opened for output operation and it already existed its previous content in deleted and replaced by new one

b)

if the file is opened for output operation and it already existed then a new copy is created

13.

Which is correct syntax

a)

Myfile:open

b)

Myfile.open

c)

My::open

14.

Calling the stream member function sync() causes the immediate synchronization

a)

True

b)

False

15.

eof() is used to get

a)

easy code reivew

b)

end of file

c)

debug report

d)

file close

16.

Which among is used for positioning relative to the beginnig of a stream

a)

ios::start

b)

ios::beg

c)

ios::begin

d)

ios::beginning

17.

Which function is used to reposition the file pointer

a)

moveg()

b)

seekg()

c)

changep()

d)

go_p()

18.

which function is used in c++ to get the current position of file pointer in a file

a)

tell_p()

b)

get_pos()

c)

get_p()

d)

tell_pos()

19.

What is use of eof()

a)

returns true if a file open for reading has reached the next character

b)

returns true if a file open for reading has reached the next word

c)

returns true if a file open for reading has reached the end

20.

what must be specified when we construct an object of class ostream

a)

stream

b)

streambuf

c)

memory

d)

none of the mentioned

21.

what is meant by ofstream in c++

(a)  

22.

what can be used to input a string with blankspace

(a)  

23.

how many group of output of operation are there in C++

a)

1

b)

2

c)

3

d)

4

24.

pick out the correct object about the instantiation of output stream

a)

cout

b)

cerr

c)

clog

d)

all of the mentioned

25.

in order to open a file with a stream object we use its (a)   function