TCS NQT Questions and Answers For Programming Logic
TCS NQT Questions and Answers For Programming Logic
1. What will be the data type returned for the following C function?
a) char
b) int
c) double
d) multiple type-casting in return is illegal
Answer: b
a) Before memmove place= string1, src = string2 After memmove place = string2,
src = string2
b) Before memmove place = string2, src = string2 After memmove place= string1,
src = string2
c) Before memmove place = string2, src = string1 After memmove place= string2,
src =string2
d) Before memmove place= string1, src = string2 After memmove place=string1,
src = string1
Answer: a
Explanation: In the C library function void *memmove(void *str1, const void *str2,
size_t n) copies n characters from str2 to str1.
CPP
3. Which of the header file is used to implement algorithms provided by C++ STL?
a) <algorithm>
b) <header>
c) <algos>
d) <Algorithm>
Answer: a
Explanation: <algorithm> header is provided by the C++ to use STL algorithms.
Answer: d
Explanation: C++ allows to append more characters to string using both inbuilt
append() function and using operator overloaded += operator.
Java
6. Which of these is an incorrect array declaration?
a) int arr[] = new int[5]
b) int [] arr = new int[5]
c) int arr[] = new int[5]
d) int arr[] = int [5] new
Answer: d
Explanation: Operator new must be succeeded by array type and array size.
7. In the following Java code, which code fragment should be inserted at line 3 so
that the output will be: “123abc 123abc”?
a) sb1.append(“abc”); s1.append(“abc”);
b) sb1.append(“abc”); s1.concat(“abc”);
c) sb1.concat(“abc”); s1.append(“abc”);
d) sb1.append(“abc”); s1 = s1.concat(“abc”);
Answer: d
Explanation: append() is stringbuffer method and concat is String class method.
append() is stringbuffer method and concat is String class method.
Data Structures
9. The essential condition which is checked before deletion in a linked queue is?
a) Underflow
b) Overflow
c) Front value
d) Rear value
Answer: a
Explanation: To check whether there is element in the list or not.
10. Which one of the following data structures are preferred in database-system
implementation?
a) AVL tree
b) B-tree
c) B+ -tree
d) Splay tree
Answer: c
Explanation: The database-system implementations use B+ -tree data structure
because they can be used for multilevel indexing.