Home Tuitions

CUET CS Chapter-Data Communication 

Board CBSE
Textbook NCERT
Class Class 12
Subject Computer Science
Chapter CUET CS Chapter-Data Communication 
Chapter Name Data Communication
Category CUET (Common University Entrance Test) UG

MCQ-Based Questions for CUET Computer Science Chapter-Data Communication 

This page is prepared by HT experts and consists of MCQ-Based Questions for CUET Computer Science chapter-Data Communication with a detailed explanation of all the questions asked from Data Communication. To find the solution to the MCQ questions click on the answer tab. Check out chapter-wise CUET computer science Practice MCQ Based Questions. 

Practice Questions for CUET Computer Science chapter-Data Communication SET-1

Computer Science - MCQ on Database Concepts

Class XII

Q.1 Duplication of data is known as

a) data inconsistency.

b) data sharing.

c) data security.

d) data redundancy.

Answer:

(c)

Explanation: Data sharing is individual pieces of data shared among different users. Data security is protection of data against unauthorized access and data inconsistency means incorrect data.

Q.2 DBMS stands for

a) database management system.

b) digital based mapping system.

c) database manipulation software.

d) database mapping system.

Answer:

(a)

Explanation: DBMS is system software, which consists of interrelated databases and operations to manage databases.

Q.3 A set of attributes that can uniquely identify tuples within the relation

is known as

a) alternate key.

b) primary key.

c) secondary key.

d) candidate key.

Ans. b

Explanation: Primary key is called so because it helps to distinguish from one relation from another.

Q.4 Cardinality of relation represents

a) number of rows in a table.

b) number of columns in a table.

c) both rows and columns.

d) number of keys.

Answer:

(a)

Explanation: Cardinality refers to number of elements in a set. Number of elements represents the number of rows in a set.

Q.5 The data model, which is not used for database management, is

a) relational data model.

b) network data model.

c) tree data model.

d) hierarchical data model.

Answer:

(c)

Explanation: Except tree model is not used for database management. All the other models are used for managing the database systems.

Q.6 A virtual table derived from one or more base tables is known as

a) parent table.

b) view.

c) child table.

d) base table.

Answer:

(b)

Explanation: The view is a kind of table, whose contents are taken upon other tables depending upon a given query condition. No stored file is created to store the contents of a view rather its definition is stored only.

Q.7 A language providing a set of operators for manipulating relations is called

a) relational algebra.

b) set difference.

c) natural join.

d) set intersection.

Answer:

(a)

Explanation: The relational algebra is a collection of operations on relations. Each operation takes one or more relations as its operands and produces another relation as its result.

Q.8 The operation, which is not used in relational algebra is

a) select.

b) join.

c) cartesian product.

d) tuple.

Answer:

(d)

Explanation: Tuple refers to the rows of tables. The various operations of relation algebra are select, project, cartesian product, union, set difference, set intersection, join and division.

Q.9 The data model in which the data is represented by pointers is called

a) relational data model.

b) hierarchical data model.

c) network data model.

d) conceptual data model.

Answer:

(c)

Explanation: A network data model represents data by collection of records. Relationships among data are represented by links (pointers).

Q.10 The data model in which data is represented in form of trees is called

a) relational data model.

b) hierarchical data model.

c) network data model.

d) database model.

Answer:

(b)

Explanation: A hierarchical data model represents data by records organized in form of trees and relationships among data are represented by links.

Q.11 The type of user, which does not work on database systems, is

a) physical storage system analyst.

b) end user.

c) application system analyst.

d) database analyst.

Answer:

(d)

Explanation: The other type of users apart from database analyst, are differentiated by the way they interact with the system. End user uses the database to retrieve some information. Physical storage system analyst is concerned with the physical implementation details of the database and application system analyst is concerned about the entire database at logical level.

Q.12 The ability to modify the scheme at physical level without affecting the scheme at conceptual level is known as

a) logical modification.

b) physical data independence.

c) physical modification.

d) logical data independence.

