Attempt this MCQ. I will post its answers after 2 days
Kulachi Hansraj Model School
Multiple Choice Questioner
(General Concepts, Header Files, File Handling)
Class XII
Time : 15 min. M.Marks : 30
1. When working with character arrays, always reserve enough array elements to hold the string AND its null-terminating character (\0).
[a] True [b] False
2. In C++, 14 % 4 =
[a] 1 [b] 2 [c] 3 [d] 4
3. Variables that are declared, but not initialized, contain
[a] blank spaces [b] zeros [c] "garbage" values [d] nothing - they are empty
4. Array indexing always starts with the number
[a] 0 [b] 1 [c] 2 [d] \0
5. A character variable may contain up to seven letters.
[a] True [b] False
6. All strings end with a null zero in memory.
[a] True [b] False
7. The name of a variable is known as its
[a] identifier [b] constant
[c] data type [d] base
8. In C++, the % refers to
[a] percentages [b] modulus operator
[c] division [d] data storage
9. A variable is given a value through
[a] osmosis [b] the cout statement
[c] the header file [d] an assignment statement
10. Variable names may begin with a number.
[a] True [b] False
11. When a data type must contain decimal numbers, assign the type
[a] int [b] char [c] double [d] long int
12. Mathematicians and computers interpret the equal sign (=) in the same way.
[a] True [b] False
13. setprecision requires the header file
[a] stdlib.h [b] iomanip.h [c] console.h [d] conio.h
14. The following statement is valid. double price = 7,450.98;
[a] True [b] False
15. All variables must be declared before they can be used.
[a] True [b] False
16. Character literals always have a length of one.
[a] True [b] False
17. If char catname[15]; , which of the following is valid?
[a] catname[15] = "Millie"; [b] catname = "Millie";
[c] catname[ ] = "Millie"; [d] none are valid
18. Which type of data file is analogous to an audio cassette tape?
[a] random access file [b] sequential access file
[c] binary file [d] source code file
19. Which of the following header files is required for creating and reading data files?
[a] ofstream.h [b] fstream.h
[c] ifstream.h [d] console.h
20. If you create a file with the same name as an existing file, you will be prompted to rename your new file.
[a] True [b] False
21. In the code fout.open("scores.dat", ios::out);
[a] ios::out is the stream operation mode.
[b] fout is the header file reference.
[c] ios::out is the stream variable name..
[d] fout is the name of the file.
22. A text editor can be used to view, or create, a file.
[a] True [b] False
23. What header file contains C++ file I/O instructions?
[a] iostream.h [b] fstream.h
[c] infstream.h [d] outstream.h
24. ifstream fin; would be used when
[a] creating a file [b] reading a file
[c] appending a file [d] removing a file
25. eof( ) is the function used for
[a] asserting no errors in a file [b] appending data to a file
[c] counting the amount of data in a file [d] checking for end of file
26. If a file you are opening for appending does not exist, the operating system will detect the missing file and terminate the operation.
[a] True [b] False
27. It is possible to open several files for access at the same time.
[a] True [b] False
28. Which of the following is not a valid ofstream argument?
[a] ios::app [b] ios::trunc
[c] ios::noreplace [d] ios::create
29. What does ios::ate mean as an argument to ofstream?
[a] Open file, but do not create. [b]Open file, create.
[c] Open file for read access only.[d]Open file, set the position to the end.
30. How would you output to an open file named a_file?
[a] a_file.out("Output"); [b] a_file="Output";
[c] a_file<<"Output"; [d]a_file.printf("Output");