## TCS Ninja Programming MCQ Questions with Answers

Here are the TCS Ninja Programming MCQ Questions and answers that were asked in the previous recruitment tests.

TCS Ninja programming MCQ questions – Programming Logic #1.

There are two integer numbers X and Y that are between 0 to 25. The user stores the value under a 5-bit number. How many minimum bits are required to store the result of the below expression?

Res=3*(X-Y)

A.8

B.5

C.7

D.8

Explanation: If we perform X-Y the possible answers shall be from -75 to 75. In order to store this, we need 8 bits.

TCS Ninja programming MCQ questions – Programming Logic #2.

Find Prefix and suffix for the below infix problem statement :

Infix Expression : 11 +20/5*(20-15)^6^5

A. Prefix Expression: 11 20 15 20 5 – ^^*6 5/+

Postfix Expression: +20/11*5-20^^15 6 5

B. Prefix Expression: 11 20 5 20 15-6 5^^*/+

Postfix Expression: +11/20 *5^^ -20 15 6 5

C. Prefix Expression: 11 20 5 20 15 – ^^^/+6 5

Postfix Expression: +11/^^-20*5 20 15 6 5

D. Prefix Expression: +11/20*5^^-20 15 6 5

Postfix Expression : 11 20 5 20 15 -6 5^^/+

Explanation: Provided the Infix expression the equivalent prefix expression is +11/20*5^^-20 15 6 5 and equivalent postfix expression is 11 20 5 20 15 -6 5^^/+.

TCS Ninja programming MCQ questions – Programming Logic #3.

Write the name of a library of functions that is used to perform arithmetic operations on BigInteger and BigDecimal.

Explanation: java.math consists of all the required functions related to BigInteger and BigDecimal.

TCS Ninja programming MCQ questions – Programming Logic #4.

Consider the following tree. What will be the preorder traversal?

A. D H E B I F G C A

B. D H E B A F I G C

C. A B D E H C F I G

D. H I D E F G B C A

Explanation: In preorder traversal, we have to visit the root first and then left, and finally right.

TCS Ninja programming MCQ questions – Programming Logic #5

Which argument is passed to fflush()?

A.no parameters

B.stdin

C.stdout

D.stderr

Explanation: In order to clear the input stream buffer we have to pass stdin to flush.

TCS Ninja programming MCQ questions – Programming Logic #6.

What is the name of the method that examines a particular data entity and determines what data elements need to be associated?

A. Entity-relationship diagram

B. Logic Data modeling

C. Customer Entities

D. Functional Primitive

Explanation: An ER diagram shows the relationship among entity sets. An entity set is a group of similar entities and these entities can have attributes. In terms of DBMS, an entity is a table or attribute of a table in the database, so by showing the relationship among tables and their attributes, ER diagram shows the complete logical structure of a database.

TCS Ninja programming MCQ questions – Programming Logic #7.

What will be the output of the below code?

```public class Main{
static int num=30;
static class Inner{
void msg()
{
System.out.Println(‘Num: num++);}
}
public static void main(string args[])
{
Main.Inner tw=new Main.Inner();
tw.msg()
}
}
```

Explanation: We are creating the object for the class Inner that is present inside the class Main. num is initialized to 30 and it is static. When the function msg() invokes it will print the value as 30 and then it will be updated as 31 since it uses a post-increment operator.

TCS Ninja programming MCQ questions – Programming Logic #8.

We cannot overload ______ operator.

A. : :

B. []

C. ()

D. +

Explanation: Scope resolution operator(::) helps us in accessing the global variable, accessing function outside the class, access the namespace and so on. This operator can never be overloaded.

TCS Ninja programming MCQ questions – Programming Logic #9.

Which data structure is used to convert an expression from one form to another form?

A. Graph

B. Stack

D. Queue

Explanation: In order to convert an Infix expression to postfix or vice versa we need to use a stack for the same.

TCS Ninja programming MCQ questions – Programming Logic #10.

Which of the following options best suits for ‘Memory Leak Occurred’

A. Resource allocation pending while debugging the code

B. Program releases resources allocated in the memory

C. Program does not free the memory which is allocated dynamically

D. Occurs due to address assignment failure.

