Programming Logic
public class main {
{
int $ = 5;
}
}
Question 1
Answer
Explanation
Question 1
What will be the output?
A. Nothing will print
B. Symbol not found error
C. Runtime error
D. Compile error
Answer
A. Nothing will print
Explanation
$ is a valid variable name
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);
}
Question 2
Answer
Explanation
Question 2
What will be printed if the above sample code is executed? Enter your answer only as a NUMERAl
Answer
-101233
Explanation
j loop will for run for only j=0 everytime. For i=0 it will print ‘-1’, then for i=1 it will print ‘0’ and so on.
In this way it will print -10123 then the print statement outside main function will be executed.
So final output = -101233
Question 3
Answer
Question 3
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 them down. 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
D. Topological Sorting
Question 4
Answer
Question 4
There are two integer numbers X and Y that are between 0 to 25. 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
Answer
D.8
Question 5
Answer
Question 5
Which among the following is a server – based paradigm?
A.Request for information
B.Cloud computing
C.Total Cost of Ownership
D. Data Validation Routine
Answer
B. Cloud computing
Also Checkout: TCS NQT Sample Question Paper
Question 6
Answer
Question 6
Write the name of a library of functions which is used to perform arithmetic operations on BigInteger and BigDecimal.
Answer
import java.math.*;
Question 7
Answer
Question 7
When we declare constant pointer to integer, we CANNOT change:
A. address in pointer variable
B. changes are not permitted
C. either address in pointer variable or value at that address
D. Value pointed by the pointer
Answer
B. changes are not permitted
Question 8
Answer
Question 8
Which among the following is a server-based paradigm?
A. Request for Information(RFI)
B. Cloud Computing
C. Total Cost Of Ownership(TCO)
D. Data Validation Routine
Answer
B. Cloud Computing
Question 9
Answer
Question 9
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^^/+
Answer
Prefix Expression: +11/20*5^^-20 15 6 5
Postfix Expression : 11 20 5 20 15 -6 5^^/+
Also Checkout