TCS Programming MCQ Questions And Answers - TCS
TCS Technical MCQ Questions: This section focuses on "Technical Questions" of TCS Exam. These programming MCQs are asked in previous TCS NQT Exams and will help you to prepare for upcoming TCS NQT exam.
1. A data type is stored as a 6 bit signed integer. Which of the following cannot be represented by this data type?
A. -12
B. 5
C. 25
D. 32
View Answer
Ans : D
Explanation: 2^6 = 64. So you can represent 64 values. This means 0 to 63 for unsigned integer and -32 to 31 for signed integer (twos complement).
2. What is the difference between a function and a method?
A. Function is a named code unlike method which is a part of an object
B. Function cannot change variables outside its scope unlike method
C. There is no difference between the two
D. Function contained in an object is called a method
View Answer
Ans : A
Explanation: A function is a piece of code that is called by name. It can be passed data to operate on and can optionally return data. All data that is passed to a function is explicitly passed.
3. What will be output for the following code?
int main()
{
int a=5,b=7
switch(a)
{
case 5 :printf(""I am 5"");
break
case 7: printf(""I am not 5"");
break;
default:printf(""I am different"");
}
return 0;
}
A. I am 5
B. I am not 5
C. I am different
D. Error
View Answer
Ans : D
Explanation: This program will generate an error as the break statement does not end with an semi-colon in case 5.
4. The value of EOF is _____
A. 0
B. -1
C. 1
D. infinite
View Answer
Ans : B
Explanation: The value of EOF = -1;
5. An array is also known as ___________ ?
A. Subscripted variable
B. Ordinary variable
C. Similar Quantities variable
D. Collective array
View Answer
Ans : A
Explanation: All elements refer to the same name.That is each element can be identified with the same name including different index value(subscript value). Hence,an array is also called as a Subscripted variable.
6. What is the output of this C code?
#include
void main()
{
static int i;
printf(""i is %d"", i);
}
A. Zero
B. 1
C. Garbage Value
D. Runtime Error
View Answer
Ans : A
Explanation: Since i is declared as static variable and the default value is zero for static variables.
7. Which of this is used to skip one iteration?
A. break
B. goto
C. continue
D. return
View Answer
Ans : C
Explanation: Continue is used to skip current block of statements for one iteration and to jump to the beginning of the loop for condition checking so that it can begin next iteration. Break however is to exit from the loop and directly go to the end of the loop.
8. Which has the highest precision?
A. float
B. unsigned long int
C. double
D. long int
View Answer
Ans : C
Explanation: double has the highest precision.
9. How can we insert different type of data in the stack.
A. Not possible
B. By implementing union
C. Structure data type
D. Both B and C
View Answer
Ans : D
Explanation: Union and structure are the special data type that allows to store different data types in the same memory
10. Which of the following is not a valid type of polymorphism ?
A. imperative polymorphism
B. adhoc polymorphism
C. predicative polymorphism
D. inclusion polymorphism
View Answer
Ans : A
Explanation: Imperative polymorphism is not an valid type of polymorphism.
11. Tricha wants to store a list of binary data.Which of following data types should she use?
A. Boolean
B. Integer
C. Character
D. Floating
View Answer
Ans : A
Explanation: As boolean can store only two values(i.e, 1 and 0), so tricha can store a list of binary data in boolean datatype.
12. Which of the following accessibility modes can be the specifier of a top level class’ ?
A. only private
B. protected and private
C. public and no modifier
D. only no modifer
View Answer
Ans : C
Explanation: Top-level classes can only have public, abstract, and final modifiers, and it is also possible to not define any class modifiers at all. This is called default/package accessibility. Besides that, private, protected, and static modifiers cannot be used when declaring top-level classes.
13. Recursion is similar to which of the following?
A. Switch Case
B. Loop
C. If-else
D. None
View Answer
Ans : B
Explanation: In recursion, the function will call itself until the base condition is not true. So, Recursion is similar to a loop and it will call itself until the base condition is not true.
14. A mode which is used to open an existing file for both reading and writing ______
A. "W"
B. "W+"
C. "R+"
D. "A+"
View Answer
Ans : C
Explanation: R+ mode is used to open an existing fiel for both reading and writing.
15. An array is also known as ___________ ?
A. Subscripted variable
B. Collective array
C. Ordinary variable
D. Similar Quantites variable
View Answer
Ans : A
Explanation: All elements refer to the same name.That is each element can be identified with the same name including different index value(subscript value). Hence,an array is also called as a Subscripted variable.
16. The scope of an automatic variable is:
A. Within the block it appears
B. Within the blocks of the block it appears
C. Until the end of program
D. Within the block it appears & Within the blocks of the block it appears.
View Answer
Ans : D
Explanation: Within the block, it appear and Within the blocks of the block it appears.
17. The following code ‘for(;;)’ represents an infinite loop. It can be terminated by.
A. break
B. exit(0)
C. abort()
D. all of the mentioned
View Answer
Ans : A
Explanation: If we write the break statement inside the infinite loop it will terminate the infinite loop.
18. What argv means in command line argument ?
A. Array of pointers
B. pointer to a character array
C. Array of character pointers
D. Array of Strings
View Answer
Ans : C
Explanation: argv(Argument Vector) is array of character pointers listing all the arguments. If argc is greater than zero,the array elements from argv[0] to argv[argc-1] will contain pointers to strings. Argv[0] is the name of the program , After that till argv[argc-1] every element is command -line arguments.
19. How can a call to an overloaded function be ambiguous ?
A. By misspelling the name
B. There might be two or more functions with the same name
C. There might be two or more functions with equally appropriate signatures
D. None of these
View Answer
Ans : B
Explanation: The call to an overloaded function can be ambiguous if the two or more functions have the same name and same function signature.
20. What type of method is used to place a method onto the top of the Stack.
A. pop()
B. push()
C. Evaluation()
D. Create()
View Answer
Ans : B
Explanation: when we want to add or place something in the stack so we need to perform push() operation.
Discussion