Explanation: Whenever we are allocating memory dynamically we have to delete the memory before the execution of the program completes else a memory leak will happen. If a program has memory leaks, then its memory usage is satirically increasing since all systems have a limited amount of memory and memory is costly. Hence it will create problems.

TCS Ninja programming MCQ questions – Programming Logic #11.

Select the best suitable answer for the below functions.

sizeof()

strlen

A. sizeof() – Returns size of string including null characters

strlen() – Returns size of string excluding null characters

B. sizeof() – Returns size of string including null characters

strlen() – Returns size of string including null characters

C. sizeof() – Returns size of string excluding null characters

strlen() – Returns size of string excluding null, characters

D. sizeof() – Returns size of string excluding null characters

strlen() – Returns size of string including null characters

Explanation: sizeof() always gives the total size of any datatype allocated by the compiler. Where the strlen() gives the length of the string i.e number of characters in a string.

TCS Ninja programming MCQ questions – Programming Logic #12.

In a Singly Circular Linked List, how many address fields are there?

A. 1+1

B. 2+1

C. 1

D. 2

Explanation: Always a singly linked list will have a data field and an address field. The last node of the linked list will be pointing the head if it is a circular linked list else it will be pointing to null.

TCS Ninja programming MCQ questions – Programming Logic #13.

The primary mission of an analyst or systems designer is to:

A. calculate the Return on Investment

B. development of Software Evaluation Tool

C. create a Data Flow Diagram

D. extract the physical requirements of the users and convert them to software

Explanation: System designers are intended to create software based on the requirements of their clients. They need to extract the physical requirements of the users and convert them to software.

TCS Ninja programming MCQ questions – Programming Logic #14.

_______ is a process to identify the key aspects of an entity and hiding the rest.

A. Encapsulation

B. Inheritance

C. Abstraction

D. Polymorphism

Explanation: Abstraction is hiding the implementation and showing the functionality alone. Whereas Encapsulation binds the variables data and code acting o data to one single unit.

TCS Ninja programming MCQ questions – Programming Logic #15.

Which one is not a type of topology?

A. Star-topology

B. Circuit-topology

C. Ring-topology

D. Bus-topology

Explanation: A Network Topology is the arrangement with which computer systems or network devices are connected to each other. We have Star-topology, Ring-topology, Bus-topology, Mesh-topology, Tree-topology, etc.

TCS Ninja programming MCQ questions – Programming Logic #16.

The statement printf (“%d, 25 ? 5 ? 0 : 5 : 25); will print

A. 5

B. Compile-time error

C. 0

D. 25

Explanation: The statement that was used is nothing but a ternary or conditional operator.

TCS Ninja programming MCQ questions – Programming Logic #17.

Integer m=10, n= 35, p=5, d=6

Comment about the output of the given two statements

Print m*n + p/d

Print p/d + m*n

A. Differ by 10

B. Same

C. Differ by 20

D. Differ due to left and right precedence

Explanation:

m*n + p/d = 10*35 + 5/6 = 350 + 0 = 350

p/d + m*n = 5/6 + 10*35 = 0 + 350 = 350

Both gives the same answer

TCS Ninja programming MCQ questions – Programming Logic #18.

When we implement stack by using linked list then:

A. Insertion of the node is done from the end and deletion from the end

B. Insertion of the node is done from beginning and deletion from end

C. Insertion of the node is done from beginning and deletion from beginning

D. Insertion of the node is done from end and deletion from beginning

Explanation: Whenever you are implementing a stack using Linked list both insertion and deletion should happen at the same end. Here both A and C are correct. But in stack always we will deal the data in the top i.e beginning hence option c is the best answer.

TCS Ninja programming MCQ questions – Programming Logic #19.

Match the following:

A. A-5, B-2, C-4, D-3

B. A-2, B-5, C-4, D-3

C. A-5, B-2, C-1, D-6

D. A-2, B-6, C-1, D-3

Answer: None of the mentioned options is correct. The correct answer is

A – 5, B – 2, C – 1, D – 3

TCS Ninja programming MCQ questions – Programming Logic #20.

The kind of software testing you can do when you have both the source code and the executable code in hand, is called as?

A. Red Box Testing

B. Black Box Testing

C. White Box Testing

D. Blue Box Testing