Answer:

(b)

Explanation: In physical data independence, the application programs remain the same even though the scheme at physical level gets modified. This is done in order to improve the performance of the system.

Q.13 The ability to modify the conceptual scheme without causing changes in the scheme at view level is known as

a) logical data independence.

b) view modification.

c) conceptual modification.

d) physical data independence.

Answer:

(a)

Explanation: The logical data independence ensures that the application program remains the same. Modifications at the conceptual level are necessary whenever a logical structure of the data gets altered.

Q.14 The size of database are usually measured in terms of

a) terabytes.

b) megabytes.

c) gigabytes.

d) databytes.

Answer:

(c)

Explanation: Gigabyte is a multiple of the unit byte for digital information storage. Since the giga prefix means 109, gigabyte means 1,000,000,000 bytes (10003, 109). Size of database is measured in gigabytes.

Q.15 The structure, which is not a logical database structure, is

a) chain.

b) network.

c) tree.

d) relational.

Answer:

(a)

Explanation: Structure in the form of chains is not allowed in database systems. Network, tree and relational data structure are the standard ways to represent the data in database systems.

Q.16 An organized collection of logically related data is known as

a) data.

b) database.

c) information.

d) metadata.

Answer:

(b)

Explanation: A database is a collection of interrelated data stored together to serve multiple applications.

Q.17 The level of database implementation, which is closest to users, is

a) view level.

b) physical level.

c) internal level.

d) user level.

Answer:

(a)

Explanation: View level is concerned with the way in which the data are viewed by individual users. It is also known as external level.

Q.18 The abstract data type uses the concept of

a) data abstraction.

b) data integrity.

c) data redundancy.

d) data independence.

Answer:

(d)

Explanation: The abstract data type implement the concept of data independence in the sense both hide implementation details from the users.

Q.19 The projection operation in relational algebra is represented by

a) p.

b) D.

c) d.

d) S.

Answer:

(a)

Explanation: The projection extracts columns from a relation and is represented by p.

Q.20 The selection operation in relational algebra is represented by

a) W.

b) ".

c) s.

d) q.

Answer:

(c)

Explanation: The selection extracts tuples from a relation depending upon a condition and is represented by s.

Q.21 The number of attributes in a relation is known as

a) degree.

b) rank.

c) key.

d) cardinality.

Answer:

(a)

Explanation: Relation consists of number of attributes and this number is known as degree.

Q.22 The database model in which data is represented in form of table is

a) relational data model.

b) hierarchical data model.

c) internal data model.

d) external data model.

Answer:

(a)

Explanation: A relational data model is a model, which organizes the data into tables i.e. data is arranged in rows and columns.

Q.23 The process of data analysis used for grouping data is known as

a) cartesian product.

b) normalization.

c) projection.

d) cardinality.

Answer:

(b)

Explanation: Normalization is a basic concept used in analyzing data. This process in turn reduces the redundancy in the system.

Q.24 The command used in manipulating the database is known as

a) DML.

b) DDL.

c) DCL.

d) TCL.

Answer:

(a)

Explanation: DML stands for data manipulation language. It provides commands to insert, delete and modify tuples in the database.

Q.25 The command used in creating and maintaining the database is

a) DML.

b) DDL.

c) DCL.

d) TCL.

Answer:

(b)

Explanation: DDL stands for data definition language. It provides statement for creating and deleting the database.

Q.26 The rule, which states the value of primary key can never be a null value, is

a) referential integrity.

b) entity integrity.

c) data integrity.

d) null integrity.

Answer:

(b)

Explanation: Primary key is a key, which uniquely identify, a specific instance of an entity. Therefore the value of primary key can never be null. The rule, which defines this fact, is known as entity integrity.

Q.27 The relation in which no two rows are identical and each table entry is single valued is

a) 1NF.

b) 2NF.

c) 3NF.

d) 5NF.

Answer:

(a)

Explanation: 1NF is used to remove the redundancy in the system. Therefore there is no delicacy and repetition of values is not allowed.

