Object Oriented Programming using C++ Questions and Answers – Inbuilt Classes


This set of Object Oriented Programming (OOPs) using C++ Multiple Choice Questions & Answers (MCQs) focuses on “Inbuilt Classes”.

1. What are inbuilt classes?
a) The predefined classes in a language
b) The classes that are defined by the user
c) The classes which are meant to be modified by the user
d) The classes which can’t be used by the user
View Answer

Answer: a
Explanation: The classes that are already provided in a programming language for use are inbuilt classes. These classes provide some functions or objects that can be used by the programmer for easier code.

2. Inbuilt class __________________________
a) Must be included before use
b) Are not necessary to be included for use
c) Are used by the compiler only
d) Can be modified by programmer always
View Answer

Answer: a
Explanation: The inbuilt classes must be included in the program. Whenever some functions are used, they must have a declaration before use. The same is the case with classes.

3. What doesn’t inbuilt classes contain?
a) Function prototype
b) Function declaration
c) Function definitions
d) Objects
View Answer

Answer: c
Explanation: The classes contain the definitions of the special functions that are provided for the programmers use. Those functions can be used to make the programming easy and to reuse the already existing code.

4. Which among the following not an inbuilt class in C++?
a) System
b) Color
c) String
d) Functions
View Answer

Answer: d
Explanation: There is no inbuilt class named function in java. The others are classes already provided in java. All those classes contain some special functions to be used in programming.

5. What is the InputStream class meant for?
a) To handle all input streams
b) To handle all output streams
c) To handle all input and output streams
d) To handle only input from file
View Answer

Answer: a
Explanation: The InputStream is an inbuilt class which is used to handle all the tasks related to input handling. This class extends input from keyboard or file or any other possible input stream.

6. Which statement is true for the Array class?
a) Arrays can have variable length
b) The length array can be changed
c) Each class has an associated Array class
d) Arrays can contain different type of values
View Answer

Answer: c
Explanation: The Array class is associated with all the other classes. This gives us the flexibility to declare an array of any type. The index goes from 0 to n, where n is some fixed size for array.

7. What is the use of Math class?
a) To use the mathematical functions with strings
b) To use the mathematical functions
c) To suppress the use of mathematical functions
d) To complex the calculations
View Answer

Answer: b
Explanation: The Math class is provided with some special functions. These functions can be used to calculate and get result of some special and usual mathematical functions. We don’t have to write the code to calculate the trigonometric function results, instead we can use Math functions.

8. DataInputStream is derived from ______________________
a) StreamingInput
b) StreamedInput
c) StreameInput
d) StreamInput
View Answer

Answer: d
Explanation: The DataInputStream is more specific class for operating on specific type of data inputs. This is used to read data of specific type. The same can be used to read data in a specific format.

9. Which attribute can be used to get the size of an array?
a) Size.Array
b) Array.Size
c) Array_name.length
d) length.Array_name
View Answer

Answer: c
Explanation: The array name is given of which the length have to be calculated. The array length is stored in the attribute length. Hence we access it using dot operator.

10. Number class can’t manipulate ____________________
a) Integer values
b) Float values
c) Byte values
d) Character values
View Answer

Answer: d
Explanation: The Number class is used to work with all the number type of values. The integers, float, double, byte etc. are all number type values. Character is not a number value.

11. Which function should be used to exit from the program that is provided by System class?
a) exit(int);
b) gc();
c) terminate();
d) halt();
View Answer

Answer: a
Explanation: The exit function should be used to terminate the program. The function is passed with an argument. The argument indicated the type of error occurred.

12. Which class contain runFinalization() method?
a) Finalize
b) System
c) Final
d) SystemFinal
View Answer

Answer: b
Explanation: The runFinalization() Function is defined in the System class. The function is used to finalize an object which undergo destruction. The action is required to terminate the object properly.

13. What does load(String)::= function do, in System class?
a) Loads dynamic library for a path name
b) Loads all the dynamic libraries
c) Loads all the Number in string format
d) Loads the processor with calculations
View Answer

Answer: a
Explanation: Only the specified path named dynamic libraries are loaded. All the dynamic libraries can’t be loaded at a time. Hence we use this function for specific libraries.

14. Which is not a System class variable?
a) err
b) out
c) in
d) put
View Answer

Answer: d
Explanation: Put is not a System class variable. The most general and basic variables are err, out and in. The variables can handle most of the tasks performed in a program.

15. Which package contains the utility classes?
a) java.lang
b) java.utility
c) java.util
d) java.io
View Answer

Answer: c
Explanation: The package java.util contains all the utility classes. This package also contains generic data structures, date, time etc. These can be used in any java program, you just have to include java.util package.

Sanfoundry Global Education & Learning Series – Object Oriented Programming (OOPs).

To practice all areas of Object Oriented Programming (OOPs) using C++, here is complete set of 1000+ Multiple Choice Questions and Answers.

Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He is Linux Kernel Developer & SAN Architect and is passionate about competency developments in these areas. He lives in Bangalore and delivers focused training sessions to IT professionals in Linux Kernel, Linux Debugging, Linux Device Drivers, Linux Networking, Linux Storage, Advanced C Programming, SAN Storage Technologies, SCSI Internals & Storage Protocols such as iSCSI & Fiber Channel. Stay connected with him @ LinkedIn | Youtube | Instagram | Facebook | Twitter