 # TCS NQT PROGRAMMING LOGIC QUESTION PAPER WITH SOLUTION | SEPTEMBER 12 2021

TCS NQT PROGRAMMING LOGIC QUESTION PAPER WITH SOLUTION | SEPTEMBER 12 2021

We at gradjobopenings.com provide free job alerts of freshers job drives. In this website we list on campus job openings for freshers and off campus job openings for freshers and also work from home job openings. This is the best website to apply for off campus drive in India. Visit our website for government job alerts and private job alerts. We also list free interview notes and study materials, one of the best interview study website.comfortable to face the interviews:

Question 1 :

What will be the output of the following pseudo code

function f()

Integer  x,y,z

x=3,y=4,z=4

print((z>=y>=x)?1:0);

End function

1. 6
2. 0
3. 1
4. 5

Ans:- 0

Question 2 :

What will be the output of the following pseudo-code

#include<stdio.h>

int main()

int a,b=0;

static int c = {11,22,33,44,55,66,77,88,99,100};

for(a=0;a<7;++a)

{

if((c[a]%2)==1)

b+=c[a];

}

printf(“%d”,b);

return 0;

}

Options

1. 255
2. 176
3. 180
4. 200

Question 3 : What will be the output of the following code

#include<stdio.h>

Int main()

{

Int value=0,x=0;

for(x=0;x<5;x++)

{

value++;

Continue;

printf(“%d”,x);

}

1. 0
2. 01234
3. 1
4. Nothing will be printed on the screen

Answer-(option d)Nothing will be printed on the screen

Question 4 :

In which level of testing are the stubs modules used?

Options

1. System testing
2. User acceptance testing
3. Integration testing
4. Unit testing

Question 5:At least two queues are required for the implementation of_____

2. Interpolation search
3. Interval search
4. Sequential search

Question 6:

Marian decides to divide the system modules into smaller programs and allocates them to the members of the system …………………

As a single unit. Which of the below phases is Marian implementing?

Options

1. System Implementation Phase
2. System Design phase
3. System requirements phase
4. System planning phase

Question 7:

Which is TRUE about polymorphism related to the compiler from the below options?

1. Compiler is a check type of object, not a type of reference.
2.  Compiler does not check the type of reference nor the type of object
3. Compiler is both a check type of object and a type of reference
4.  Compiler is a check type of reference, not a type of object

Question 8:

Which computer algorithm is not based on divide and conquer algorithm

1. Quick sort
2. Job scheduling problem
3. Merge sort
4. Closet pair

Question 9:

What is the output of prefix expression +,-,*,7,2,/,9,3,1 ?

1. 10
2. 11
3. 12
4. 13

Question 10:

What is the time complexity of matrix chain multiplication?

1. O(n^3)
2. O(nlogn)
3. O(n^2)
4. O(2^n)

Ans:- O(n^3)

Question 11:

The name of the method that might work differently depending on what argument is passed to it is called ______

Options

1. Inheritance
2. Method overriding
4. abstraction

Question 12:

What is the output of the following code

Integer digit=0

If digit

Print 1

Else

Print digit

End if

1. 1
2. Digit
3. 0
4. Nothing will be printed

Ans:-  c) 0

Question 13:

What is the output of the following pseudo code

read integer rose = 1, lotus =2;

rose += lotus = rose

Print rose

Print lotus

Options

1. 11
2. 22
3. 21
4. 12

Ans:- c) 21

Question 14:

Evaluation of the cyclomatic complexity comes under which type of testing

1. White box testing
2. Black box testing
3. Grey box testing
4. Stress testing

Answer- (option a) White box testing

Question 15:Jacob wants to reuse the following loop inversely-> for (mile=0;mile<dest;mile++). Which of the options is most suited?

1. for(mile=dest; mile>0;mile–)
2. for(mile=dest; mile>=0;mile–)
3. for(mile=dest-1; mile>-1;mile–)
4. for(mile=dest-1; mile>0;mile–)

Ans:- c

Question 16:

Below is the JSON format to store employee data

{

“Id” : “001”,

“Name” : “John”,

“Department” : “QA”

}

A JSON format, designed with a collection of(key, value) and pairs in which each of the key …………………………………..

Which type of data structure is most suitable to implement JSON Format?

Options

1. AVL Tree
2. Associative Tree

Question 17:

Katie has to allocate resources for project work involving the classical waterfall method. Which phase of the waterfall method would require………..effort and Katie to allocate more resources?

effort and Katie to allocate more resources?

Options

1. Testing phase
2. Design Phase
3. Development phase
4. Maintenance Phase

Question 18: What does the below code snippet perform?

Public void navigate(Tree root)

{

navigate(root.left);

cout<<root.data;

navigate(root.right);

}

1. Level order traversal
2. Postorder traversal
3. Preorder traversal
4. Inorder traversal

Ans:- d) Inorder traversal

Question 19:

What will be the output of the following code

#include <iostream>

using namespace std;

int main()

{

int skip_num;

for(skip_num=1;skip_num<=5;skip_num++){

if(skip_num==2|| skip_num==4){

continue;

}

cout<<skip_num;

}

return 0;

}

1. 1 3 4 5
2. 2 4 6
3. 1 3 5
4. 1 2 5

Ans:- B. 1 3 5

Question 20:

What is the output of the following code

#include<stdio.h>

int problem(int num)

int main()

int solution = problem(1);

printf(“%d\n”,solution);

}

int problem(int num)

{

if(num > 5)

exit(0);

return(++num);

}

Question 21:

David is checking the complexity of time on all types of traversals. Which of the below is most suited for BFS?

Options

1. O(V+E)
2. O(log n)
3. O(1)
4. O(log n)/2

Ans:- a) O(V+E)

Question 22:

What is the output of the following code

#include<iostream.h>

using namespace std;

int main ()

{

int a=3, b=5;

while(b–)

a++;

cout << a;

return 0;

}

Question 23:

What will be the output of the following code below

#include <iostream>

using namespace std;

void f(int *p,int *m){

*m=*m+3;

*p=*p+*m;

return;

}

int main(){

int i=5,j=6;

int k=0;

f(&i,&j);

k=i*j;

printf(“%d”,k);

return 0;

}

1. 138
2. 126
3. 135
4. 134

Ans:-B) 126