You are on page 1of 6

1) a) b) c) d) 2) a) b) c) d) 3) a) b) c) d) 4) a) 5


Who will allocate the memory for the statement int i; compiler linker operating system device driver Which of the following statement is true? Dynamically allocated memory will not be released automatically when function returned. Statically allocated memory will not be released automatically when function returned. If constructor is defined as private then it is not possible to invoke it. Memory device driver inserts unused blocks into the free blocks list. In which of the following case copy constructor will not be called? When object initialize When object is passed as a parameter to a function. When temporary object created and returns the value to main function. When object is assignment is taken place When to declare base class destructor virtual? class hierarchy uses dynamic binding

a) b) c) d)

An implementation of a queue Q, using two stacks S1 and S2, is given below: Void insert(Q, x) { Push(S1, x); } Void delete(Q) { If(stack-empty(s2)) then If(stack-empty(S1)) then { Print(“Q is empty”); Return; } Else while(!(stack-empty(S1))) { X = pop(S1); Push(S2,x); } } Let n insert and m(<=n) delete operations be performed in an arbitary order on an empty queue Q. Let x and y be the number of push and pop operations performed respectively in the process. Which one of the following true for all m and n? n+m<=x<2n and 2m<=y<=n+m n+m<=x<2n and 2m<=y<=2n 2m<=x<2n and 2m<=y<=n+m 2m<=x<2n and 2m<=y<=2n

6) Consider the following C-function in which a[n] and b[m] are two sorted integer arrays and c[n+m] be another integer array. Void xyz(int a[], int b[], int c[]) { Int I, j, k; I=j=k=0; While((i<n) && (j<m)) If(a[i] < b[j]) c[k++] = a[i++];

0. fb. k=m+i-1 and b[m-1]<=a[i] if j=m a) only (i) b) only (ii) c) either (i) or (ii) but not both d) both 7) consider the following C-program void foo(int n. 2. 8. k = n % 10.k). 2. /* Line 1 */ Int main() { Float fa. Foo(a.Else c[k++] = b[j++]. sum). int sum) { int k=0. 14 b) 8. 0. j = n/10. //input fa Fb = foo(fa).sum). 0 c) 2. 4. 4. sum). 4. If Line 1 is deleted. j=0. 4. sum += k. 0. the above code will show: a) b) c) d) 9) no compile warning or error some compiler-warnings not leading to unintended results some compiler-warnings due to type-mismatch leading to unintended results compiler errors Consider the following C-program int f(int n) . Printf(“%d\n”. } Float foo(float a) { Return a. if(n==0) return. } Int main() { Int a = 2048. k=n+j-1 and a[n-1]<b[j] if i=n ii) i<n. 0 8) Consider the following C-program: Float foo(float). 14 d) 2. } What does the above program print? a) 8. Which of the following condition(s) hold(s) after the termination of the while loop? i) j<m. 8. sum = 0. printf(“%d”. } The above code compiled without any error or warning. foo(j. 0.

int found = 0. next_pos[1][0] = row. i<len.h> long countPaths. int len = strlen(s). . printf("%s". next_pos[1][1] = col+1. int col) { int next_pos[3][2]. } next_pos[0][0] = row+1. n += i. a) b) c) d) 10) } The value returned by f(1) is 16 18 26 34 The output of the following program is: void foo() { int i. for(i=0. if(row == 3 && col == 3) { countPaths++. //std::cout << row << " " << col << '\n'. return. char p[20]. next_pos[0][1] = col. next_pos[2][0] = row+1.{ static int i=1.h> #include<conio. i++) p[i] = s[len-i]. char *s = "string". f(n). next_pos[2][1] = col+1. i += n. } gnirts string gnirt no output is printed a) b) c) d) #include <iostream.p). int i. int paths = 0. if(n>=10) return n. void findPath(int row.

a. strcpy(a. char *p="New String". //Line number:9// p = malloc(strlen(Temp) + 1). i<3. // clrscr(). char a[]="String". strcpy(p. cout<<"total paths available "<<countPaths<<"\n".next_pos[i][1]). printf("(%s. free(a). char *Temp.p). ii) Each man is associated with exactly 2 lodges. } 11) There are some men and some lodges for which the following conditions hold true – i) Each lodge is represented by exactly 3 men . Temp=a.0). } } return.for(i=0. } //Line number 15// a) Swap contents of p & a and print:(New string.Temp). //Line number: 7) a=malloc(strlen(p) + 1).p). iii) Any pair of lodge has only one man in common. getch(). free(p). } int main() { findPath(0. i++) { if(next_pos[i][0] < 4 && next_pos[i][1] < 4) { printf("(%d. string) b) Generate compilation error in line number 7 c) Generate compilation error in line number 8 .%d)".next_pos[i][0]. %s)". How many men and how many lodges were there? a) 6 b) 8 c) 8 d) 8 men men men men and and and and 4 4 5 6 lodges lodges lodges lodges 12) What will the following program do? void main() { int i. findPath(next_pos[i][0].next_pos[i][1]).

PrintVal(). Sample(int i) { ptr = new int(i). } int main() { Sample s1= 10. char *p2. } }. foo(s1).p2). void foo(Sample x) { cout << x. while(*p2++=*p1++). } ~Sample() { delete ptr. } void PrintVal() { cout << "The value is " << *ptr + p. s1. *ptr = I.p.d) Generate compilation error in line number 10 13) Find the output for the following C program main() { char *p1=”String". } a) b) c) d) Compilation error Run time error String No output printed 14) class Sample { public: int *ptr. printf("%s\n". p2=(char *)malloc(20). } a) Compilaion error . p = I. int p.

a1= =a2. } } void main(){ foo a1. return true. bool foo::operator==(foo temp){ if(*this == temp ) { cout<<"The both are same objects\n". }. } e) f) g) h) 16) Compilaion error Run time error The both are same objects The both are different objects . return false. a2. }Else { cout<<"The both are different objects\n".b) Run time error c) Linker error d) 1020 15) class foo{ public: bool operator==(foo temp).