Trilogy Previous Years Solved Sample Placement Papers
-
Pointer = new type[number_of_elements]
is syntax for:A: Pointer declaration
B: Allocate memory for a single element
C: Allocate memory for a block of elements
D: Structure
Ans: C -
In which data structure is each node connected to several other nodes?
A: Non-linear
B: Linear
C: Stack
D: Queue
Ans: A -
Which data structure represents a hierarchical relationship?
A: Non-linear
B: Linear
C: Stack
D: Queue
Ans: A -
Each node in a tree has a child node:
A: Zero
B: More
C: Both A and B
D: No
Ans: C - The condition top=n-1 in stack indicates
a) stack is full
b) stack has one element
c) stack underflow
d) stack is empty
Answer: a) stack is full - In which data structure addition of new element and removal of element takes place at different end
a) non linear
b) linear
c) stack
d) queue
Answer: d) queue - In Queue items are inserted at end
a) Top
b) front
c) rear
d) bottom
Answer: c) rear - In queue items are removed at end
a) Top
b) front
c) rear
d) bottom
Answer: b) front - In queue we remove the element which is
a) least recently added
b) most recently added
c) both a and b
d) none
Answer: a) least recently added - Queue is also called as
a) last in first out
b) first in last out
c) first in first out
d) first in first in
Answer: c) first in first out - In queue which operation is generally called as push
a) enqueue
b) dequeue
c) push
d) pop
Answer: a) enqueue -
Consider the following class definitions:
class a { }; class b : protected a { };
What happens when we try to compile this class?
A: Will not compile because the class body of
a
is not defined.B: Will not compile because the class body of
b
is not defined.C: Will not compile because
class a
is not publicly inherited.D: Will compile successfully.
Ans: D -
Which of the following statements are true in C++?
A: Classes cannot have data as public members.
B: Structures cannot have functions as members.
C: Class members are public by default.
D: None of these.
Ans: B -
The use of the break statement in a switch statement is:
A: Optional
B: Compulsory
C: To check an error
D: None of the above
Ans: A -
To be called object-oriented, a programming language must allow:
A: Functions that return only a single value
B:
#include
filesC: Inheritance
D: All of the above
Ans: C -
What is true about inline functions ?
A: It's a compulsion on the compiler to make function inline
B: It's a request to the compiler to make the function inline
C: It's the indication to the compiler that the function is recursive
D: It's the indication to the compiler that the function is member function
Ans: B -
Which member function of class cannot modify its objects attributes ?
A: friend functions
B: Private member functions
C: Constant member functions
D: Static member functions
Ans: C -
Which of the following parameter passing mechanism is/are supported by C++ but not in C?
A: Pass by value
B: Pass by reference
C: Pass by value result
D: All of the above
Ans: B -
Which of the following type of function is an ideal candidate for being declared inline ?
A: A function that is small and is not called frequently
B: A function that is small and is called frequently
C: A function that is not small and is not called frequently
D: A function that is not small and is called frequently
Ans: B -
One of the disadvantage of pass by reference is that the called function may inadvertently corrupt the called data. This is avoided by ?
A: passing pointers
B: declaring the formal parameters constant
C: declaring the actual parameters constant
D: all of above
Ans: B -
When an argument is passed by reference:
A: A variable is created in the function to hold the argument value
B: The function cannot access the argument value
C: A temporary variable is created in the calling program to hold the argument's value
D: None of these
Ans: A -
Overloaded functions:
A: Are a group of functions with the same value
B: All have the same number and types of arguments
C: Make life simpler for programmers
D: May fail unexpectedly due to stress
Ans: C -
A static function:
A: Should be called when an object is destroyed
B: Is closely connected with an individual object of a class
C: Can be called using the class name and function
D: Is used when a dummy object must be created
Ans: C -
Dividing a program into functions:
A: Is the key to object-oriented programming
B: Makes the program easier to conceptualize
C: Makes the program run faster
D: Both B and C
Ans: C -
Static member function:
A: Can access any other member function & member variables
B: Can access only static member variables & member functions
C: Can be called only through the object of the class
D: Returns only static data
Ans: B -
Which of the following statements is correct?
A: C++ enables defining functions that take constants as an argument.
B: We cannot change the argument of functions that are declared as constant.
C: Both A and B.
D: We cannot use the constant while defining the function.
Ans: C - During conversion of infix to postfix pop is done when appears
a) (
b) )
c) ~
d) ::
Answer: b) ) - Each operator in postfix string refers to its operand in a string
a) previous 3
b) next 3
c) next 2
d) previous 2
Answer: d) previous 2