You are on page 1of 7

50 Muliple choice questions of Object Oriented Programming

6. The Worst case occur in linear search


1. Which of the following is a Scalar algorithm when
Data type? a) Item is somewhere in the middle of the
a) Float array
b) Pointer b) Item is not in the array at all
c) Arrays c) Item is the last element in the array
d) Union d) Item is the last element in the array
or is not there at all

2. Which of the following is invalid? 7. p++ executes faster than p+1 because
a) ‘ ’ a) p uses registers
b) “ ” b) p++ is a single instruction
c) ‘a’ c) ++ is faster than +
d) ‘abc’ d) None of these

3. When a key is pressed on the 8. The printf() function retunes which


keyboard, which standard is used for value when an error occurs?
converting the keystroke into the a) Positive value
corresponding bits on windows b) Zero
platform? c) Negative value
a.) ANSI d) None of these
b. ) ASCII
c.) ISO 9. What is the first change that selection
d. ) EBCDIC sort would make to this sequence to
put it into ascending order: "3 1 4 2"?
4. Which of the following is an example a) 1 3 4 2
of compounded assignment b) 2 4 1 3
statement?
c) 3 2 4 1
a) a = 5
b) a += 5 d) 4 2 3 1
c) a = b = c 10. A linked list index is ____ that
d) a = b represents the position of a node in a
linked list.
5. Operators have hierarchy. It is used to a) an integer
know which operator b) a variable
a) is most important c) a character
d) a Boolean
b) is used first
c) is faster
d) operates on large numbers 11. The C complier provides the DEBUG
complier option and its sub-options to
control the following actions:-
a) The generation and placement of 17. What is the output of the following
hooks and symbol tables. program, if its command line
b) The placement of debug information arguments were 1 5 7.
into the object file or separate debug file. int main(int argc, char *argv[])
c) both a and b {
d) None of these. int x;
x = argv[1] + argv[2] + argv[3];
12. Identify the invalid pointer arithmetic printf ("%d", x);
a) Addition of float value to a }
pointer a) Error: invalid pointer addition
b) Comparison of pointers that do not b) 1,5,7
point to the element of the same c) 7,5,1
array. d) 5,1,7
c) Subtracting an integer from a
pointer. 18. Value of the first linked list index is
d) Assigning the value 0 to a pointer a) one
variable . b) zero
c) -1
13. A Structure d) None of these
a) can be read as a single entity
b) cannot be read as a single entity 19. What is the output of the following
c) can be displayed as a single entity program?
d) has member variables that cannot void main() {
be read individually. char s1[] = "Hagrid";
char s2[] = "Hagrid";
14. When the main function is called, it is if (s1==s2)
called with the arguments printf ("Same");
a) Argc else
b) Argv printf ("Different");
c) None of these }
d) both a & b a) Same
b) Different
15. A Link is c) Conditional Error
a) a Compiler d) None of these
b) a C interpreter
c) an analyzing tool in C 20. What is output of following program
d) an active debugger when we compile and run it?
void main( )
16. Which is of the below is not a benefit of {
using a linked list instead of an array? int const * p=5;
a) Linked list is more flexible printf("%d",++(*p));
b) Linked list allow you sort the }
elements more easily. a) 25
c) Linked list allow you to b) 6
randomly access one of its c) Compiler error: Cannot modify
elements. a constant value.
d) All of the above are its benefits d) 30
21. What is output of following? a) The warning message of the C
void main() compiler.
{ b) A debugger
char s[ ]="man"; c) A static analyzer
int i; d) All of the above.
for(i=0;s[i];i++) printf("\n%c%c%c
%c",s[i],*(s+i),*(i+s),i[s]); 26. int i , j ;
} int ctr = 0;
a) mmmm int myArray[2][3];
aaaa for(i=0;i<3;i++)
nnnn for (j=0;j<2;j++)
b) mmmm {
aaa myArray[j][i]=ctr ;
nnnn ++ctr;
c) man }
man What is the value of myArray[1][2]; in
man the sample code above?
d) error a) 1
b) 2
22. int testarray[3][2][2] = {1, 2, 3, 4, 5, 6, c) 5
7, 8, 9, 10, 11, 12}; What value does d) 00,10,01,11,12
testarray[2][1][0] in the sample code
above contain? 27. Which one of the following is valid for
a) 3 opening a read-only ASCII file?
b) 5 a) fileOpen (filenm, "r");
c) 11 b) fopen (filenm, "ra");
d) 9 c) fileOpen (filenm, "read");
d) fopen (filenm, "r");
23. f = fopen( filename, "r" );
Referring to the code above, what is 28. When is insertion sort, a good choice
the proper definition for the variable f ? for sorting an array?
a.FILE f; a) Each component of the array
b. FILE *f; requires a large amount of memory.
c.FILE **f; b) Each component of the array
d. FILE int f; requires a small amount of memory.
c) The array has only a few items out
24. int x[] = { 1,4,8,5,1,4 }; of place.
int *ptr, y; d) The processor speed is fast.
ptr = x+4;
y = ptr-x; 29. Given the statement,
What does y in above code equal? maruti.engine.bolts = 25;
a) -3
b) 0 Which of the following is true ?
c) 4 a)Structure bolts is nested within
d) 4 + sizeof(int) structure engine.
b) Structure engine is nested within
25. Which of these is the best tool for structure maruti.
finding unsafe library function calls? c) Structure maruti is nested within
structure engine. c) 1,2,3,4,5,6,7,8
d) Structure maruti is nested within d) Segmentation fault
structure bolts. 32. What does "typedef unsigned int
Uint;" do?
30. char *m[] = { a) it is ignored by the compiler
“Chandu Ke Chacha Ne”, b) it renames an unsigned integer
“Chandu Ki Chachi Ko”, data type as Uint
“Chaandi Ki Chamach Se”, c) it causes a compiler error
“Chutney Chataai !!!!!!” d) it renams an integer data type as
}; Uint.
void main( )
{ 33. The output will be
int i; int main()
for(i=0,i<=3;i++) {
Printf(“\n%s”,m[1]); int i = 5, j = 2;
} junk (&i, &j);
a) Chandu Ke Chacha Ne printf(“\n %d %d”,i,j);
Chandu Ki Chachi Ko }
Chaandi Ki Chamach Se junk ( int *i, int *j)
Chutney Chataai!!!!!! {
*i = *i **i;
b) Chandu Ki Chachi Ko *j = *j**j;
Chandu Ki Chachi Ko }
Chandu Ki Chachi Ko a) 25 , 4
Chandu Ki Chachi Ko b) 25, 2
c) 5, 4
c) Chaandi Ki Chamach Se d) 5, 2
Chaandi Ki Chamach Se
Chutney Chataai 34. Select the proper order of events.
Chutney Chataai a) Debug program, write results, load
program, describe objective, run
d) All of the above program, record results.
31. What is the output? b) Describe objective, write program,
int main( ) record results, load program, debug
{ program, , run program
struct num c) Run program, record results, load
{ program, describe objective, record
int x,y; results, debug program.
} val[4] = { 1,1,2,3,4,5,6,7}; d) Describe objective, write program,
struct num *ptr = val; debug program, load program, run
int i = 0; program, record results.
for(;i<4;i++) {
ptr->x = ptr->y, ++ptr++->y; 35. What will be output of following
printf("%d,%d ", val[i].x, val[i].y); program?
}
} #include “stdio.h”
a) 1,3,2,5,4,7,6,9 void main( )
b) Undefined behavior {
char *str="i know u ."; }
clrscr( ); while( ( ch = getc (fp))!=EOF)
while(*str) printf (“%c”,ch);
{
fclose(fp);
putc(*str,stdout);
fputchar(*str); }
printf("%c",*str); a) Kickt 44-a Gokulpeth nagpur
str++; b) Kickt 44-a Gokulpeth
} c) Infinite Loop
getch(); d) None of the above
}
a) iii kkknnnooowww uuu ... 38. Which function call will you add to
b) iiiiii knowwwwwwwwww
the following program to write the
uuuuuuu
c) ii kknnooww uu .. entire structure into the file?
d) None of the above void main( )
{
36. What will be the output of program struct rain _details
(days), if it is executed from the {
command line as shown below? char city[10];
days friday tuesday Sunday
float raininmm;
/* days*/ };
# include<stdio.h> struct rain_details r = {
void main (int argc, char *argv[]) “Banglore”, 40.5
{ };
while(--argc>0) FILE *fp;
printf(“%s”,*++argv); Fp = fopen (“rain.dat”, “wb”);
} /* add function call here */
a) days friday tuesday sunday fclose (fp);
b) friday tuesday sunday a) fread (&r, sizeof ( r ),1,fp);
c) days tuesday sunday b) fwrite (&r, sizeof ( r),1,fp);
d) None of the above c) fwrite (&w, sizeof( w),1,fp);
d) fread (&w, sizeof( w),1,fp);
37. void main( )
{ 39. An expression contains relational,
unsigned char ch; assignment and arithmetic operators. If
parenthesis is not present, the order will
FILE *fp;
be:-
/* ABC.C exists and contains “Kicit 44-a a) Assignment, arithmetic, relational
Gokulpeth\0 nagpur”*/ b) Relational, arithmetic, assignment
fp = fopen ( “abc.c”, “r”); c) Assignment, relational, arithmetic
if (fp = = NULL) d) Arithmetic, relational, assignment
{
printf (“Unable to open the file”); 40. Which of the following gives the memory
exit (1); address of a pointer a?
a) *a;
b) a; printf ("e1 and e2 are different");
c) &a; }
d) Address(a); a) illegal structure operation error
b) e1 and e2 are same
41. In C, arrays and pointers can always be c) e1 and e2 are different
used interchangeably. d) none of these
a) True
b) False 46.Which one of the following statements
allocates enough space to hold an array of
42. In a group of nested loops, which loop is 10 integers that are initialized to 0?
executed the most number of times?
a) the outermost loop a) int *ptr = (int *) malloc(10, sizeof(int));
b) the innermost loop b) int *ptr = (int *) calloc(10, sizeof(int));
c) all loops are executed the same number of c) int *ptr = (int *) malloc(10*sizeof(int));
times d) int *ptr = (int *) calloc(10*sizeof(int));
d) cannot be determined without knowing the
size of the loops 47. What is the output

