Model Exam 2015
Model Exam 2015
3. What is pointer?
A. The variable that stores the value of another variable
B. The variable that stores reference of garbage variable
C. The variable that stores the memory address of another variable
D. A & C Both
4. Which header file is used for reading and writing to a file?
A. iostream C. stdlib
B. fstream D. None of the mentioned
5. You have assigned the address of Value to the pointer P, Which statement will display
the value stored in Value using pointer P?
A. cout<<P; C. cout<<&P;
B. cout<<*Value; D. cout<<*P;
6. When the ___________ is present in front of a variable name, it represents the address of
that variable.
17. ___________ string manipulation function looks for the first occurrence of a sub-string in
another string.
A. strchr( ) C. strstr( )
B. strlwr( ) D. strupr( )
18. Which one of the following is true statement considering file input/output operations?
A. If a file object is declared with ofstream class, we can use it for writing and reading to
and from a file.
B. If a file object is declared with ifstream class, we can use it for writing to a file.
C. If a file object is declared with fstream class, we can use it only for reading from a
file.
D. If a file object is declared with ofstream class, we can use it for reading from a file.
E. None
19. What is the output of “ cout<<strnicmp("Computer Engineering", "computer Science
",10) ”;
A) 0
B) +ve Number D) Undetermined value
C) -ve Number E) None
A) ptr1=&x; C) x=&c;
B) z=x; D) a=&ptr1;
21. which one is not correct
A) ptr3=ptr1; D) x=ptr3;
B) ptr3=&ptr2; E) A and D
C) ptr3=&d; F) B and C
22. which one is correct statement to display the Value of variable using pointer
A) cout<<a; C) cout<<*a;
B) cout<<&a; D) cout<<*c;
23. Assume the file is opened using ostream object. Which one is the default access mode
A) ios::binary C) ios::out
B) ios::in D) ios::app
24. Which function is used to move a pointer position in file reading mode
A) seekp( ); C) tellg( );
B) seekg( ); D) tellp( );
25. which fstream function returns the failure of file opening
A) fail( ); C) error( );
B) close( ); D) eof( );
26. Which one of the following is not correct statement while working on strings?
A. char name[30] = “Aster”;
B. char *name = “Solomon”;
C. char *name; D. char name[30];
name = “Jemal”; name = “Abebech”;
A. 0 1 2 3 4
B. 0 5 10 15 20
C. 0 5 10 15
D. None of these
34. What is the output of the following C++ code?
a) 123
john
b) 123john
c) john123
d) john
123
43. Which of the following is a properly defined structure?
a) struct {int a;}
b) struct a_struct {int a;}
c) struct a_struct int a;
d) struct a_struct {int a;};
44. Which of the following correctly declares an array?
a) int array[10];
b) int array;
c) array{10};
d) array array[10];
45. If the two strings are identical, then strcmp() function returns
a). -1 b).1
c). 0 d).True
46. What is the output of the following C++ program?
int main ()
{
char str1[10] = "Hello";
char str2[10] = "World";
char str3[10];
int len ;
strcpy( str3, str1);
cout<<"strcpy(str3,str1)"<<str3<< endl;
strcat( str1, str2);
cout<<"strcat(str1,str2):"<<str1<<endl;
len = strlen(str1);
cout << "strlen(str1) : " << len << endl;
return 0;
}
A. strcpy(str3,str1)Hello
strcat(str1,str2):Hello
strlen(str1) : 10
B. strcpy(str3,str1)HelloWorld
strcat(str1,str2):HelloWorld
strlen(str1) : 10
C. strcpy(str3,str1)Hello
strcat(str1,str2):World
strlen(str1) : 10
D. strcpy(str3,str1)Hello
strcat(str1,str2):HelloWorld
strlen(str1) : 10
int main ()
{
string str1 = "Hello";
string str2 = "World";
string str3;
int len ;
str3 = str1;
cout << "str3 : " << str3 << endl;
str3 = str1 + str2;
cout << "str1 + str2"<< str3 << endl;
len = str3.size();
cout << "str3.size() : " << len << endl;
return 0;
}
A.
str3 : Hello
str1 + str2HelloWorld
str3.size() : 10
B.
str3 : Hello
str1 + str2Hello
str3.size() : 10
C.
str3 : Hello
str1 + str2HelloWorld
str3.size() : 9
D.
str3 : Hello
str1 + str2
str3.size() : 0
48. What is the output of the following C++ program?
void main ()
{
int val1 = 5, val2 = 15;
int *p1, *p2;
p1 = &val1;
p2 = &val2;
*p1 = 10;
*p2 = *p1;
p1 = p2;
*p1 = 20;
cout<<"value1="<<val1<<endl;
cout<<“val2="<<val2;
}
A. value1=10
val2=10
B. value1=10
val2=20
C. value1=20
val2=20
D. value1=0
val2=0
49. Which one of the following pairs of functions can’t be considered as overloaded
functions?
A. 10
B. 5
C. 0
D. Error