You are on page 1of 3

Chapter XVI: New Features of ANSI C++ Standard

1. Which of the following data type(s) is introduced by ANSI C++?


a) bool
b) wchar_t
c) char_t
d) Both a and b
2. Consider the following code snippet:

..
int p;
string s("Pass");
bool k;
if(s=="pass")
{
k=true;
}
p=true+50+false;
cout<<p;
..
What will be the output on executing the above code?
a) Error as the Boolean values cannot be added
b) 51
c) 52
d) No output
3. Which of the following character literal(s) does use two bytes of memory?
a) wide_character literal
b) byte_character literal
c) new_character literal
d) None of the above
4. Which of the following casting operator can cast a pointer to any other type of pointer in
ANSI C++?
a) const_cast
b) dynamic_cast
c) reinterpret_cast
d) static_cast
5. Consider the following code snippet:
.
char *a,b;
if(typeid(a)==typeid(b))
cout<<"a";
else
cout<<"b";
.
What will be the output of the above code?
a) b
b) a
c) Compilation error
d) No output
6. Consider the following code snippet:
1. class sample
2. {
3. public:
4. explicit sample(float);
5. int a;
5. }

6. sample x=10.5;
..
The code will not compile. Which of the following option will solve the problem?
a) Line 6 should be changed to sample x(10.5);
b) In line 4, explicit keyword should be removed
c) Both a and b
d) Either a or b
7. Which of the following keyword is used to modify a const object?
a) explicit
b) typeid
c) mutable
d) typename
8. Which of the following option will create a user-defined namespace in ANSI C++?
a) namespace namespace_name{.};
b) namespace(){namespace_name}
c) namespace namespace_name{.}
d) namespace(){namespace_name}
9. Let us define a namespace called samplespace, which includes a member variable,
namely p. How will you access this member variable from outside the namespace?
I. using namespace samplespace;
II. using samplespace :: p;
III. samplespace.p;
IV. p :: samplespace();
a) I only
b) II only
c) Both III and IV
d) Both I and II
10. Write the equivalent expression using operator keywords for the following.
(a!=b) > (~(a & b)&=(a^b))
a) (a not_eq b) gt (not( a bitand b) and_eq (a xor b))
b) (a not_eq b) > (compl( a bitand b) and_eq (a xor b))
c) (a not_eq b) gt (not( a bitand b) not_eq (a exor b))
d) (a not_eq b) > (compl( a bitand b) not_eq (a exor b))