Sei sulla pagina 1di 15

Section A

1.Which is the parameter that is added to every non static member function when it is
called?
Ans:- this pointer

2.What does object.method1().method2() signature called in c++?


a. Nested method
b. method chaining
c. method overloading
d. none of the above
Ans:-b

3.What is the output of the following program?


Main()
{
Int i=0;
for(i=0;i<20;i++)
{
Switch(i)
{
Case 0: i+=5;
Case 1: i+=2;
Case 5: i+=5;
default: i+=4;
break;
}
printf("%d",i);
}
}
a. 0,5,9,13,17
b. 5,9,13,17
c. 12,17,22
d. 16,21
e. syntax error
Ans:-d

4. What is the output of the following program?

class some
{
public:
~some()
{
cout<<"some's destructor"<<endl;
}
};
void main()
{
some s;
some.~some();
}
Ans:- Error member identifier expected at s.~some() statement

5. What is the output of the following program?


main()
{
char *p;
int *q;
long *r;
p=q=r=0;
p++;
q++;
r++;
printf("%p...%p...%p",p,q,r);
}
Ans:-Error: cannot convert 'long*' to 'int*' and 'int*' to 'char*' in p=q=r

6. What is the output of the folling program?


#include<stdio.h>
main()
{
struct xx
{
int x;
struct yy
{
char s;
struct xx *p;
};
struct yy *q;
};
}
Ans:- no warning. run time exception, general protection fault.

7. What is output of the below program?


void main()
{
int a=30;
printf("%d");
}
a. prints a blank space
b. it will give syntax error
c. prints a value 31783972
d. prints a value 30
e. prints a value which varies from compiler to compiler.
Ans:- d

8. From the program


int foo(int a,int b)
{
if( a&b)
return 1;
return 0;
}
a. if either a or b is zero then the function returns 0
b. if both a & b are non zero then the function returns 1
c. if both a and b are negative then the function returns 0
Ans :- option a & option b

9. Name some pure object oriented languages.


Ans:- small talk , ruby, Eiffel

10. What is the output of the following rpogram?


char *foo()
{
char result[100];
strcpy(result,"anything is good");
return(result);
}
void main()
{
char *j;
j=foo();
printf("%s",j);
}
Ans:- Output: anything is good

11. What is the type of the algorithm used in solving the 8 queens problem?
Ans:- Backtracking

12. Wheter Linked list is a linear or non linear data structure?


Ans:- According to Access stategies Linked list is a linear one According to Storage
linked list is a non linear one.

13. Minimum number of queues needed to implement the priority queue?


Ans:- two

14. How many different trees are possible with 10 nodes?


Ans:- 1014

15. Which datastructure is used to perform recursion?


Ans:-Stack

16. In selecting the pivot for Quicksort, which is the best choice for optimal
partitioning:
a. the first element of the array
b. the last element of the array
c. the middle element of the array
d. the largest element of the array
e. the median of array
Ans:-

17. A binary tree with 20 nodes has _______ null branches?

Null Branches

Ans:- 20+1=21

18. Compare and contrast TRUNCATE anad DELETE for a table?


Ans:- 1. truncate is DDL comand, Delete is DML
2. delete operation can be rolled back but truncate can't
3. 'where' clause can be used wit delete and not with truncate

19. What is the basic difference between a join and a union?


Ans:-

20. Can a view be updated/inserted/deleted?If yes-under what condition?


Ans:-

21. Which of the following join will produce Cartesion product?


a. inner join
b. self join
c. outer join
d. natural join
Ans:- d

22. Which of the constraints are used to achieve referential integrity?


a. Primary Key
b. Unique Key
c. Foreign Key
d. Not Null constraint

23. Which of the following is not a transaction control statement?


a. commit
b. merge
c. rollback
d. save point
Ans:-b
24. Suppose a table has 100 rows and view has been created on that table. Later all the
rows in the table have been deleted. How many rows the has now?
a. 50
b.0
c.100
d. None of the above
Ans:-

25. Which of the following is not among ACID proporties?


