Notice: Due to an ongoing migration of our storage and publishing system, material requested since last month will not be uploaded for the time being, and new requests are paused. All existing notes remain available.

Unit 3 MCQs Data File operations, Constructors, Destructors and File Handling

CSE202 — Object Oriented Programming 50 questions. Pick an option to check it.

Read the notes

0 of 50 answered 0 right 0 wrong , 50 left

  1. Question 1 of 50

    Which header file is required to perform file input/output operations in C++?

  2. Question 2 of 50

    Which class is used specifically for writing data to a file?

  3. Question 3 of 50

    Which class is used specifically for reading data from a file?

  4. Question 4 of 50

    What is the return type of a constructor?

  5. Question 5 of 50

    Which file mode is used to append content to the end of an existing file?

  6. Question 6 of 50

    Which symbol is used to prefix the destructor name?

  7. Question 7 of 50

    Which function is used to close a file explicitly in C++?

  8. Question 8 of 50

    What happens if a file is opened in 'ios::out' mode and the file already exists?

  9. Question 9 of 50

    Which constructor is called when an object is initialized with another object of the same class?

  10. Question 10 of 50

    Which syntax correctly defines a copy constructor for class 'A'?

  11. Question 11 of 50

    What is the purpose of the 'write()' function in file handling?

  12. Question 12 of 50

    Which function is used to move the get pointer (input pointer) in a file?

  13. Question 13 of 50

    What does 'ios::binary' mode do?

  14. Question 14 of 50

    Which function returns the current position of the output pointer?

  15. Question 15 of 50

    When is a destructor called?

  16. Question 16 of 50

    Can a constructor be overloaded?

  17. Question 17 of 50

    What is an Initializer List used for?

  18. Question 18 of 50

    Which member must be initialized using an initializer list?

  19. Question 19 of 50

    What is the correct syntax to read an object 'obj' of class 'Student' from a binary file using ifstream object 'fin'?

  20. Question 20 of 50

    What is the default access mode for an 'ofstream' object?

  21. Question 21 of 50

    Which function checks if the End-Of-File has been reached?

  22. Question 22 of 50

    How many destructors can a class have?

  23. Question 23 of 50

    If a programmer does not define any constructor, what does the compiler do?

  24. Question 24 of 50

    What is the output of sizeof(fstream) roughly dependent on?

  25. Question 25 of 50

    Which combination of modes allows reading and writing to a file while preserving original content?

  26. Question 26 of 50

    Which stream function reads a line of text, including spaces?

  27. Question 27 of 50

    Which flag sets the file pointer to the end of the file immediately after opening?

  28. Question 28 of 50

    What implies 'Random Access' in file handling?

  29. Question 29 of 50

    Can a destructor accept arguments?

  30. Question 30 of 50

    What is a parameterized constructor?

  31. Question 31 of 50

    Which seek direction moves the pointer relative to the beginning of the file?

  32. Question 32 of 50

    When working with Structures and Files, why is reinterpret_cast or C-style cast used in write?

  33. Question 33 of 50

    Which of the following constitutes a default constructor?

  34. Question 34 of 50

    If a class has a pointer member, what is the risk of using the default copy constructor?

  35. Question 35 of 50

    Which function puts a single character into the file stream?

  36. Question 36 of 50

    In file.seekg(n, ios::cur);, what does n represent?

  37. Question 37 of 50

    Which mode is required to perform input and output operations on the same file using fstream?

  38. Question 38 of 50

    The order of destruction of objects is:

  39. Question 39 of 50

    Which error handling function returns true if a non-fatal error (like format mismatch) occurs?

  40. Question 40 of 50

    Can a constructor accept a reference to its own class type as a value parameter (e.g. A(A a))?

  41. Question 41 of 50

    What is the main advantage of using binary files over text files for storing objects?

  42. Question 42 of 50

    The open() function takes how many arguments generally?

  43. Question 43 of 50

    What is a deep copy?

  44. Question 44 of 50

    Which symbol is used for the Initializer List syntax?

  45. Question 45 of 50

    If fstream file; is declared, which function opens the file?

  46. Question 46 of 50

    When using ios::trunc, what happens to the existing file content?

  47. Question 47 of 50

    Can constructors be declared as private?

  48. Question 48 of 50

    What happens if a destructor is not virtual in a base class when deleting a derived class object via a base pointer?

  49. Question 49 of 50

    Which function returns the current get position in an input stream?

  50. Question 50 of 50

    In the context of file modes, what does ios::ate stand for?

That's unit 3

Answer a few questions and your score shows up here.