Q.28 The relation in which each non-key attribute is functionally dependent on the entire key is

a) 1NF.

b) 2NF.

c) 3NF.

d) 5NF.

Answer:

(b)

Explanation: A table is said to be in 2NF, if it is in 1NF and all non-key attributes are totally dependent upon primary key.

Q.29 The relation in which each non-key attribute is no-transitively dependent on the entire key is

a) 1NF.

b) 2NF.

c) 3NF.

d) 4NF.

Ans. c

Explanation: A table is said to be in 3NF, if it is in 2NF and transitively dependency is removed from the table.

Q.30 The function, which is used to combine related tuples from two relations, is

a) intersection.

b) difference.

c) join.

d) projection.

Answer:

(c)

Explanation: In the simplest form the join operation is just the cross product of the two relations. Two interrelated tuples from two different relations and are joined by this function.

Practice Questions for CUET Computer Science chapter-Data Communication SET-2

Q.31 The command used to remove the table physically is

a) alter.

b) drop.

c) delete.

d) insert into.

Answer:

(b)

Explanation: DROP TABLE table_name; is the command used to remove the table.

Q.32 The rule, which is used to specify the value in the certain column must satisfy a Boolean expression, is

a) foreign key constraint.

b) check constraint.

c) table constraint.

d) unique key constraint.

Answer:

(b)

Explanation: A check constraint is the most generic constraint type. The value in certain column should satisfy a truth-value expression. There is no limit to the number of check constraints that one can define on a column.

Q.33 The person responsible for the security and functioning of the database is

a) database administrator.

b) end user.

c) security officer.

d) programmer.

Answer:

(a)

Explanation: DBA is a person, who checks the authenticity of the database, whether database is secure and functioning properly.

Q.34 One of the disadvantages of the database system is that its

a) integrity is maintained.

b) high hardware configuration cost

c) reduced data redundancy.

d) increased durability.

Answer:

(b)

Explanation: Cost of hardware is one of the most important things for a database system. Its hardware configuration cost is high.

Computer Science - MCQ on Data File Handling

Class XII

Q.1 A “student.dat” file exist, with the object of class students. Assume that the file has just been opened through the object fil of fstream class. A single command to place the file pointer to the third record from beginning is

a) file.seek(3*sizeof(student), ios::beg);

b) fil.seekg(3*sizeof(student), ios::beg);

c) file.seek(2*sizeof(student), ios::beg);

d) file.seek(3*size(student), ios::beg);

Answer:

(b)

Explanation: The function seekg() sets current get position in a stream.

Q.2 The building block of the file is

a) field.

b) record.

c) attribute.

d) token.

Answer:

(a)

Explanation: Field is the smaller unit. This is the building block of file. Field is characterized by its size, length and type.

Q.3 The error in the following line is

cin.get().get();

a) The syntax of cin is wrong.

b) Undefined symbol infile.

c) Integer array cannot read getl() function.

d) get( ) cannot return the reference twice.

Answer:

(d)

Explanation: We cannot use two get() simultaneously in cin. get() returns a reference to istream. It can’t return the reference twice.

Q.4 An appropriate C++ statement to open a file named EMP.DAT for output is

a) fileobject.seekg(“EMP.DAT”);

b) ofstream afile((“EMP.DAT”);

c) instream seekg(“EMP.DAT”);

d) instream afile(“EMP.DAT”);

Answer:

(b)

Explanation: ofstream is used for output to a file. For an ofstream object, the file open mode can be either ios::out to output data to a file or ios::app to append data to the end of file.

Q.5 An appropriate C++ statement to go to the beginning of the file at anytime is

a) fileobject.seekg(ios::beg);

b) fileobject.seekg(1,ios::beg);

c) fileobject.seekg(0,ios::beg);

d) fileobject.seekg(ios::begin);

Answer:

(c)

Explanation: fileobject.seekg(0,ios::beg); is the right usage, asthe function seekg( ) sets current get position in a stream.

