Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
100% found this document useful (1 vote)
2K views

TCS NQT Questions and Answers For Programming Logic

This document contains 10 questions and answers about programming logic, C, C++, Java, and data structures. The questions cover topics like function return types in C, using header files and algorithms in C++, array declarations in Java, and properties of data structures like incidence matrices, linked queues, and trees. The answers provided explanations for choosing the correct response.

Uploaded by

Samkit Sanghvi
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
2K views

TCS NQT Questions and Answers For Programming Logic

This document contains 10 questions and answers about programming logic, C, C++, Java, and data structures. The questions cover topics like function return types in C, using header files and algorithms in C++, array declarations in Java, and properties of data structures like incidence matrices, linked queues, and trees. The answers provided explanations for choosing the correct response.

Uploaded by

Samkit Sanghvi
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

TCS NQT Questions and Answers

for Programming Logic


C Programming

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

2. What will be the output of the following C code?

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.

4. Pick out the compound assignment statement.


a) a = a – 5
b) a = a / b
c) a -= 5
d) a = a + 5
Answer: c
Explanation: When we want to modify the value of a variable by performing an
operation on the value currently stored, We will use compound assignment
statement. In this option, a -=5 is equal to a = a-5.
https://www.freshersnow.com/placement-papers-download/

5. Which method do we use to append more than one character at a time?


a) append
b) operator+=
c) data
d) both append & operator+=

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

8. What are the dimensions of an incidence matrix?


a) Number of edges*number of edges
b) Number of edges*number of vertices
c) Number of vertices*number of vertices
d) Number of edges * (1⁄2 * number of vertices)
Answer: b
Explanation: Columns may represent edges and vertices may be represented by
the rows. https://www.freshersnow.com/placement-papers-download/

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.

You might also like