43. What is the index number of the last int main() {


element of an array with 29 elements? int x=0;
a) 29 for(;x<20 && printf("%d ",x);x++)
b) 28 switch(x) {
c) 0 case 0:x++,x*=2;
d) 27 case 1:x+=2;
case 99:x+=6;
44. Which of the following gives the memory default:x+=3;
address of the first element in array break;
foo, an array with 100 elements? }
a) foo[0]; }
b) foo; a) 0 12 16
c) &foo; b) 0 13 17
d) foo[1]; c) 0 14 18
d) 0 11 15 18
45. What is the output of the following
program? 48. What is the output

main () void main() {


{ char *s[]={ "miller","miller","filler","filler"};
struct emp char **p;
{ p=s;
char name[20]; printf("%s ",++*p);
int empno;} printf("%s ",*p++);
}; printf("%s ",++*p);
struct emp e1 = {"harrypotter", 1311}; }
struct emp e2 = e1; a) iller miller iller
if (e1==e2)
printf ("e1 and e2 are same"); b) iller miller filler
else
c) iller iller filler
d) iller iller iller

49. char ** array [12] [12][12];


Consider array, defined above. Which one
of the following definitions and
initializations of p is valid?

a) char ** (* p) [12][12] = array;


b) char ***** p = array;
c) char * (* p) [12][12][12] = array;
d) char (** p) [12][12] = array;

50. What will be the output when following


code is executed
int a=10,b;
b=a++ + ++a;
printf("%d,%d,%d,%d",b,a++,a,++a);

a) 22,13,13,13
b) 22,10,11,13
c) 22,11,11,11
d) 22,11,13,14

You might also like