The following program segment
const int m = 10 ;
int &n = m ;
n = l1 ;
cout << m << n;
A. | results in compile time error |
B. | results in run time error |
C. | prints 1111 |
D. | prints 1 0 11 |
Option: A Explanation : Click on Discuss to view users comments. |
The following program segment
int a = 10 ;
int const &b = a ;
a = l1 ;
cout << a << b ;
A. | results in compile time error |
B. | results in run time error |
C. | prints 1111 |
D. | none of the above |
Option: C Explanation : The very idea of declaring b as a constant integer is to protect it from changes. However, since it is aliased to a variable whose attribute is not const, the value of b can be indirectly changed by changing the value of a. This is a bad programming practice. Click on Discuss to view users comments. |
Which of the following is not a storage class supported by C++ ?
A. | register |
B. | auto |
C. | mutable |
D. | dynamic |
Option: D Explanation : Click on Discuss to view users comments. |
Consider the following program segment.
static char X [3] = "1234" ;
cout << X ;
A complete c++ program with these two statements
A. | prints 12 3 4 |
B. | prints 12 3 |
C. | prints 1234 followed by some junk |
D. | will give a compilation error |
Option: D Explanation : c++ forbids initialization with strings, whose length is more than the size of the array. C compiler permits. Click on Discuss to view users comments. |
Consider the following program segment.
const char *p1= "To make the bitter butter better" ; // stm1
char *const p2 = "Recommend this book 2 others "; //stm2
p1 = "add some better butter not bitter. " ; //stm3
p2 = "so that th~y 2 will get benefited. " ; //stm4
* (p1+3) = 'A' ; //stm5
* (p2+3) = 'A' ; //stm6
Which of the statement results in error?
A. | stm4 and stm5 |
B. | stm1 and stm2 |
C. | stm1 and stm4 |
D. | stm2 and stm3 |
Option: A Explanation : Click on Discuss to view users comments. |
Syllabus covered in this section is-
This Section covers OOPS Questions Answers .These questions can be used for the preparation of various competitive and academic exams like
Who can benefit
Various Search Terms Used For This Section Are