DXC Technology Computer Programming Questions

30 April 2024

 

Q1) Tower of Hanoi is an application of--------

A. Stacks

B. Linked Lists

C. Queue

D. Dequeues
 
Answer : Option A

Explanation: Stack concept is used in towers of hanoi

 

Q2) Deadlocks can be described more precisely in terms of a directed graph called a system resource allocation graph, What can be conduced in the two statements stated below are true for a system.

1. The graph contains a cycle.

2. The cycle involves only a set of resource types each of which has only a single instance.

A. A deadlock will occur

B. A deadlock will never occur

C. The statement contradicts each other

D. A deadlock may exist
 
Answer : Option D

Explanation:

All deadlocks involve conflicting resource needs by two or more processes. Here graph contains cycle which involves only a set of resource types each of which has only a single instance. Then here deadlock might occur.

 

Q3) Yukta created an interface to use it in different parts of the program by implementing it. But she forgot to specify the access specified for each contained method. What will be the access specified of the methods that will be inherited/implemented?

A. Protected 

B. Public

C. Private 

D. An error will be generated 
 
Answer : Option B

Explanation: If public access specifier is used for a method it can be accessed in different parts of the program.

 

Q4) What is the value of 10101B in decimal number system?

A. 21

B. 42

C. 16

D. 20
 
Answer : Option A

Explanation: The binary equivalent of 21 is 10101.

 

Q5) Function main is the starting point of execution of a program. Which of the following options shall help in making an executable program without the use of main function in the program?

A. It is not possible to run a program without a main function in a program

B. Any program without a main function shall not do anything but can only produce a blank screen

C. Two macros can be used. One to hold the name of a function and its working and the other to call the first macro

D. Any function can be made and marked as starting point using a language dependent syntax
 
Answer : Option B

Explanation: A program without main function will not do anything, it will only produce a blank screen. Execution of program starts from the main function.

 

Q6) How many nodes does a full binary tree with “n” leaves contain?

A. 2n+1 nodes

B. log2n nodes

C. 2n—1 nodes

D. 2n nodes

Answer : Option C

Explanation: Full binary tree with n leaves contain 2n – 1 nodes.

 

Q7) Which members of a class cannot be inherited?

A. Public

B. Private

C. Private and Protected

D. Protected

Answer : Option B

Explanation: A subclass does not inherit the private members of its parent class

 

Q8) A librarian has to rearrange the library books on  a shelf in a proper order at the end of each day. Which sorting technique should be the librarian’s ideal choice?

A.Bubble sort

B.Insertion sort

C.Selection sort

D.Heap sort

Answer : Option B

Explanation: In insertion sort values from the unsorted part are picked and placed at the correct position in the sorted part. So it is the best way for a librarian.

 

Q9) A programmer tries to debug a code of 10,000 lines. It is known  that there is a logical error in the first 25 lines of the code.

 What is the efficient way to debug the code?

A. Compile the entire code and check it line by line

B. Use an interpreter on the first 25 lines of code

C. Compile the entire code and run it

D. None of the above can be used to debug  the code

Answer : Option B

Explanation: Here it is mentioned that there is a logical error in the first 25 lines of code. So the best way to debug the code is to use an interpreter on the first 25 lines.

 

Q10) What is the output of the pseudocode statements given below?

(Note: Assume that when two data types are processed through an operator, the answer maintains the same data type as that of the input. Also, all data types have enough range to accommodate any number. If two different data types are operated upon, the result assumes the data type that is more expressive.)

integer a = 984, b=10

//float is a data type to store real numbers.

float c

c = a/b

print c

A.984

B.98.4

C.98

D.Error

Answer : Option C

Explanation: Here a and b are integers, so when 984/10 is done only 98 will be stored in variable c which is float(actually it is 98.000000). So answer is 98.

 

Q11) A language has 28 different letters in total. Each word in the language consists of a maximum of 7 letters. A programmer wants to create a data type to store a word of this language. She decides to store the word as an array of letters. How many bits should she assign to the data type to store all kinds of words of the language?

A.7

B.35

C.28

D.196

Answer : Option B

Explanation: In binary, there are only two possibilities- zero and one. 
Thus, looking at the powers of 2, we realize that 32 is the closest exponential result of 2 to 28, where 2^5 = 32.
Hence, to cover all the possibilities, we need 5 bits at the least.
But there are seven letters. Thus, the number of bits we require is 7 * 5 = 35 bits 

 

Q12) X and Y are asked to write a program to sum the rows of a 2X2 matrix stored in an array A.

X writes the code (Code A) as follows:

for n= 0 to 1

sumRow1[n]=A[n][0]+A[n][1]

end

Y writes the code (Code B) as follows:

sumRow1[0] =A[0][0] + A[0][1]

sumRow1[1] =A[1][0] + A[1][1]

Which of the following statements is correct about these codes if no loop unrolling is done by the compiler?

A.Code A would execute faster the Code B

B.Code B would execute faster than Code A

C.Code B is logically incorrect

D.Code A is logically incorrect

Answer : Option B

Explanation: A technique for transforming loops called "loop unrolling" aids in streamlining a program's execution time. Iterations are essentially eliminated or decreased. When a loop is unrolled, loop control and loop test instructions are removed, which speeds up the programme. In Code B the number of overhead Looping is more than Code A. So code B will be faster than code A.

 

Q13) For Which of the given options is the stack implementation useful?

A.Radix search

B.Breath first search

C.Recursion

D.None of the above

Answer : Option C

Explanation: For executing recursion we stack implementation is useful.



FAQ

Any Questions?
Look Here.

Related Articles

Accenture Abstract Reasoning Previous Year Questions

Accenture Critical Reasoning and Problem Solving Questions

Accenture English Ability Previous Year Questions

Accenture MS Office Questions

Accenture Network Security & Cloud Computing Questions

Accenture Pseudocode Questions

Capgemini Game Based Aptitude Previous Year Questions

Capgemini Technical MCQ's Previous Year Questions

Cisco Aptitude Previous Year Questions

Cognizant Gen C Quantitative Ability Previous Year Questions

Dell Quantitative Aptitude Previous Year Questions

Dell Verbal Ability Previous Year Questions

Deloitte Quantitative Aptitude Previous Year Questions

DXC Technology Automata Fix Questions

DXC Technology Logical Ability Questions

DXC Technology Quantitative Ability Previous Year Questions

DXC Technology Verbal Ability Questions

Goldman Sachs Numerical Computation Previous Year Questions

Hexaware Logical Ability Previous Year Questions

Hexaware Numerical Ability Previous Year Questions

Hexaware Verbal Ability Previous Year Questions

Infosys Mathematical Ability Previous Year Questions

Infosys Pseudocode Questions

Infosys Puzzle Solving Previous Year Questions

Infosys Reasoning Ability Previous Year Questions

Infosys SP DSE Previous Year Questions

Infosys Verbal Ability Previous Year Questions

InfyTQ DBMS Questions

InfyTQ Java Questions

LTI Logical Reasoning Previous Year Questions

LTI Quantitative Ability Previous Year Questions

LTI Verbal Ability Previous Year Questions

Mindtree Previous Year Questions

TCS NQT Numerical Ability Questions

TCS NQT Previous Year Coding Questions

TCS NQT Verbal Ability Questions

Tech Mahindra Logical Ability Previous Year Questions

Tech Mahindra Quantitative Ability Previous Year Questions

Top 14 Capgemini Pseudocode Questions

Top 15 LTI Coding Questions

Top 15 TCS NQT Reasoning Questions

Wipro Logical Ability Questions

Wipro Quantitative Ability Previous Year Questions

Wipro Verbal Ability Questions