a.Atomocity
b.Integrity
c.Consistency
d.Durability
Ans:-b

26. Which of the following is not an aggregate function?


a.distinct
b.max
c.sum
d.count

27. What is the output of the following program?


class OpOverload
{
public:
bool operator==(OpOverload temp)
};
bool OpOverload::operator==(OpOverload temp)
{
if(*this==temp)
{
cout<<"Both the objects are the same\n";
return true;
}
else
{
cout<<"objects are different\n";
return false;
}
}
void main()
{
OpOverload a1,a2;
a1==a2;
}
Ans:-Runtime Error:Stack Overflow

28. Write the output of the following program.


main()
{
int x=20,y=35;
y=++y + --x;
x=y-- + x++;
printf("x : %d\t y :%d\n ",x,y);
}
Ans:-x:75 y:54

29. Supposewe are sorting an array of eight integers using quicksort, and we have just
finished the first partitioning with array looking like this:
2 5 1 7 9 12 11 10
which statement is correct?
a.the pivot could be either the 7 or the 9
b.the pivot could be the 7, but it is not the 9
c.the pivot is not 7, but it could be the 9
d.neither the 7 nor the 9 is the pivot
Ans:- a

30. Can the abstract method have the static qualifier?


Ans:-

2. What does someFunction do?

int someFunction (int n1, int n2)


{
int result;
result = 1;
if (! (n2<=0))
{
if (n2%2 == 1)
{
result = result * n1;
}
result = result * someFunction (n1*n2,n2/2);
}
return result;
}

Ans: (n1)^n2

3. Convert the following C declaration into English description


Eg, int *x;
x is a pointer to an integer

a. int (*x[10]) (int)