Q.6 An appropriate C++ statement to go to the 20th byte in a file is

a) fileobject.seekg(ios::beg);

b) fileobject.seekg(20,ios::beg);

c) fileobject.seekg(21,ios::beg);

d) fileobject.seekg(ios::begin);

Answer:

(b)

Explanation:fileobject.seekg(0,ios::beg); is the right usage, asthe function seekg( ) sets current get position in a stream.

Q.7 The pointer that points to the current object being operated upon is

a) specific pointer.

b) current pointer.

c) this pointer.

d) internal pointer.

Answer:

(c)

Explanation: this is the internal pointer maintained by C++ as a self-referential pointer to the host class.

Q.8 A key field is used to

a) to verify the record.

b) to check if the record is present or not.

c) to identify the record.

d) to check the number of attributes in a field.

Answer:

(c)

Explanation: A key field is a field or set of fields of a database (typically a relational database) table, which together form a unique identifier for a database record (a table entry).

Q.9 The error in the following code is in

int buf[100], n = 10;

cin.getline)( buf, n, ‘\t’);

a) int.

b) buf.

c) cin.

d) getline.

Answer:

(d)

Explanation: The above statement is invalid as integer array cannot be read using getline() function.

Q.10 The number of stream objects required to process four files sequentially is

a) two.

b) three.

c) four.

d) five.

Answer:

(c)

Explanation: In sequential arrangement, the files are processed by using the number of stream object same as the number of files.

Q.11 The number of stream objects required to merge two sorted files into the third file is

a) three.

b) four.

c) five.

d) two.

Answer:

(a)

Explanation: When the two sorted files are merged into a third file, three stream objects are required.

Q.12 The error in the following program is in

char ch;

cin.get(ch).get(ch);

a) char.

b) cin.

c) get.

d) ch.

Answer:

(c)

Explanation:We cannot use two get() simultaneously in cin. get() returns a reference to istream. It can’t return the reference twice.

Q.13 The function which opens a file and attaches it to an existing ofstream object, is

a) openfil().

b) openfile().

c) openfl().

d) open().

Answer:

(d)

Explanation: open() is ofstream member function which opens the file and attaches the file to the ofstream object.

Q.14 The function which closes the stream is

a) closestr().

b) closefile().

c) closef().

d) close().

Answer:

(d)

Explanation: The close() function closes the stream and also closes all the opened stream files.

Q.15 The ostream member function which that outputs a fixed number of bytes beginning with a specific location in memory, is

a) open().

b) read().

c) write().

d) tellp().

Answer:

(c)

Explanation: The write() function expects a first argument of type const char*. When the stream is associated with a file, the data is written at the location specified by the “put” file position pointer.

Q.16 The ostream member function which inputs a fixed number of bytes from the specified stream to an area in memory beginning at a specified address, is

a) open().

b) read().

c) write().

d) tellp().

Answer:

(b)

Explanation: The bytes are input beginning at the location specified by he “get” file position pointer. read() requires a first argument of type char*.

Q.17 The two member functions of ofstream class are

a) open and rdbuf.

b) put and get.

c) set and reset.

d) seekg and seekp.

Answer:

(a)

Explanation: ofstream class is derived from ostream class. It is used to write data onto a file. The member functions of ofstream class are open and rdbuf.

Q.18 The number of ways in which a file can be opened in C++

a) two.

b) three.

c) four

d) five.

Answer:

(a)

Explanation: A file can be opened in C++ in two ways: by using the constructor of the stream class to be used, by using the open() function of the stream class to be used.

Q.19 The two methods in which the file can be opened is

a) using constructor and destructor.

b) using constructor and read() function.

c) using constructor and write() function.

d) using constructor and open() function.

Answer:

(d)

Explanation: A file can be opened in C++ by two methods: by using the constructor of the stream class to be used, and by using the open() function of the stream class to be used.

Q.20 The function of ios::ate is

a) open the file for appending.

b) seek to end of file on opening it.

c) discard contents if file exists.

