Test Series - cpp

Test Number 30/102

Q: What does a default header file contain?
A. prototype
B. implementation
C. declarations
D. pointing
Solution: In the header file, we define something that to be manipulated in the program.
Q: setprecision requires which of the following header file?
A. stdlib.h
B. iomanip.h
C. console.h
D. conio.h
Solution: The iomanip header file is used to correct the precision of the values.
Q: Which of the following header file does not exist?
A. 
B. 
C. 
D. 
Solution: There is no such header file  in C++.
Q: Which of the header file must be included to use stringstream?
A. 
B. 
C. 
D. 
Solution: stringstream is available under the header file  in C++.
Q: 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
Solution: In this fstream.h header file is used for accessing the files only.
Q: What does a class in C++ holds?
A. data
B. functions
C. both data & functions
D. arrays
Solution: The classes in C++ encapsulates(i.e. put together) all the data and functions related to them for manipulation.
Q: Which other keywords are also used to declare the class other than class?
A. struct
B. union
C. object
D. both struct & union
Solution: Struct and union take the same definition of class but differs in the access techniques.
Q: The data members and functions of a class in C++ are by default ____________
A. protected
B. private
C. public
D. public & protected
Solution: By default all the data members and member functions of class are private.
Q: Constructors are used to ____________
A. initialize the objects
B. construct the data members
C. both initialize the objects & construct the data members
D. delete the objects
Solution: Once the object is declared means, the constructor are also declared by default.
Q: When struct is used instead of the keyword class means, what will happen in the program?
A. access is public by default
B. access is private by default
C. access is protected by default
D. access is denied
Solution: For structures, by default all the data members and member functions are public.

You Have Score    /10