b. char (*(x[3]())[5];

Ans: a. array of pointers


b. pointer to array function
4. #define unsafe(i) \
( (i) >= 0 ? (i) : -(i))
int safe (int i)
{
return i >=0 ? i : -i;
}
int f (int *x)
{
return ++(*x);
}
void main ()
{
int x;
x = 5;

x = unsafe (f(&x));
printf (“%d”, x);

x = safe (f(&x));
printf (“%d”, x);
}

What the output of above program?


a. 6, 7 b. 5, 7
c. 6, 8 d. 7, 8
e. 5, 5
Ans: a. 6, 7

5. Write the output of the following program


myfunc (a, b)
int a, b;
{
return ( a= (a==b));
}
main()
{
int process(), myfunc();
printf (“the value of process is %d !\n”, process(myfunc, 3,6));
}
process(pf,val1,val2)
int (*pf) ();
int val1, val2;
{
return ((*pf) (val1,val2));
}
Ans: Error: extra parameter in call in function process(), if the error is rectified then it
will give 0.

6. Assuming that a pointer takes 2 bytes of memory, what would be the output for the
following program
void main(int argc, char argv[])
{
int a=4, b=-2;
char *cp= “abcdef”;
int grade[5] = {3, 2, 1, 0, -1};
printf(“a.%d\n”, -b/a);
printf(“b.%d\n”, ++a + b++);
printf(“c.%d\n”, *grade+2);
printf(“d.%d\n”, cp[3]);
printf(“e.%d\n”, strlen(cp));
printf(“f.%d\n”, sizeof(cp));
}
Ans: printf(“a.%d\n”, -b/a);  a.0
printf(“b.%d\n”, ++a + b++);  b.3
printf(“c.%d\n”, *grade+2);  c.1
printf(“d.%d\n”, cp[3]);  d.101
printf(“e.%d\n”, strlen(cp));  e.6
printf(“f.%d\n”, sizeof(cp));  f.2

7. what is the output for the following code?


class base
{
public:
virtual void baseFun() {cout<< “from base”<< end1; }
};
class deri: public base
{
public:
void baseFun() { cout<< “from derived”<<end1; }
};
void SomeFunc(base *baseObj)
{
baseObj -> baseFun();
}
int main()
{
base baseObject;
SomeFunc(&baseObject)l
deri deriObject;
SomeFunc(&deriObject);
}
Ans: From base
From derived

8. Write the output for the following program


class complex
{
double re;
double im;
public:
complex (): re(1), im(0.5) { }
bool operator==(complex &rhs) {
operator int() { }
};
bool complex: : operator == (complex &rhs) {
if((this->re == rhs.re) && (this->im == rhs.im))
return true;
else
return false;
}
}
int main () {
complex c1;
cout<< c1;
}

Ans: ERROR

9. What is the output of the following snippet?


#include<stdio.h>
class test
{
private:
static int n;
public:
void inc( )
{
n++;
}
void display ( )
{
printf( “value : : %d\n”);
}
};
int test: : n = 0;
void main ( )
{
test a,b;
a.inc( );
a.display( );
b.inc( );
b.display( );
}

Ans: value: :1
value: :2

10. In the given binary tree, using array you can store the node at 4 at which location?
1

Ans: In array, node 4 can be stored in 5th location.

11. Convert the expression ((A+B) * C-(D-E)^(F+G)) to equivalent Prefix and Postfix
notations.
Ans: Prefix: ^ - * + ABC – DE + FG
Postfix: AB + C * DE - - FG + ^

12. Consider the following binary tree.

D T

B M X

A C L K Y

P
(a) What is the result of a postorder traversal of the above tree?
Ans: ACBDIPKMYXTG
(b) What is the result of a inorder traversal of the above tree?
Ans: ABCDGIMKPXY
(c) Is the above tree a binary search tree? Why or why not?
Ans: Yes, since it has 2 or less than 2 child node of each node.

13. What is the order of each of the following tasks? (Choose from O(1), O(log2 n),
O(n), O(n log2 n), O(n2), O(2n); each order may appear more than once.)
(a) Pooping an item off a stack containing n items.
(b) Performing a Towers of Hanoi algorithm with n disks.
(c) Using quick sort to sort an array of n integers, in the average case.
(d) Using quick sort to sort an array of n integers, in the worst case.
(e) Inserting a single item into a binary search tree containing n items, in the
average case.
(f) Performing a bubble sort on an array of n integers, in the worst case.
(g) Displaying all n elements in a sorted linked list.
(h) Performing a binary search of a sorted array of n strings, in the worst
case.

14. Match the following regular expressions

1. ab*a A. a
2. (ab)*a B. abe
3. [a-e]{2,4} C. bbacd
4. [a-e][a-e]{4,5} D. abbbbba

15. Write a query to get the same rows from two tables A and B
Ans: select * from Sailors s, Boats b where s.sid=b.bid.

16. Write a query to list the maximum salary in such departments which have more
than two employees from table EMP which has columns empno, ename, deptno,
salary.

17. Write a query to list the ename and his manager name from table Emp which has
columns empno, ename, mgrno
Ans: select e1.ename, e2.ename from emp e1,e2 where e1.mgrno=e2.empno.

18. Write a query to produce the following output empno, ename, deptname from two
tables emp (empno, ename, deptno) and dept (deptno, deptname)
Ans: select empno, ename, deptname from emp e, dept d where e.deptno=d.deptno;

19. Write a query to find the max salary from emp (empno, ename, salary) without
using max function.

20. If a complete binary tree has 63 nodes then


a. What is the depth of the tree?
b. What is the number of non-leaf nodes?
Ans: a. 6 (2^k – 1=63 => k=6)
b. 32
21. Consider the following graph
1
2 3
2
2 7
2
4 2

8
1
3
1

1 6
0

5
9

1
1 search, starting from vertex 1, and if
If this graph is searched by depth-first
neighbours are searched in numerical order, what will be the order in which the nodes
are visited? (Note: If you use an explicit stack for depth-first search, then the nodes
are visited when they come off the stack, so they have to pushed in reverse numerical
order to be searched in numerical order)

Section C

Section C : 20 questions, 20 marks, 25-30 min.


(1-5) Reasoning Based

1. A person with some money spends 1/3 for cloths, 1/5 of the remaining for food and
1/4 of the remaining for travel. He is left with Rs.100/-. How much did he have with
him in the beginning?
Ans: x(1-(1/3+1/5+1/4))=100
Rs.461.50/-
2. Grass in lawn grows equally thick and in uniform rate. It takes 24 days for 70 cows
and 60 days for 30 cows to eat the whole of the grass. How many cows are needed to
eat the grass in 96 days?
Ans: 18

3. There is a safe with 5 digit number as the key. The 4th digit is 4 greater than the 2nd
digit, while the 3rd digit is 3 less than the 2nd digit. The 1st digit is thrice the last digit.
There are 3 pairs whose sum is 11.
Ans: 29256

4. In Mr. Mehta’s family, there are one grandfather, one grandmother, two fathers,
two mothers, one father-in-law, one mother-in-law, four children, three grandchildren,
one brother, two sisters, two sons, two daughters, and one daughter-in-law. How
many members are there in Mr Mehta’s family? (Give minimal possible number)
Ans:

5. Anshul was studying for his examinations and the lights went off. It was around
1:00 AM. He lighted two uniform candles of equal length but one thicker than the
other. The thick candle is supposed to last six hours and the thin one two hours less.
When he finally went to sleep, the thick candle was twice as long as the thin one. For
how long did Anshul study in candle light?
Ans: 3 hrs.

(6-10) Maths Based

6. A cylinder is 6 cm in diameter and 6 cm in height. If spheres of the same size are


made from the material obtained, what is the diameter of each sphere?
(a) 5 cm (b) 2 cm (c) 3 cm (d) 4 cm
Ans: (b) 2 cm

7. The difference between the compound interest payable half yearly and the simple
interest on a certain sum lent out at 10% p.a for 1 year is Rs.25. What is the sum?
(a) Rs.15000 (b) Rs.12000 (c) Rs.10000 (d) None of these
Ans:

8. What is the smallest number by which 2880 must be divided in order to make it
into a perfect square?
(a) 3 (b) 4 (c) 5 (d) 6
Ans: (c) 5

9. A father is 30 years older than his son, however, he will be only thrice as old as the
son after 5 years. What is father’s present age?
(a) 40 yrs (b) 30 yrs (c) 50 yrs (d) None of these
Ans: (a) 40 yrs

10. 5 men or 8 women do equal amount of work in a day. A job requires 3 me and 5
women to finish the job in 10 days. How many woman are required to finish the job in
14 days?
(a) 10 (b) 7 (c) 6 (d) 12
(11-15) Verbal Based

I felt the wall of the tunnel shiver. The master alarm squealed through my earphones.
Almost simultaneously, Jack yelled down to me that there was a warning light on…
Fleeting but spectacular sights snapped into and out of the view, the snow, the shower
of debris, the moon, looming close and big, the dazzling sunshine for once unfiltered
by layers of air. The last twelve hours before re-entry were particularly bone-chilling.
During this period, I had to go up into the command module. Even after the fiery re-
entry and splashing down in 810 water in the south pacific, we could still see our
frosty breath inside the command module.

11. Which one of the following reasons would one consider as more possible for the
warning lights to be on?
a. There was a shower of debris.
b. Jack was yelling.
c. A catastrophe was imminent.
d. The moon was looming close and big.
Ans: b.

12. The statement that the dazzling sunshine was “for once unfiltered by layers of air”
means
a. That the sun was very hot.
b. That there was no strong wind.
c. That the air was unpolluted.
d. None of the above.
Ans:

13. The word ‘Command Module’ used twice in the given passage indicates perhaps
that it deals with,
a. An alarming journey.
b. A commanding situation.
c. A journey into outer space.
d. A frightful battle.
Ans:

14. What do you mean by squealed.


a. Turn On
b. Sounded
c. Screech
d. Turn off
Ans: c

15.What is the antonym of dazzling?


a. Stunning
b. Glittery
c. Showy
d. Bland
Ans: d
(16-20) : What is the one thing that you would like to change in your hometown?
(Write a short passage not more than 200 words).

Potrebbero piacerti anche