d) if file doesn’t exist, open fails.

Answer:

(b)

Explanation: ios::ate seeks to end-of-file upon opening of the file. I/O operations can still occur anywhere within the file.

Q.21 The function which sets the file buffers to read and write is

a) ifstream

b) ofstream

c) fstream

d) filebuf

Answer:

(d)

Explanation: In a filebuf object, characters are cleared out of the put area by doing write operations to the file, and characters are put into the get area by doing read operations from that file.

Computer Science - MCQ on Data File Handling

Class XII

Q.1 The function which sets the file buffers to read and write is

a) ifstream.

b) filebuf.

c) ofstream.

d) fstream.

Answer:

(b)

Explanation: In a filebuf object, characters are cleared out of the put area by doing write operations to the file, and characters are put into the get area by doing read operations from that file.

Q.2 The function which provides output operations is

a) ifstream.

b) filebuf.

c) ofstream.

d) fstream.

Answer:

(c)

Explanation: ofstream provides an interface to write data to files as output streams.

Q.3 The function that provides both output and input operations is

a) ifstream.

b) filebuf.

c) ofstream.

d) fstream.

Answer:

(d)

Explanation: fstream is an input-output file stream class. It inherits all the functions from istream and ostream classes through iostream class defied inside iostream.h file.

Q.4 In C++, files are by default treated as

a) text file.

b) binary file.

c) media file.

d) archive file.

Answer:

(a)

Explanation: A text file is a kind of computer file that is structured as a sequence of lines. A text file exists within a computer file system.

Q.5 The functions which manipulates get-pointer and put-pointer in the file are

a) get() and getline().

b) seekg() and seekp().

c) tellg() and tellp().

d) eof() and fail().

Answer:

(b)

Explanation: These functions operate on an offset calculation from the beginning, end, or current position in the stream.

Q.6 The function that determines the end-of-file operation is

a) fail().

b) good().

c) eof().

d) bad().

Answer:

(c)

Explanation: In computing, end-of-file, commonly abbreviated EOF is a condition in a computer operating system where no more data can be read from a data source. The data source is usually called a file or stream.

Q.7 A flow of bytes into or out of a program is known as

a) file.

b) stream.

c) buffer.

d) template.

Answer:

(a)

Explanation: A stream is an abstraction that represents a device on which input and output operations are performed. A stream can basically be represented as a source or destination of characters of indefinite length.

Q.8 Members of ofstream class are

a) seekp() and tellp().

b) get() and put( ).

c) get() and getline().

d) bad() and good().

Answer:

(a)

Explanation: ofstream provides an interface to write data to files as output streams.

Q.9 Functions available for file I/O error handing are

a) bad() and good().

b) seekp() and tellp().

c) get() and put().

d) get() and getline().

Answer:

(a)

Explanation: Whenever an I/O function that takes a file handle as an input parameter raises an error, it will pass this file handle as a third parameter to the error handler function.

Q.10 A constant describing how a file is to be used is known as

a) stream.

b) object.

c) file mode.

d) binary.

Answer:

(c)

Explanation: Property (read-only); the mode of an open file. It can be different from the mode parameter that was passed to open the file if you have repeating attributes (for example, "read, read") or if some attributes were ignored. The property is undefined if the file is closed.

Q.11 The function that sets the current put position in a stream is

a) seekp().

b) tellp().

c) get().

d) put().

Answer:

(a)

Explanation: seekup() sets the position of the put pointer. The put pointer determines the location in the output sequence where the next output operation is going to take place.

Q.12 The link that is used to send the processed data from memory to the file is

a) file-to-memory.

b) memory-to-file.

c) both.

d) file-to-file.

Answer:

(b)

Explanation: Memory-to-file link is used for output purposes in which the data flows from memory to the file.

Q.13 The stream class to which the memory-to-file link is related, is

a) ifstream.

b) ofstream.

c) fstream.

d) instream.

Answer:

(b)

Explanation: ofstream provides an interface to write data to files as output streams.

