Q.1
What is the use of swap() function in array class?
  • a) Swaps two elements of an array given elements
  • b) Swaps two arrays
  • c) Swaps two elements given indices of elements
  • d) Swaps same elements of the array if required
Q.2
What is the syntax of swap()?
  • a) swap(arr1, arr2);
  • b) arr1.swap(arr2);
  • c) swap<int, int>(arr1, arr2);
  • d) swap[arr1, arr2];
Q.3
What is the use of empty() function in array classes?
  • a) To check whether the size of an array is zero or not
  • b) To check whether an array is empty or not
  • c) To check how many elements are there in the array
  • d) To check whether an array contains negative elements or not
Q.4
What is the use of fill() function in array class?
  • a) To fill an array with a given single value
  • b) To delete all the elements that are equal to the given value
  • c) To replace all the elements of the array which are equal to the given value
  • d) To check whether given element fills the array or not
Q.5
What will be the output of the following C++ code? #include <iostream> #include <array>   using namespace std;   int main(int argc, char const *argv[]) { array<int,arr arr1.fill(2); for(int i=0;i<5;i++) cout<<arr1[i]; cout<<endl; return}
  • a) 22222
  • b) 20000
  • c) 00002
  • d) 20002
Q.6
What will be the output of the following C++ code? #include <iostream> #include <array>   using namespace std;   int main(int argc, char const *argv[]) { array<int,arr arr1.fill(5); cout<<get<5>(arr1); return}
  • a) 5
  • b) Compile-time error
  • c) Run-time error
  • d) Segmentation fault
Q.7
What happens when both of the following C++ programs are compiled and executed? ===== Program 1 ===== #include <iostream> #include <array>   using namespace std;   int main() { array<int,arr arr1.fill(5); cout<<get<5>(arr1); return} ===================== ===== Program 2 ===== #include <iostream> #include <array>   using namespace std;   int main() { array<int,arr arr1.fill(5); cout<<arr1.at(5); return} =====================
  • a) Program 1 gives compile-time error and Program 2 gives run-time error
  • b) Program 1 gives run-time error and Program 2 gives compile-time error
  • c) Both programs results into compile-time error
  • d) Both programs results into run-time error
0 h : 0 m : 1 s