Output Stream C++ MCQ

Errorlogger
0
1. How many groups of output of operation are there in c++?
a) 1
b) 2
c) 3
d) 4


2. Picl out the correct objects about the instantiation of output stream.
a) cout
b) cerr
c) clog
d) All of the mentioned


3. What is meant by ofstream in c++?
a) Writes to a file
b) Reads from a file
c) Both a & b
d) None of the mentioned


4. What is the output of this program?
  1.     #include <iostream>
  2.     using namespace std;
  3.     int main () 
  4.     {
  5.         char str[] = "Steve jobs";
  6.         int val = 65;
  7.         char ch = 'A';
  8.         cout.width (5);
  9.         cout << right;
  10.         cout << val << endl;
  11.         return 0;
  12.     }
a) Steve jobs
b) A
c) 65
d) 65


5. What is the output of this program?
  1.     #include <iostream>
  2.     using namespace std;
  3.     int main () 
  4.     {
  5.         int n; 
  6.         n = 43;
  7.         cout << hex << n << endl;
  8.         return 0;
  9.     }
a) 2c
b) 2b
c) 20
d) 50


6. What is the output of this program in the “test.txt” file?
  1.     #include <fstream>
  2.     using namespace std;
  3.     int main ()
  4.     {
  5.         long pos;
  6.         ofstream outfile;
  7.         outfile.open ("test.txt");
  8.         outfile.write ("This is an apple",16);
  9.         pos = outfile.tellp();
  10.         outfile.seekp (pos - 7);
  11.         outfile.write (" sam", 4);
  12.         outfile.close();
  13.         return 0;
  14.     }
a) This is an apple
b) apple
c) sample
d) This is a sample


7. What is the output of this program?
  1.     #include <iostream>
  2.     using namespace std;
  3.     int main ()
  4.     {
  5.         int n;
  6.         n = -77;
  7.         cout.width(4); 
  8.         cout << internal << n << endl;
  9.         return 0;
  10.     }
a) 77
b) -77
c) – 77
d) None of the mentioned


8. What is the output of this program?
  1.     #include <iostream>
  2.     #include <locale>
  3.     using namespace std;
  4.     int main()
  5.     {
  6.         locale mylocale("");
  7.         cout.imbue( mylocale );
  8.         cout << (double) 3.14159 << endl;
  9.         return 0;
  10.     }
a) 3.14
b) 3.14159
c) Error
d) None of the mentioned


9. How many types of output stream classes are there in c++?
a) 1
b) 2
c) 3
d) 4


10. What must be specified when we construct an object of class ostream?
a) stream
b) streambuf
c) memory
d) None of the mentioned
Tags

Post a Comment

0Comments

Post a Comment (0)

#buttons=(Accept !) #days=(30)

Our website uses cookies to enhance your experience. Check Now
Accept !