Q.14 The stream class to which the file-to-memory link is related, is

a) fstream.

b) instream.

c) ofstream.

d) ifstream.

Answer:

(d)

Explanation: ifstream provides an interface to read data from files as input streams.

Q.15 The file in which the data is stored in the form of 0 and 1 is

a) data file.

b) text file.

c) binary file.

d) octal file.

Answer:

(c)

Explanation: The data in the text file is stored in the form of readable characters while the data in the binary file is in the form of binary format, i.e., 0 and 1.

Q.16 A collection of related fields that can be treated as a unit is known as

a) field.

b) record.

c) file.

d) table.

Answer:

(b)

Explanation: A record is a collection of data (related fields).

Q.17 The function used to read a complete string at a time is known as

a) get().

b) getdata().

c) getline().

d) getch().

Answer:

(c)

Explanation: The function getline can be used to read input either from the current input or from a file or pipe, by redirection analogous to printf.

Q.18 The base class for ofstream and ifstream is

a) fstream.

b) istream.

c) ostream.

d) ofistream.

Answer:

(a)

Explanation: fstream is an input-output file stream class. It inherits all the functions from istream and ostream classes through iostream class defied inside iostream.h file.

Q.19 The file in which direct access of record is possible is known as

a) direct file.

b) mapped file.

c) random file.

d) indirect file.

Answer:

(c)

Explanation: Random access files consist of records that can be accessed in any sequence. This means the data is stored exactly as it appears in memory, thus saving the processing time both when the file is written and when it is read.

Q.20 The function that resets the error state so that further operations can be attempted is known as

a) eof( ).

b) bad( ).

c) fail( ).

d) clear( ).

Answer:

(d)

Explanation: clear( ) sets a new value for the error control state. The new ones replace all the bits in the control state. The value existing before the call has no effect.

Q.21 The function which returns nonzero when an input or output operation has failed is known as

a) int bad( ).

b) int eof( ).

c) int fail( ).

d) int good( ).

Answer:

(c)

Explanation: The fail() function returns true if an error has occurred with the current stream, false otherwise. This can be used for checking whether the previous operation has failed.

Q.22 The function which returns nonzero if no error has occurred is known as

a) int good( ).

b) int fail( ).

c) int eof( ).

d) clear( ).

Answer:

(a)

Explanation: The function returns true if none of the stream's error flags are set. This function is not the exact opposite of bad( ), which only checks whether the bad bit error flag is set.

Q.23 C++ statement to open a file named EMP.DAT for output should be

a) ifstream afile(“EMP.DAT”);

b) ofstream afile(“EMP.DAT”);

c) fstream afile(“EMP.DAT”);

d) open afile(“EMP.DAT”);

Answer:

(b)

Explanation: ofstream provides an interface to write data to files as output streams.

Q.24 C++ statement to go to the beginning of the file at anytime will be written as

a) fileobject.seekg(0,ios::beg);

b) ofstream afile(0,ios::beg);

c) ifstream(0,ios::beg);

d) fstream(0,ios::beg);

Answer:

(a)

Explanation: seekg( ) sets the position of the get pointerat the beginning of the file.

Q.25 C++ statement to go to the 20th byte in a file is

a) fileobject.seekg(20,ios:: end);

b) fileobject.seekg(20,ios:: beg);

c) fileobject.ofstream(20,ios:: end);

d) fileobject.ifstream(20,ios:: end);

Answer:

(b)

Explanation: seekg( ) sets the position of the get pointerat the beginning of the file.20 indicates the position of the byte in a file.

Q.26 A file in which the records are organized in no specific order is known

as

a) sequential file.

b) serial file.

c) temporary file.

d) permanent file.

Answer:

(b)

Explanation: A serial file is one in which the records are stored in the order in which they occur. They are not sorted into any particular order.

Q.27 The file-opening mode that discards content if the file exists is

a) ios::app.

b) ios::ate.

c) ios::trunc.

d) ios::nocreate.

Answer:

(c)

