C++ Programming Fundamentals

C++ programming concepts including STL, object-oriented programming, file I/O, templates, and virtual functions

15 Questions Published

Questions

Question 1 Multiple Choice (Single Answer)

Which of the following components of Standard Template Library hold(s) data of some type?

  1. Algorithms
  2. ssssContainers
  3. Iterators
  4. Encapsulation
  5. Data abstraction
Question 2 Multiple Choice (Single Answer)

Which of the following error handling functions in C++ returns true when an input or output operation has failed?

  1. Exit()
  2. Good()
  3. Bad()
  4. Eof()
  5. Fail()
Question 3 Multiple Choice (Single Answer)

The default visibility mode in C++ is

  1. public
  2. protected
  3. private
  4. public-private
  5. unprotected
Question 4 Multiple Choice (Single Answer)

Which of the following member functions of the map class is used to give the location of a specified element?

  1. Begin()
  2. Clear()
  3. Find()
  4. Erase()
  5. Insert()
Question 5 Multiple Choice (Single Answer)

The _____________ member function of a class modifies the values of the member variables.

  1. Accessor function
  2. Mutator function
  3. Constructor function
  4. Inline function
  5. Destructor function
Question 6 Multiple Choice (Single Answer)

The ____________ file mode is used in C++ to write all the data at the end of the file.

  1. ios::in
  2. ios::out
  3. ios::trunc
  4. ios::ate
  5. ios::binary
Question 7 Multiple Choice (Single Answer)

The _____________ I/O stream function is used to return the next character from an input file stream without moving the inside pointer.

  1. _unlink()
  2. putback()
  3. flush()
  4. peek()
  5. getline()
Question 8 Multiple Choice (Single Answer)

_____________ is the process of deciding which class function is to be called at runtime.

  1. Static binding
  2. Late binding
  3. Virtual function
  4. Abstract class
  5. Derived class
Question 9 Multiple Choice (Single Answer)

A function generated from a function template is called

  1. generated class
  2. generated function
  3. static member function
  4. inline function
  5. constructor function
Question 10 Multiple Choice (Single Answer)

Which function is used to make use of a function which is used in two derived classes and also in the base class without having any complexity in the program.

  1. Virtual function
  2. Function overloading
  3. Operator overloading
  4. Inheritance
  5. Encapsulation
Question 11 Multiple Choice (Single Answer)

__________ visibility mode is used when public and protected members of base class become protected members of derived class.

  1. Public
  2. Private
  3. Protected
  4. Not inherited
  5. Public-Private
Question 12 Multiple Choice (Single Answer)

________ is the one in which all code is written without mention of any specific type and thus, can be used transparently with any number of new types.

  1. Run-time polymorphism
  2. Compile-time polymorphism
  3. Parametric polymorphism
  4. Ad-hoc polymorphism
  5. Abstract class
Question 13 Multiple Choice (Single Answer)

The _____________ operator is used to define a member function outside the class declaration using the class name.

  1. ::
  2. '*'
  3. '&'
  4. '=='
  5. '!'
Question 14 Multiple Choice (Single Answer)

_____________ is the class object used to read data from disk files.

  1. ofstream
  2. ifstream
  3. PRN
  4. argc
  5. istream_withassign
Question 15 Multiple Choice (Single Answer)

Consider the following C++ code:

class Sample {
    int a;

public:
    Sample(int b)
    {
        a = b;
    }
    Sample(Sample s)
    {
        a = s.a;
    }
};
void main()
{
    Sample s(100);
    Sample s1(s);
}

Referring to the above program code, what initialises the object s1?

  1. 1000
  2. Value of s object
  3. 200
  4. 300
  5. 400