TCS NQT Programming Logic Questions With Answers: C Pragramming 1
TCS NQT Programming Logic Questions With Answers: C Pragramming 1
TCS NQT Programming Logic Questions With Answers: C Pragramming 1
with Answers
C Pragramming
1. What will be returned in the following C code?
Answer: b
Explanation: The strlen() function is used to return the length of the string s.
Answer: a
CPP
3. What will be the output of the following C++ code?
a) 15 18 21
b) 21 21 21
c) 24 24 24
d) Compile time error https://www.freshersnow.com/placement-papers-download/
Answer: b
Explanation: a[1][2] means 1 * (4)+2 = 6th element of an array starting from zero.
Output:
Answer: d
Explanation: All the above mentioned are advantages and properties of call by
reference.
Java
5. What will s2 contain after following lines of Java code?
a) one
b) two
c) onetwo
d) twoone
Answer: c
Explanation: Two strings can be concatenated by using append() method.
Answer: a
Explanation: Java assigns to each thread a priority that determines hoe that
thread should be treated with respect to others. Thread priority is integers that
specify relative priority of one thread to another.
Data Structures
7. Which node is the child node of the Node D in the following ternary tree?
a) A
b) C
c) B
d) No child node
Answer: d
Explanation: Since Node D is the Leaf node of the above ternary tree and leaf
node has no child node. So there is no child node for Node D in the above
ternary tree.
Answer: b
Explanation: The string is read from right to left because a prefix string has
operands to its right side.
CPP
9. Which is used to describe the function using placeholder types?
a) template parameters
b) template type parameters
c) template type
d) type parameters
Answer: b
Explanation: During runtime, We can choose the appropriate type for the function
and it is called as template type parameters.
Answer: c
Explanation: As the value of b = 0 is provided to the func() and the function is throwing
an exception whenever the value of b = 0. Therefore the function throws the exception
which will be printed on the screen.
Output: