Mascot Previous Years Solved Sample Placement Papers
-
Which of the following is the correct class of the object
cout
?A: iostream
B: istream
C: ostream
D: ifstream
Ans: C -
Which of the following cannot be used with the keyword
virtual
?A: class
B: member functions
C: constructor
D: destructor
Ans: C -
Which of the following problem causes an exception?
A: Missing semicolon in statement in
main()
.B: A problem in calling function
C: A syntax error
D: A run-time error
Ans: D -
Which one of the following options is correct about the statement given below? The compiler checks the type of reference in the object and not the type of object.
A: Inheritance
B: Polymorphism
C: Abstraction
D: Encapsulation
Ans: B -
What will be the output of the following program?
#include <iostream.h> void main() { float x; x = (float)9/2; cout << x; }
A: 4.5
B: 4.0
C: 4
D: 5
Ans: A -
The term __________ means the ability to take many forms.
A: Inheritance
B: Polymorphism
C: Member function
D: Encapsulation
Ans: B - What is the result of the following operation? Top (Push (S, X))
a) X
b) X+S
c) S
d) XS
Answer: aExplanation: The function Push(S,X) pushes the value X in the stack S. Top() function gives the value which entered last. X entered into stack S at last.
- The prefix form of an infix expression (p + q) – (r * t) is?
a) + pq – *rt
b) – +pqr * t
c) – +pq * rt
d) – + * pqrt
Answer: cExplanation: Given Infix Expression is ((p+q)-(r*t)) (+pq)-(r*t) (-+pq)(r*t) -+pq*rt. Thus prefix expression is -+pq*rt.
- Which data structure is used for implementing recursion?
a) Queue
b) Stack
c) Array
d) List
Answer: bExplanation: Stacks are used for the implementation of Recursion.
- What data structure is used when converting an infix notation to prefix notation?
a) Stack
b) Queue
c) B-Trees
d) Linked-list
Answer: aExplanation: First you reverse the given equation and carry out the algorithm of infix to postfix expression. Here, the data structure used is stacks.
- What would be the Prefix notation for the given equation? A+(B*C)
a) +A*CB
b) *B+AC
c) +A*BC
d) *A+CB
Answer: cExplanation: Reverse the equation or scan the equation from right to left. Apply the infix-postfix algorithm. The equation inside the bracket evaluates to CB* and outside the bracket evaluates to A+ therefore getting CB*A+. Reversing this and we get +A*BC.
- What would be the Prefix notation for the given equation? (A*B)+(C*D)
a) +*AB*CD
b) *+AB*CD
c) **AB+CD
d) +*BA*CD
Answer: aExplanation: Reverse the equation or scan the equation from right to left. Apply the infix-postfix algorithm. The equation inside the brackets evaluate to DC* and BA* respectively giving us DC*BA*+ in the end. Reversing this we get the +*AB*CD.
- What would be the Prefix notation for the given equation? (a+(b/c)*(d^e)-f)
a) -+a*/^bcdef
b) -+a*/bc^def
c) -+a*b/c^def
d) -a+*/bc^def
Answer: bExplanation: Reverse the equation or scan the equation from right to left. Apply the infix-prefix algorithm. The preference order in ascending order are as follows +*/^. Brackets have the highest priority. The equations inside the brackets are solved first.
- What would be the Prefix notation and Postfix notation for the given equation? A+B+C
a) ++ABC and AB+C+
b) AB+C+ and ++ABC
c) ABC++ and AB+C+
d) ABC+ and ABC+
Answer: aExplanation: For prefix notation there is a need of reversing the giving equation and solving it as a normal infix-postfix question. We see that it doesn’t result as same as normal infix-postfix conversion.
- What would be the Prefix notation for the given equation? a|b&c
a) a|&bc
b) &|abc
c) |a&bc
d) ab&|c
Answer: cExplanation: The order of preference of operators is as follows (descending): & |. The equation a|b&c will be parenthesized as (a|(b&c)) for evaluation.