DSSSB TGT / PGT · Topic-wise previous year questions
Computer Science Previous Year Questions (page 33)
2444 Computer Science questions asked in DSSSB TGT / PGT previous year papers, each with the correct answer and explanation. Read them free on UTpaper, or attempt the full papers as timed online tests.
Which of the following is NOT a benefit of using threads in an operating system?
AImproved application responsiveness
BIncreased system resource utilisation
CSimplified programming model
DFaster execution of tasks in single-core processors
Show answerHide answer
Correct answer: (D) Faster execution of tasks in single-core processors
Explanation
On a single-core CPU, threads only take turns (concurrency), so they do not make tasks run faster in parallel. They do improve responsiveness and resource use.
What is the advantage of using a sliding window over a stop-and-wait protocol?
ASliding window is simpler to implement.
BSliding window uses larger packet sizes.
CSliding window increases throughput by allowing multiple packets to be sent before
acknowledgment.
DSliding window requires no acknowledgments.
Show answerHide answer
Correct answer: (C) Sliding window increases throughput by allowing multiple packets to be sent before
acknowledgment.
Explanation
Stop-and-wait sends one frame and waits for its ACK. A sliding window allows several frames in flight before acknowledgment, which uses the link better and gives higher throughput.
In which scenario would the ReadConsole system call be used over ReadFile?
AWhen reading input from a network socket
BWhen reading from a database
CWhen reading from the console or terminal window
DWhen reading from a disk file
Show answerHide answer
Correct answer: (C) When reading from the console or terminal window
Explanation
In the Windows API, ReadConsole reads characters from the console input buffer (the terminal window). ReadFile is the general call for files, pipes and devices.
ENUM is a MySQL-specific type and is not in the SQL:1999 standard, which has DATE, BOOLEAN, CHAR and VARCHAR. Strictly, STRING is not a standard SQL type either.
TCP is full-duplex: once connected, data can flow in both directions at the same time. TCP is connection-oriented and stateful, and does not broadcast.
Consider the following statements.
P. The output of the four inputs AND gate is 1 when all the four inputs values are 1’s.
Q. The output of the four inputs AND gate is 0 when at least one input value is 0.
R. Three AND gates are used in the implement given three variable Boolean function F (A, B,
C) = AB +BC +AC using basic logic gates.
Which of the given statements are correct in a digital logic system?
AOnly P and Q
BP, Q, and R
COnly Q and R
DOnly P and R
Show answerHide answer
Correct answer: (B) P, Q, and R
Explanation
P and Q describe the AND gate correctly. For AB + BC + AC you need three AND gates (AB, BC, AC) plus OR gates, so R is also true.
Which of the following systems typically DO NOT use contiguous allocation?
ACD-ROM systems
BVideo streaming systems
CGeneral-purpose operating systems with dynamic file sizes
DReal-time systems
Show answerHide answer
Correct answer: (C) General-purpose operating systems with dynamic file sizes
Explanation
General-purpose OSs have files that grow and shrink, which causes external fragmentation with contiguous allocation. So they use linked or indexed allocation instead.
Contiguous allocation is most suitable for which type of systems?
ASystems with dynamic file sizes
BMulti-user systems with high I/O demands
CReal-time systems requiring fast access
DSystems with limited storage
Show answerHide answer
Correct answer: (C) Real-time systems requiring fast access
Explanation
Contiguous allocation stores a file in consecutive blocks, which gives fast sequential and direct access. This suits real-time systems, and also read-only media such as CD-ROMs.
What will be the output of the following code?
#include <stdio.h>
int main() {
int arr[] = {1, 2, 3, 4, 5};
printf("%d %d \n", arr[2], *(arr + 2));
return 0;
}
A3 3
B2 2
CCompilation Error
DUndefined Behavior
Show answerHide answer
Correct answer: (A) 3 3
Explanation
arr[2] and *(arr + 2) both mean the third element, 3, so "3 3" is printed.
What is the output of the following code? #include <stdio.h>
void func(int *p) {
int q = 10;
p = &q;
}
int main() {
int x = 20, *ptr = &x;
func(ptr);
printf("%d\n", *ptr);
return 0;
}
ACompile time error
B20
C10
DGarbage value
Show answerHide answer
Correct answer: (B) 20
Explanation
C passes the pointer by value, so p = &q changes only the local copy in func. ptr still points to x, and 20 is printed.
A company wants to develop a software tool that identifies duplicate entries in a large
database while ensuring scalability and accuracy. Which computational thinking steps should
be prioritised, and in what order, to achieve an efficient solution?
For this task the key's order is abstraction first: keep only the important features of an entry. Then decompose the task, recognise duplicate patterns, and finally design the algorithm.
When solving a Sudoku puzzle using computational thinking, which step is the most critical
for ensuring efficiency?
AProblem decomposition
BAbstraction
CBrute force approach
DPattern recognition
Show answerHide answer
Correct answer: (D) Pattern recognition
Explanation
Sudoku is solved efficiently by recognising patterns, such as which numbers are missing in rows, columns and boxes. This cuts down the possibilities far more than brute force.
Which among the following is the primary purpose of using interfaces in Java?
ATo avoid creating objects
BTo achieve multiple inheritance
CTo improve user experience
DTo reduce memory usage
Show answerHide answer
Correct answer: (B) To achieve multiple inheritance
Explanation
A Java class can extend only one class but can implement many interfaces. Interfaces are therefore Java's way of achieving multiple inheritance of type.
What will be the output of the following code?
class Test {
Test(int x) {
System.out.println("Parameterized Constructor");
}
Test() {
this(10);
System.out.println("Default Constructor");
}
public static void main(String[] args) {
Test obj = new Test();
}
}
AParameterized Constructor followed by Default Constructor
BCompilation Error
CDefault Constructor
DParameterized Constructor
Show answerHide answer
Correct answer: (A) Parameterized Constructor followed by Default Constructor
Explanation
new Test() calls the no-argument constructor. Its first statement, this(10), runs the parameterized constructor first, so "Parameterized Constructor" is printed and then "Default Constructor".
A 2D array can be initialised with a flat list when both sizes are given: {1,2,3,4} fills row by row. [2,2] is not C syntax, and only the first dimension may be left empty.
Given a 3-dimensional array C[3][4][5] stored in row-major order, with each element
occupying 1 byte, and the base address 3000, what is the address of C[2][3][4]?
A3057
B3059
C3124
D3171
Show answerHide answer
Correct answer: (B) 3059
Explanation
Offset = i × (4 × 5) + j × 5 + k = 2 × 20 + 3 × 5 + 4 = 59, so the address is 3000 + 59 = 3059.
Consider the following statements regarding digital logic systems and and select the correct
statements.
P. The output of the n inputs NAND gate is 0 when all the n inputs values are 1’s.
Q. The output of the n inputs NAND gate is 1 when all the n inputs values are 0’s.
R. The output of the n inputs NAND gate is 1 when all the n inputs values are 1’s.
S. Minimum three NAND gates are used to implement the given three variable Boolean
function F (A, B, C) = AB +BC using only NAND logic gates.
AOnly P, Q and S
BOnly P, R and S
CP, Q, R and S
DOnly P, Q and R
Show answerHide answer
Correct answer: (A) Only P, Q and S
Explanation
A NAND gate gives 0 only when all inputs are 1, so P and Q are true and R is false. AB + BC = ((AB)'·(BC)')' needs three NAND gates, so S is true.
Correct answer: (D) A base condition and a recursive call
Explanation
A recursive function needs a base condition to stop and a recursive call that moves toward that base case. Without a base case the recursion never ends.
What will be the output of the following code?
public class ExceptionDemo {
public static void main(String[] args) {
try {
int[] numbers = {1, 2, 3};
System.out.println(numbers[5]);
} catch (Exception e) {
System.out.println("Exception caught: " + e.getClass().getName());
} finally {
System.out.println("Execution completed.");
}
}
}
numbers[5] is past the end of the array, so an ArrayIndexOutOfBoundsException is thrown. getClass().getName() gives its full name, and finally always runs.
Suppose there are n elements in an array A[ ]. If we want to insert a new element at position i in array A[ ], 1 ≤ i ≤ n, causing elements numbered i, i+1, …, n to become numbered:
Ai−1, i, i+1, i+2, i+3, …, n+1
Bi+1, i+2, i+3, …, n+1
Ci−1, i+1, i+2, i+3, …, n+1
Di+2, i+3, …, n+1
Show answerHide answer
Correct answer: (B) i+1, i+2, i+3, …, n+1
Explanation
To insert at position i, elements i to n each move one place to the right, so they become i+1, i+2, ..., n+1.
If the recursive approach of linear search is used to search a key in a linked list of n elements, then what are the time and space complexity to search an element in a linked list?
ATime Complexity = O(n), Space Complexity = O(1)
BTime Complexity = O(1), Space Complexity = O(1)
CTime Complexity = O(1), Space Complexity = O(n)
DTime Complexity = O(n), Space Complexity = O(n)
Show answerHide answer
Correct answer: (D) Time Complexity = O(n), Space Complexity = O(n)
Explanation
Recursive search makes up to n calls, so the time is O(n). Each pending call uses a stack frame, so the space is also O(n).
What is the output of the following JavaScript code?
const obj = { name: "Alice" };
Object.defineProperty(obj, "age",
{
value: 25,
writable: false
});
obj.age = 30;
console.log(obj.age);
Aundefined
BError: Cannot modify property
C25
D30
Show answerHide answer
Correct answer: (C) 25
Explanation
writable: false makes the age property read-only. In non-strict mode, obj.age = 30 is silently ignored, so 25 is printed. Strict mode would throw a TypeError.
A sorting algorithm in which the two or more elements with equal key values appear in the
same order in sorted output as they appear in the input data set is known as a/an:
Ainternal sorting algorithm
Bexternal sorting algorithm
Cstable sorting algorithm
Dunstable sorting algorithm
Show answerHide answer
Correct answer: (C) stable sorting algorithm
Explanation
A stable sort keeps records with equal keys in their original relative order. Insertion sort and merge sort are stable.
Consider the pseudocode of the function given below.
abc(int n)
{
int i, j, k = 0;
for (i = n/2; i <= n; i++)
for (j = 2; j <= n; j = j * 2)
k = k + n/2;
return k;
}
what will the time complexity of the function abc() be?
AO(n²)
BO(n)
CO(n log n)
DO(log n)
Show answerHide answer
Correct answer: (C) O(n log n)
Explanation
The outer loop runs about n/2 times, and the inner loop doubles j, so it runs about log₂ n times. That gives O(n log n).
Which of the following is an advantage of the linked list over an array?
ALinked list takes less storage to store the n elements as compared to array.
BLinked list takes less time to access the ith element as compared to array.
CInserting an element at beginning of the linked list takes less time as compared to
array.
DInserting an element as last element of the linked list takes less time as compared to
array.
Show answerHide answer
Correct answer: (C) Inserting an element at beginning of the linked list takes less time as compared to
array.
Explanation
Inserting at the beginning of a linked list only changes the head pointer, which is O(1). An array must shift every element, which is O(n). Array access by index is faster.
Consider the expression given below:
x = a + b * (c − d) / e + f % g;
The variables have the following values:
a = 8, b = 5, c = 10, d = 3, e = 2, f = 7, g = 3;
If the variables x, a, b, c, d, e, f, g are of integer data type, then what will be the value of x after evaluating the above expression?
A24
B26
C20
D21
Show answerHide answer
Correct answer: (B) 26
Explanation
b * (c − d) = 5 × 7 = 35, and 35 / 2 = 17 in integer division. f % g = 7 % 3 = 1. So x = 8 + 17 + 1 = 26.
How to use these DSSSB TGT / PGT Computer Science questions
Every question here was asked in a real DSSSB TGT / PGT paper; the paper and shift are shown on the card, and the number opens the question on its own page. Try each one before tapping Show answer, then attempt the full DSSSB TGT / PGT papers as timed tests to check your speed under exam conditions.