Explanation: In ios::trunc, if the file does not exist, a new empty file is created. If the file exists, its content is deleted and it is treated as a new file.

Q.28 The file in which the records are written sequentially is known as

a) serial file.

b) parallel file.

c) sequential file.

d) temporary file.

Answer:

(c)

Explanation: A sequential file is designed for efficient processing of records in sorted order on some search key.

Q.29 The file opening mode, which seeks to end of file on opening it, is

a) ios::ate.

b) ios::app.

c) ios::nocreate.

d) ios::in.

Answer:

(a)

Explanation: ios:ate helps to go to the end of the file when opened.

Q.30 The technique that reduces the number of I/O call is known as

a) polymorphism.

b) inheritance.

c) buffering.

d) encapsulation.

Answer:

(c)

Explanation: Typically, the data is stored in a buffer as it is retrieved from an input device (such as a keyboard) or just before it is sent to an output device (such as a printer).

Q.31 The file opening mode, which opens the file for appending, is

a) ios::app.

b) ios:: binary.

c) ios::nocreate.

d) ios::noreplace.

Answer:

(a)

Explanation: With ios::app, every output is appended at the end of the file.

Q.32 The flag that is used to ignore a whitespace is

a) showbase.

b) showpos.

c) unitbuf.

d) skipws.

Answer:

(d)

Explanation: When the skipws format flag is set, as many whitespace characters as necessary are read and discarded from the stream until a non-whitespace character is found before every extraction operation. Tab spaces, carriage returns and blank spaces are all considered whitespaces.

Q.33 The function that sets floating-point precision and returns previous precision is

a) int ios::precision( ).

b) int ios::precision(int n).

c) int ios::precision(char n).

d) int ios::previousprecision(n).

Answer:

(b)

Explanation: int ios::precision(int n) sets the floating-point precision to 'n'. Returns the previous precision.

Q.34 The base class for fstream, ifstream and ofstream is

a) filebuf.

b) ostreambase.

c) istreambase.

d) fstreambase.

Answer:

(d)

Explanation: fstreambase provides operations common to fstream, ifstream and ofstream file streams. It also contains open() and close() functions.

Q.35 The file mode constant, which causes the open() function to fail if the file already exists is

a) ios :: nocreate.

b) ios :: app.

c) ios :: noreplace.

d) ios :: out.

Answer:

(c)

Explanation: ios :: noreplace causes the open( ) function to fail if the file already exists. This is used when one wants to create a new file and at the same time.

Q.36 To append data in a file, the file is opened in two modes. These modes are

a) output and ios :: app.

b) input and trunc.

c) output and binary.

d) input and ate.

Answer:

(a)

Explanation: Once the file gets opened in ios :: app mode, the previous records is retained and new data gets appended to the file.

Q.37 The output of the following program if the file content before the execution of the program is the string “ABC”

void main()

{ char ch = ‘A’

fstream fileout(“data.dat”,ios::out);

fileout << ch ;

input p = fileout.tellg();

cout << p;

}

a) 0.

b) 1.

c) 2.

d) 3.

Answer:

(b)

Explanation: tellg gets the position of put pointer and therefore the output will be 1.

Q.38 The functions which read and write data respectively, one byte at a time are

a) get() and put().

b) get() and getline().

c) seekg() and seekp().

d) tellg() and tellp().

Answer:

(a)

Explanation: get( ) extracts a character from the stream and returns its value . The put function writes one character to the output stream.

Q.39The function that returns the current error state is

a) clear().

b) int eof().

c) int fail().

d) rdstate().

Answer:

(d)

Explanation: rdstate() returns the current internal error state flags of the stream. The internal error state flags are automatically set by calls to input/output functions to signal certain types of errors that happened during their execution.

Q.40 The functions which are capable of handling a single and multiple characters respectively, are

a) get() and getline().

b) read() and write().

c) get() and put().

d) getline() and get().

Answer:

(a)

Explanation: get( ) extracts a character from the stream and returns its value and getline() extracts more than one character from the stream.