C ++ MULTIPLE CHOICE QUESTION
Check your Knowledge Press to Start www.prolearninghub.com
1. In a linked list: 1) Each link contains a pointer to next link 2) Each link contains data 3) An array of pointer to the next links 4) The link is stored in a array 2;4 1;2 1;3 3;4 www.prolearninghub.com
2. If you wanted to sort so many large objects or structure, it would be most efficient to: Place them in a array and sort the array Place pointers to them and then sort the array Placed them in a link list and sort the link list Place reference to them in an array and then sort them www.prolearninghub.com
3. Virtual function allows you to: Create an array of type pointer-to-base class that can hold pointer to derived class Create function that have no body Group the object of different class Use the same function call to execute the member function from different class www.prolearninghub.com
4. A pointer to be a base class can point to object of derived class. True False www.prolearninghub.com
Late binding or dynamic binding 5. Deciding after a program start to execute what function will be executed by a particular function call statement, is called Late binding Dynamic binding Late binding or dynamic binding None of these www.prolearninghub.com
6. A pure virtual function is a virtual functions that: (Choose all that apply) 1) Has no body 2) Is used in a base class 3) Returns nothing 4) Take no arguments 2;4 1;4 2;3 1;2 www.prolearninghub.com
7. A virtual base function is useful when: Different base function in base and derived classes have the same name There are multiple paths from the one derived class to another The identification of a function in base class is ambiguous It make sense to use base class with no body www.prolearninghub.com
8. A friend function can be used to: (Choose all that apply) 1) Avoid arguments between classes 2) Allow access to class whose source code is unavailable 3) Allow one class to access unrelated class 4) Increase the versatility of an overloaded function 1;2 1;3 3;4 2;4 www.prolearninghub.com
9. The keyword friend does not appear in: (Choose all that apply) The class allowing access to another class The class desiring access to another class The private section of a class The public section of a class www.prolearninghub.com
10. A static function: Should be called when an object is destroyed Is closely connected with an individual object for a class Can be called using the class name and function name Is used when a dummy object must be created www.prolearninghub.com
11. An assignment operator can not be overloaded to: Help keep track of the number of identical object Assign a separate id onto each object Ensure that all member data is copied exactly Signal when assignment takes place www.prolearninghub.com
12. The user must always define the operation of the copy constructor True False www.prolearninghub.com
13. The operation of the assignment operator and that of the copy constructor are: (Choose two options) 1) Similar, except that the copy constructor create the new object 2) Similar, except that the assignment operator copies member data 3) Different, except that they both create a new object 4) Different , except that they both copy member data 1;2 1;4 2;3 3;4 www.prolearninghub.com
14. A copy constructor could be defined to copy only part of an object data True False www.prolearninghub.com
15. The lifetime of a variable that is defined as: (Choose all that apply) 1) Automatic in a member function coincides the lifetime of the function 2) Member data of an object coincide with the lifetime of the object 3) External coincide with the life time of the class 4) Static in a member function coincide with the lifetime of the function 1;4 1;2 2;3 3;4 www.prolearninghub.com
16. There is no problem with returning the value of a variable defined as automatic within a member function so long as it is returned by the value. True False www.prolearninghub.com
17. A copy constructor is invoked when: 1) A function returns by reference 2) A function returns by value 3) An argument is passes reference 4) An argument is passed by value 2;4 1;4 2;3 1;3 www.prolearninghub.com
18. What does this pointer point to? The object of the function whose using its member The current occupying object Both a and b None of these www.prolearninghub.com
The flow of function through the function 19. A C++ stream is: The flow of function through the function The flow of data from one place to another A file None of these www.prolearninghub.com
20. The base class for most stream classes is the ____class. IOS IS OS None of these www.prolearninghub.com
21. Which stream class is to only write on files? ofstream ifstream fstream iostream www.prolearninghub.com
22. Which stream class is to only read on files? of stream if stream stream upstream www.prolearninghub.com
23. To perform File I/O operations, we must use _________ header file. <ifstream> <ofstream> <fstream> Any of these www.prolearninghub.com
24. Which of the following is not a file opening mode ____ . Ions::ate Ions::concrete Ions::no replace Ions::truncate www.prolearninghub.com
25. Streams that will be performing both input and output operations must be declared as class _______. iostream stream stdstream Stdiostream www.prolearninghub.com
26. To create an output stream, we must declare the stream to be of class ___________. ofstream ifstream iostream None of these www.prolearninghub.com
27. Which among following is used to open a file in binary mode ? Ios::app Ios::out Ios::in Ios::binary www.prolearninghub.com
28. Which is correct syntax? myfile:open ("example.bin", ios::out); myfile.open ("example.bin", ios::out); myfile::open ("example.bin", ios::out); myfile.open ("example.bin", ios:out); www.prolearninghub.com
29. Which among following is correct syntax of closing a file in C++ ? myfile$close(); myfile@close(); myfile:close(); myfile.close(); www.prolearninghub.com
30. __________ is return type of is_open() function. into bolo float char * www.prolearninghub.com
31. It is not possible to combine two or more file opening mode in open () method. True False www.prolearninghub.com
32. By default, all the files are opened in ___________mode Binary Text Can’t say No idea www.prolearninghub.com
33. What is use of elf()? Returns true if a file open for reading has reached the next character. Returns true if a file open for reading has reached the next word. Returns true if a file open for reading has reached the end Returns true if a file open for reading has reached the middle www.prolearninghub.com
34. Which functions allow changing the location of the get and putting positions? sg() and sp() sekg() and sekp() gog() and gop() seekg() and seekp() www.prolearninghub.com
35. Offset counted from the current position using? Ios::curr Ios::cr Ios::cur Ios::current www.prolearninghub.com
36. Which among is used for positioning relative to the beginning of a stream? Ios::start Ios::beg Ios::begin Ios::begining www.prolearninghub.com
37. Which is among following is used to Open a file for output and move the read/write control to the end of the file? Ios::ate Ios::ann Ios::at Ios::end www.prolearninghub.com
38. Which is correct syntax for, position n bytes back from end of fileObject ? fileObject.seekg(ios::end, n); fileObject.seekg(n, ios:end ); fileObject.seekg(n, ios::end ); fileObject.seekg(ios:end, n); www.prolearninghub.com
39. Which stream class is used to both read and write on files ifstream fstream ofstream iostream www.prolearninghub.com
40. How to get position to the nth byte of fileObject? fileObject.seekg( 'filename',n ); fileObject.seekg( n, 'filename' ); fileObject.seekg( n ); fileObject.seekg( n, ios::app ); www.prolearninghub.com
41. eof() is used to get: Easy code review End of file Debug report File close www.prolearninghub.com
42. Name of the streams that are used for: If stream Of stream F stream All of them www.prolearninghub.com
43. Some stream work with input and some with output? True False www.prolearninghub.com
44. We can output a text on an object class of ofstream using the insertion operator because: The ofstream class is the stream The insertion operator is work with all classes We are actually outputting to cout The insertion operator is overloaded in ofstream www.prolearninghub.com
The insertion operator 45. To write data of the type float, to an object of type ofstream you should use: The insertion operator Seeking() Write() Put() www.prolearninghub.com
46. Mode bit such as app and ate: (Choose all that apply) 1) Are defined as ios class 2) Can specify if the file is open for read or write 3) Work with the put() and get() function 4) Specify ways of opening a file 2;3;4 1;3;4 1;4 1;2;3 www.prolearninghub.com
47. A file pointer is always contains the address of the file. False True www.prolearninghub.com
48. The statement f1.write((char*)^obj1, sizeof(obj1)); Writes the member function of obj1 to f1 Writes the date in obj1 to f1 Writes the member function and data of obj1 to f1 Writes the address if obj1 to f1 www.prolearninghub.com
49. Redirection redirects: A stream from a file to screen A file from a device to a stream A device from a stream to screen The screen from a device to stream www.prolearninghub.com
50. The printer can access using the predefined filename____? PRN PLC Can be both None of these www.prolearninghub.com
The Results