Professional Documents
Culture Documents
TCS TECHNICAL MCQ'S (2020-21) : Programming Logic
TCS TECHNICAL MCQ'S (2020-21) : Programming Logic
TCS TECHNICAL MCQ'S (2020-21) : Programming Logic
Programming Logic:
Answer: Option B
Q2. What will be the output for the below? Enter your answer only as Numeral
Answer: 0
Q3. 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
Answer: Option A
Answer: 30
Q5. Select the correct code for opening a file for writing in binary mode
A. File*f =fwriteb(“abc.bin”)
B. File*f = fopen(“abc.bin”,”bw”)
C. File*f = fopen(“abc.bin”,”wb”)
D. File*f =fwrite(“abc.bin”,”b”)
Answer: Option C
Answer: Option A
Q7. What is the name of the method that examines a particular data entity and determines
what data elements need to be associated with it?
A. Customer Entities
B. Entity Relationship Diagram
C. Logic Data Modelling
D. Functional Primitive
Answer: Option B
Answer: Option A
Q9. Which of the following functions is used to accept strings with white spaces?
A.getWhiteSpaceString();
B.scanf();
C.gets();
D.getstrings();
Answer: Option C
Q10.Which data structure is used to convert expression from one form to another form?
A. Graph
B. Stack
C. LinkedList
D. Queue
Answer: Option B
A. floor(6.23)
B. ceil(6.23,7)
C. floor(6.23,7)
D. ceil(6.23)
Answer: Option D
Q12. Which combination of the integer variables a, b and c makes the variable m get the value
4 in the following expression?
m = (a > b) ? (( a > c ) ? a : c) : ((b > c ) ? b : c )
A. a=6, b=3, c=5
B. a=6, b=5, c=3
C. a=5, b=4, c=5
D. a=3, b=4, c=2
Answer: Option D
Q13. 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.
Answer- Option C
Programming Logic
Q1..Given here is a scenario. Consider the graph algorithm and answer the given question.
John wants to go to different locations of the city in which he is. He has listed all of
themdown.However he wants to visit one location before visiting some other location
What application of graphs he uses to determine that location?
A. DFS
B. Dijkstra’s
C. BFS
D. Topological Sorting
Answer: Option D
int $ = 5;
}
}
Answer: Option A
Q3. What will be printed if the below sample code is executed? Enter your answer only as
aNUMERAl
class main
{
public static void main(string args[]}
{
int i,j,x=0;
for(i=0;i<5;i++)
for(j=0;j<5;j++){
x=(i+j-1);
System.out.print(x)
;break;
}
}
System.out.print(x);
}
Answer: -101233
Q5. There are two integer numbers X and Y that are between 0 to 25. User stores the
valueunder 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
Answer: Option D
Explanation: If we perform X-Y the possible answers shall be from -75 to 75. In order to
storethis we need 8 bits.
Q6. Find Prefix and suffix for the below infix problem statement :
Answer: Option D
Q7. Write the name of a library of functions which is used to perform arithmetic operations
onBigInteger and BigDecimal.
Answer: Option B
Answer: Option B
Programming Logic
Q1. The primary mission of an analyst or systems designer is to
A. Extract the physical requirements of the user and convert them to the software
B. Calculate the return on investment
C. Create a data flow diagram
D. Development of software evaluation tool
Answer: Option A
Answer: Option C
Q3. When we execute the given code what will be the value of x and y?
Q4. What will be the return value of fseek() function if error occurs?
Answer: Option A
Answer: 1-1
A. Differ by 10
B. Same
C. Differ by 20
D. Differ due to left and right precedence
Answer: Option B
Q7. Which of the following is incorrect syntax for function declaration with default argument?
Answer: Option B
Answer: Option C
Q9. What will be the output of the below code?
Answer: Option B
A ceil(3.6) 1 32.000000
B floor(3.6) 2 3.000000
C pow(2, 5) 3 12.000000
D abs(-12) 4 25.000000
5 4.000000
6 0.000000
Answer: Option A
Answer: Option D
Q3. Which of the following is NOT a logical operator?
A. !
B. &&
C. ||
D. &
Answer: Option D
Q4. In a Singly Circular Linked List, how many address fields are there?
A. 1+1
B. 2+1
C. 1
D. 2
Answer: Option C
Answer: Option D
Q7. When we compose a binary tree through the given preorder sequence, what will be left
child of 6? (Note: Consider 4 as root node)
4, 2, 1, 3, 6, 5, 7
A. 1
B. 5
C. 7
D. 3
Answer: Option B
Q8. What will be the output of the following program?
Q9. Based on below infix and postfix expressions, identify the Prefix expression.
Infix expression: P-Q-(R+S)/(W-X)*Y+Z
Postfix Expression: PQRS+*WX-Y*/Z+
A. -P/*Q+RS+*-WXYZ
B. -P/*Q+RS+*W-XYZ
C. P-/*Q+R+S*WXYZ-
D. P-/*+RS+Q*-WXYZ-
Answer: Option A
Programming Logic
Q1. What will be the output of the following program?
Q2. function is used to show a key pressed by a user will appear on the screen.
A. getche()
B. getsf()
C. gfets()
D. getch()
Answer: Option A
Answer: Option A
Both A and B can be correct. If insertion and deletion happens at the same end it is stack and if
it happens at different ends it is Queue. Here the best among A and B is Option A
Q4. 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
Answer: Option D
Q5. is a process to identify the key aspects of an entity and hiding the rest.
A. Encapsulation
B. Inheritance
C. Abstraction
D. Polymorphism
Answer: Option C
Answer: Option B
Answer: Option B
Q8. Assume: Linked list as head -> 2 -> 4 -> 6 -> 8
Answer: Option C
Q9. Predict the output.
A. No output
B. 20
C. 0
D. Compilation Error
Answer: Option A
Q10. What would be the Time Complexity of below Code? Type your answer:
Answer:
O(count)
Programming Logic
Q1. What will be the output of the following program?
Q2. function is used to show a key pressed by a user will appear on the screen.
A. getche()
B. getsf()
C. gfets()
D. getch()
Answer: Option A
Answer: Option A
Both A and B can be correct. If insertion and deletion happens at the same end it is stack and if
it happens at different ends it is Queue. Here the best among A and B is Option A
Answer: Option D
Q5. is a process to identify the key aspects of an entity and hiding the rest.
A. Encapsulation
B. Inheritance
C. Abstraction
D. Polymorphism
Answer: Option C
Answer: Option B
Answer: Option B
Q8. Assume: Linked list as head -> 2 -> 4 -> 6 -> 8
Answer: Option C
Q9. Predict the output.
A. No output
B. 20
C. 0
D. Compilation Error
Answer: Option A
Q10. What would be the Time Complexity of below Code? Type your answer:
Answer:
O(count)
Programming Logic
Q1. What will be the output of the following program?
Q2. function is used to show a key pressed by a user will appear on the screen.
A. getche()
B. getsf()
C. gfets()
D. getch()
Answer: Option A
Answer: Option A
Both A and B can be correct. If insertion and deletion happens at the same end it is stack and if
it happens at different ends it is Queue. Here the best among A and B is Option A
Answer: Option D
Q5. is a process to identify the key aspects of an entity and hiding the rest.
A. Encapsulation
B. Inheritance
C. Abstraction
D. Polymorphism
Answer: Option C
Answer: Option B
Answer: Option B
Q8. Assume: Linked list as head -> 2 -> 4 -> 6 -> 8
Answer: Option C
Q9. Predict the output.
A. No output
B. 20
C. 0
D. Compilation Error
Answer: Option A
Q10. What would be the Time Complexity of below Code? Type your answer:
Answer:
O(count)
Programming Logic
Q1. What will be the output of the following program?
Q2. function is used to show a key pressed by a user will appear on the screen.
A. getche()
B. getsf()
C. gfets()
D. getch()
Answer: Option A
Answer: Option A
Both A and B can be correct. If insertion and deletion happens at the same end it is stack and if
it happens at different ends it is Queue. Here the best among A and B is Option A
Answer: Option D
Q5. is a process to identify the key aspects of an entity and hiding the rest.
A. Encapsulation
B. Inheritance
C. Abstraction
D. Polymorphism
Answer: Option C
Answer: Option B
Q7. Which one is not a type of topology?
A. Star-topology
B. Circuit-topology
C. Ring-topology
D. Bus-topology
Answer: Option B
Answer: Option C
Q9. Predict the output.
A. No output
B. 20
C. 0
D. Compilation Error
Answer: Option A
Q10. What would be the Time Complexity of below Code? Type your answer:
Answer:
O(count)
Programming Logic
Q2. Construct post order Transversal for the constructed tree with the given In-Order and
Preorder Traversals:
In-Order: 9 7 10 6 8
Pre-Order: 6 7 9 10 8
A. 9 10 7 8 6
B. 9 7 6 10 8
C. 8 9 10 7 6
D. 9 8 10 7 6
Answer: Option A
Q3. What will be the output of the following program?
Answer: 8-0-2
Float num1;
Short num2;
Long num3;
Answer: Option B
Q5. The kind of software testing you can do when you have both the source code and the
executable code in hand, is called as?
Answer: Option C
Expression 1: cout<<endl;
Expression 1: cout<<”\n”<<flush;
Answer: Option C
Q7. Spot the error in the given code. If there is no error, select the most appropriate option
A. Error at line 9
B. Error at line 8
C. Employee User Id:12
D. Compilation error
Answer: Option C
Here, p is
Answer: Option C
Answer: Option D
Q10. What will be the output of the following program?
Answer: Option C.
Programming Logic
Q2. Construct post order Transversal for the constructed tree with the given In-Order and
Preorder Traversals:
In-Order: 9 7 10 6 8
Pre-Order: 6 7 9 10 8
A. 9 10 7 8 6
B. 9 7 6 10 8
C. 8 9 10 7 6
D. 9 8 10 7 6
Answer: Option A
Q3. What will be the output of the following program?
Answer: 8-0-2
Float num1;
Short num2;
Long num3;
Answer: Option B
Q5. The kind of software testing you can do when you have both the source code and the
executable code in hand, is called as?
Answer: Option C
Expression 1: cout<<endl;
Expression 1: cout<<”\n”<<flush;
Answer: Option C
Q7. Spot the error in the given code. If there is no error, select the most appropriate option
A. Error at line 9
B. Error at line 8
C. Employee User Id:12
D. Compilation error
Answer: Option C
Q8. float (*p)[5]
Here, p is
Answer: Option C
Answer: Option D
Q10. What will be the output of the following program?
A. Run time error
B. Triangle
C. Compile Time error
D. It’s Rectangle
Answer: Option C.
Programming Logic
Answer: False
Q2. What is the name of the approach by development of a system by means of a series of
iterations to incorporate mid term changes until the system tests all the business requirements.
A. Prototyping
B. Normalization
C. Smoke test
D. Tracking
Answer: Option D
Q3. Suppose there is a stack of size 7. In that stack we push first 3 even numbers from the range
of 1 to 10 in ascending order. Then we perform two pop operations then we push first 3 odd
numbers from the range 11 to 20 in ascending order, then what will be the top element into
the stack?
A. 13
B. 2
C. 15
D. 6
Answer: Option C
Q4. In the given program, if the sum value is initialized with 0 value before starting the loop,
find the aggregate value of sum after completion of loop statements.
A. 15
B. 16
C. 17
D. 18
Answer: Option B
Q5. Which of the following combinations forms the correct example combo for Greedy and
Divide & Conquer Algorithms?
A.
Greedy Divide and Conquer
B.
Greedy Divide and Conquer
● Strassen’s Matrix ● Closest Pair (or Points)
● Multiplication, Knapsack Problem ● Traveling Salesman
● Job Scheduling Problem ● Binary Search
● Graph - Map Colouring
C.
Greedy Divide and Conquer
D.
Greedy Divide and Conquer
Answer: 1
Q7. What will be the prefix conversion of the following postfix expression?
A. *-I/JK/LMN
B. *I/JK-/LMN
C. *-I/JK/-LMN
D. *-IJK/-/LMN
Answer: Option A
Answer: Option D
Programming Logic
Q1. What would be the output of the below snippet?
Answer: 92
Q2. The Hashing Technique hash function takes a and returns the value of
that key in order to identify the index of an array.
A. Null, Hash
B. Hash, Key
C. Key, Null
D. Key, Hash
Answer: Option D
Q3. What will be the output of the following program?
Answer: Option A
Q5. What would be the output of the below code?
A. NULL
B. error : variable a wrongly initialized in the default constructor
C. error: incompatible types <null> cannot be converted to int
D. 0
Answer: Option C
Q6. Which of the below functions is used to convert double value 8.33 to 9?
A. ceil()
B. top()
C. fabs()
D. floor()
Answer: Option A
Q7. When we execute the given program what will it print?
Answer: Option A
Programming Logic
Q1.What would be the output of below code?
Answer: Option C
Answer: Option A
Q4. When the given code is executed, what will be the output that is printed?
Answer: 11
4 Graph
A. A-3, B-2
B. A-4, B-3
C. A-3, B-1
D. A-2, B-4
Answer: Option C
Answer: Option B
Answer: Option A
Q8. Write the output for the below code.
A. NullPointerException
B. Error in Main Method
C. Advanced Java
D. Java EE
Answer: Option C
Q9. A bus conductor has a bunch of coins, each coin has a different value. New coins
are addedat the end of the bunch. Only coins are issued to customers from the top
side of the bunch.
Developer X wants to implement this in application by the help of data structure.
Which datastructure is best suitable for implementation of current logic?
A. Queue
B. Graph
C. Stack
D. Tree
Answer: Option A
Q10. What is the full form of ROI in the context of Software development?
A. Return-on-investment
B. Rationality-of-internet
C. Reduction-of-investment
D. Rate-of-integration
Answer: Option A