Pfmcqs
Pfmcqs
Pfmcqs
Which of the following syntax can be used to use a member of a namespace without
including that namespace?
namespace::member
namespace->member
namespace.member
namespace~member
What happens if the following C++ statement is compiled and executed?
int*ptr =NULL;delete ptr;
a) The program is not semantically correct
b) The program is compiled and executed successfully
c) The program gives a compile-time error
d) The program compiled successfully but throws an error during run-time
What will be the output of the following C++ code?
#include<iostream>usingnamespace std;int main (){
1
intcin;
cin>>cin;
cout<<"cin: "<<cin;
return0;}
a) Segmentation fault
b) Nothing is printed
c) Error
Which of the following correctly declares an array in C++?
a) array{10};
b) array array[10];
c) int array;
d) int array[10];
Which of the following is not used as a file opening mode?
ios::trunc
ios::binary
ios::in
ios::ate
2
#include <stdio.h>int main(void){
intnew=5;
printf("%d", new);}
a) Error in C and successful execution in C++
b) Error in both C and C++
c) Error in C++ and successful execution in C
d) A successful run in both C and C
3
Object
can’t be created
Which header file is used to include the string object functions in C++?
#include <string.h>
#include <cstring>
#include <string>
#include <string.cpp>
Which of the following is the default mode of the opening using the ofstream
class?
ios::in
b) ios::out
c) ios::app
d) ios::trunc
Which of the following user-defined header file extension used in c++?
a) hg
b) cpp
c) h
d) hf
4
4. Which is a true statement for object of String class?
a. Object are immutable
b. Object are mutable
c. Object are created only once
d. Object can’t be created
8. Which function is used in C++ to get the current position of file pointer in a file?
a. tell_p()
b. get_pos()
c. get_p()
d. tell_pos()
5
b. In dynamic polymorphism, the conflict between the function call is
resolved during the run time
c. In dynamic polymorphism, the conflict between the function call is never
resolved during the execution of the program
d. In dynamic polymorphism, the conflict between the function call is
resolved at the beginning of the program
1.
int main()
2.
3.
{
4.
5.
registerint i =1;
6.
7.
int*ptr =&i;
8.
9.
cout<<*ptr;
10.
11.
return0;
12.
13.
}
14.
a) Runtime error may be possible
b) Compiler error may be possible
c) 1
d) 0
6
13. Which
of the following operator is used with this pointer to access members of a
class?
a. .
b. !
c. ->
d. ~
7
8