1. 1. You can use C++ as a procedural, as well as an object-oriented, language
A. True B. False
2. A default catch block catches
A. all thrown objects B. no thrown objects
C. any thrown object that has not been caught by an earlier catch block
D. all thrown objects that have been caught by an earlier catch block
3. Adding a derived class to a base class requires fundamental changes to the base class
A. True B. False
4. The use of the break statement in a switch statement is
A.optional B.compulsory
C.not allowed. It gives an error message D.to check an error
E. None of the above
5. To expose a data member to the program, you must declare the data member in the
_____ section of the class
A. common B. exposed
C. public D. unrestricted
E. user
6. Evaluate the following expression: 3 >6&&7>4
A. True B. False
7. Which of the following are valid characters for a numeric literal constant?
A.a comma B. a dollar sign ($)
C.a percent sign (%) D.a space
E.None of the above
8. A function that changes the state of the cout object is called a(n) _____
2. A. member B. adjuster
C. manipulator D. operator
9 .A constructor that accepts __________ parameters is called the default constructor.
A. one B. two
C. no D. three
10. Can a class have virtual destructor?
A. Yes B. No
11. A function that is called automatically each time an object is destroyed is a
A. constructor B. destructor
C. destroyer D. terminator
12. Which of the following assigns the number 5 to the area variable?
A. area 1 = 5 B. area = 5
C. area == 5 D. area --> 5
E. area < > 5
13. The _____ mode tells C++ to open a file for input
A. add::ios B. in::file
C. ios::app D. ios::in
E. ios::out
14. Sending a copy of data to a program module is called _______
A. passing a value B.making a reference
C. recursion D.setting a condition
3. 15. To use either an input or output file, the program must include the _____ header file
A. filestream.h B. fstream.h
C. instream.h D. inoutstream.h
E. iostream.h
16. An array name is a _____
A. subscript B. formal parameter
C. memory address D.prototype
17. To enter a comment in a C++ program, you begin the comment with _____
A. ** B. &&
C. D. @
E. //
18. When you pass a variable _____, C++ passes only the contents of the variable to the
receiving function
A. by reference B. by value
C. globally D. locally
19. The compiler converts your C++ instructions into _____
A. edited code B. object code
C. source code D. translated code
20. Find the output for the following C program
i=20,k=0;
for(j=1;j9 && Y++!=10 && Y++>10)
{printf("%d", Y);
else
printf("%d", Y);
4. }
21. What is the sizeof(long int)
(a) 4 bytes
(b) 2 bytes
(c) compiler dependent
(d) 8 bytes
22. What is the output of the following program?
main()
{
char *src = "Hello World";
char dst[100];
strcpy(src,dst);
printf("%s",dst);
}strcpy(char *dst,char *src)
{while(*src) *dst++ = *src++;
}
A) "Hello World" B)"Hello"
C)"World" D) NULL
E) unidentified
23. What is the output of the following program?
main()
{
int l=6;
switch(l)
{ default : l+=2;
case 4: l=4;
case 5: l++;
5. break;
}
printf("%d",l);
}
a)8 b)6 c)5 d)4 e)none
24. What is the output of the following program?
main()
{
int x=20;
int y=10;
swap(x,y);
printf("%d %d",y,x+2);
}
swap(int x,int y)
{
int temp;
temp =x;
x=y;
y=temp;
}
a)10,20 b) 20,12 c) 22,10 d)10,22 e)none
25. main()
{
int i;
char *p;
i=0X89;
p=(char *)i;
p++;
6. printf("%xn",p);
}
26. main()
{
int i;
clrscr();
printf("%d", &i)+1;
scanf("%d", i)-1;
}
a. Runtime error. b. Runtime error. Access violation.
c. Compile error. Illegal syntax d. None of the above
27. main()
{
int i = 0xff ;
printf("n%d", i<<2);
}
a. 4 b. 512
c. 1020 d. 1024
28. main()
{
int i, j, *p;
i = 25;
j = 100;
p = &i; // Address of i is assigned to pointer p
printf("%f", i/(*p) ); // i is divided by pointer p
}
a. Runtime error. b. 1.00000
c. Compile error d. 0.00000
7. 29. main()
{
int c = 5;
printf("%d", main||c);
}
a. 1 b. 5
c. 0 d. none of the above
30. main()
{
char c;
int i = 456;
clrscr();
c = i;
printf("%d", c);
}
a. 456 b. -456
c. random number d. none of the above
31. main()
{
int i =10, j = 20;
clrscr();
printf("%d, %d, ", j-- , --i);
printf("%d, %d ", j++ , ++i);
}
a. 20, 10, 20, 10 b. 20, 9, 20, 10
c. 20, 9, 19, 10 d. 19, 9, 20, 10
8. 32. main()
{
int x=5;
clrscr();
for(;x==0;x--) {
printf("x=%dn”", x--);
}
}
a. 4, 3, 2, 1, 0 b. 1, 2, 3, 4, 5
c. 0, 1, 2, 3, 4 d. none of the above
33. The keyword used to define a structure is _____
A. Stru B. Stt
C. Struct D. structure
34. Header files often have the file extension _____
A. .H B. .HE
C. .HEA D. .HEAD
35.vThe step-by-step instructions that solve a problem are called _____
A. an algorithm
B. a list
C. a plan
D. a sequential structure