Programing Logic
Question 1
Answer
Question 1
Q1. Which argument is passed to fflush()?
A.no parameters
B.stdin
C.stdout
D.stderr
Answer
Option B
TCS NQT MOCK TEST / PRACTICE SET
Click Here!
//Q2.
public Class Main
{
public static void main(string[])
{
int x=1/2;
if(x==0.5)
System.out.println(x+1);
else
System.out.println(x*2);
}
}
Question 2
Answer
Question 2
Q2. What will be the output for the below? Enter your answer only as Numeral
Answer
Answer: 0
Question 3
Answer
Question 3
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
//Q4.
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()
}
}
Question 4
Answer
Question 4
Q4. What will be the output of the below code?
Answer
30
Question 5
Answer
Question 5
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
//Q6.
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
class MainClass
{
public void sort()
{
ArrayList<String> arrayList= new ArrayList<String>();
arrayList.add("mango");
arrayList.add("grapes");
Iterator iterator = arrayList.iterator();
while(iterator.hasNext())
{
System.out.print(iterator.next() +" ");
}
Collections.sort(arrayList);
}
}
public class Main
{
public static void main(String[] args)
{
MainClass mainclass = new MainClass();
mainclass.sort();
}
}
Question 6
Answer
Question 6
Q6. What will be the output of the below code?
A. mango grapes
B. Compilation error
C. Collection.sort() throws Concurrent Modification Exception
D. Grapes mango
Answer
Option A
Question 7
Answer
Question 7
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
Question 8
Answer
Question 8
Q8. We cannot overload ______ operator.
A. : :
B. []
C. ()
D. +
Answer
Option A
TCS NQT MOCK TEST / PRACTICE AET
Click Here!
Question 9
Answer
Question 9
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
Question 9
Answer
Question 9
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
Question 10
Answer
Question 10
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
Question 11
Answer
Question 11
Q11.What is the mathematical function used to round off 6.23 to 7?
A. floor(6.23)
B. ceil(6.23,7)
C. floor(6.23,7)
D. ceil(6.23)
Answer
Option D
Question 12
Answer
Question 12
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
Question 13
Answer
Question 13
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