TCS NQT Programming Language Logic Q&A
TCS NQT Programming Language Logic Q&A
Q&A
C Programming
Answer: a
Explanation: fopen() opens the named file, and returns a stream, or NULL of the
attempt fails.
a) yes
b) yes no
c) Duplicate case value error
d) Character case value error
https://www.freshersnow.com/placement-papers-download/
Answer: c
CPP
3. What are the advantages of passing arguments by reference?
a) Changes to parameter values within the function also affect the original
arguments
b) There is need to copy parameter values (i.e. less memory used)
c) There is no need to call constructors for parameters (i.e. faster)
d) All of the mentioned
Answer: d
Explanation: All the above mentioned are advantages and properties of call by
reference.
Answer: a
Explanation: <any> header file is required to use any container and its realted
functions.
Java
Answer: a
Explanation: push() and pop() are standard functions of the class stack, push()
inserts in the stack and pop removes from the stack. 3 & 2 are inserted using
push() the pop() is used which removes 2 from the stack then again push is used
to insert 5 hence stack contains elements 3 & 5.
Output:
Answer: a
Explanation: A BlockingQueue without any intrinsic capacity constraints always
reports a remaining capacity of Integer.MAX_VALUE.
Data Structures
7. What will be result if the given stack is popped?
a) pat
b) tap
c) atp
d) apt
Answer: b
Explanation: The word ‘pat’ is pushed on to the stack. When the characters of the
stack are popped one by one, the word ‘tap’ is obtained.
8. What is wrong with below code for inorder traversal of inorder threaded binary
tree:
Answer: a
Explanation: Property of inorder threaded binary tree is left node with inorder
predecessor and right node with inorder successor information are stored.
9. What does the following function do for a given Linked List with first node as
head?
a) Prints all nodes of linked lists
b) Prints all nodes of linked list in reverse order
c) Prints alternate nodes of Linked List
d) Prints alternate nodes in reverse order
Answer: b
Explanation: fun1() prints the given Linked List in reverse manner.
For Linked List 1->2->3->4->5, fun1() prints 5->4->3->2->1.
Java
10. What will be the output of the following Java program?
a) 1
b) 2
c) 3
d) 4
Answer: b
Explanation: trimTosize() is used to reduce the size of the array that
underlines an ArrayList object.
Output: