All 100 questions of DSSSB TGT Computer Science Practice Set 2 with the correct answer and a solution. Read them free on UTpaper, or attempt the paper as a timed online test.
This question is based on following table :
TABLE : DELIVERY
SNO | DBOY | ITEM | STAR | AMOUNT
1001 | AMAN | FOOD | 5 | 3000
1005 | JONES | MEDICINE | 3 | 5000
1008 | AMAN | MEDICINE | 2 | 4000
1009 | RAZID | FOOD | 4 | 4500
1010 | JONES | GIFT | 5 | 5000
1018 | AMAN | FOOD | 5 | 3000
1022 | RAZID | MEDICINE | 4 | 5000
Which of the following SQL commands will remove the rows, which have column value of STAR less than 5 ?
AREMOVE FROM DELIVERY WHERE STAR < 5;
BDROP TABLE DELIVERY WHERE STAR < 5;
CDELETE FROM DELIVERY WHERE STAR < 5;
DDELETE * FROM DELIVERY WHERE STAR < 5;
Show answerHide answer
Correct answer: (C) DELETE FROM DELIVERY WHERE STAR < 5;
Explanation
DELETE FROM table WHERE condition removes matching rows. There is no REMOVE command, DROP removes the whole table, and DELETE * is not valid standard SQL.
Consider the following tables in a database SPORTS :
Table 1 : STUDENTS
ADMNO | SNAME
101 | AMAR
205 | MARIA
410 | MALALA
Table 2 : GAMES
GAMEID | GNAME
G03 | CRICKET
G05 | FOOTBALL
Which of the following SQL Command will produce an output as :
SNAME | GNAME
AMAR | CRICKET
MARIA | CRICKET
MALALA | CRICKET
AMAR | FOOTBALL
MARIA | FOOTBALL
MALALA | FOOTBALL
ASELECT SNAME, GNAME FROM STUDENTS, GAMES;
BSELECT SNAME, GNAME FROM STUDENTS X GAMES;
CSELECT SNAME FROM STUDENTS, GNAME FROM GAMES;
DSELECT SNAME FROM STUDENTS, SELECT GNAME FROM GAMES;
Show answerHide answer
Correct answer: (A) SELECT SNAME, GNAME FROM STUDENTS, GAMES;
Explanation
Listing two tables with no join condition gives their Cartesian product: every student paired with every game (3 × 2 = 6 rows), which matches the output.
This question is based upon the following class and code segment :
class STOCK
{ float price ;
public :
STOCK( ) ; // Function 1
STOCK(float P) ; // Function 2
STOCK(STOCK &S) ; // Function 3
void INIT( ) ; // Function 4
void DISP( ) ; // Function 5
~ STOCK( ) ; // Function 6
};
void main( )
{
STOCK S2(10) ; // Statement 1
______
______ // Other Statements
______
}
Which of the following declaration/statement will invoke the default constructor of the class - STOCK?
ASTOCK S1(S2);
BSTOCK S2;
CSTOCK S1(20);
DS2.INIT();
Show answerHide answer
Correct answer: (B) STOCK S2;
Explanation
Corrected: the book's key says (a), but STOCK S1(S2) calls the copy constructor. A declaration without arguments, like STOCK S2, invokes the default constructor.
Which of the following options states the correct storage - device hierarchy in terms of decreasing access time?
AMagnetic tape, magnetic disk, cache, main memory
BMagnetic disk, optical disk, main memory, register
CMagnetic tape, magnetic disk, main memory, register
DRegister, main memory, magnetic disk, magnetic tape
Show answerHide answer
Correct answer: (C) Magnetic tape, magnetic disk, main memory, register
Explanation
Decreasing access time means going from slowest to fastest: magnetic tape, magnetic disk, main memory, register. Option A wrongly puts cache before main memory.
Which of the following is not an advantage of client - side scripting ?
AFast processing as data is not sent to the server
BGive developers more control over behaviour of web widgets
CAllow for more interactivity by immediate responses to user's actions
DGive developers more control for data repositories across systems
Show answerHide answer
Correct answer: (D) Give developers more control for data repositories across systems
Explanation
Client-side scripts run in the browser and give speed, control of widgets and interactivity. Managing data repositories across systems is done on the server side.
Which of the following file stream function will not move the file pointer to (N+1)th record of a binary file F created with the help of objects of class EMPLOYEE ?
AF. seekp (N*sizeof (EMPLOYEE));
BF. seekg (F.tellg( )*N);
CF. seekg (sizeof (EMPLOYEE)*N);
DPOS = sizeof (EMPLOYEE)*N;
Show answerHide answer
Correct answer: (B) F. seekg (F.tellg( )*N);
Explanation
seekg(F.tellg()*N) multiplies the current position by N, which is not the offset of the (N+1)th record. The correct offset is N*sizeof(EMPLOYEE).
Which of the following statements about disk scheduling algorithms is correct ?
AThe disk arm behaves like an elevator in SCAN algorithm
BFCFS provides fastest service to the disk requests
CSSTF algorithm is an optimal algorithm
DSCAN algorithm provides more uniform wait time compared to C - SCAN algorithm
Show answerHide answer
Correct answer: (A) The disk arm behaves like an elevator in SCAN algorithm
Explanation
In SCAN, the disk arm moves to one end, then reverses, serving requests along the way, like an elevator. C-SCAN, not SCAN, gives more uniform waiting time.
ACounting semaphore can be used to control access to finite number of instances of a resource
BReader writers problem typically arises when several concurrent processes share the data base
CBanker's algorithm prevents dead lock
DA computer system is in a safe state only if there exists a safe sequence
Show answerHide answer
Correct answer: (C) Banker's algorithm prevents dead lock
Explanation
The banker's algorithm avoids deadlock (by checking for a safe state); it does not prevent it. Prevention means removing one of the four necessary conditions.
The following figure is a ______ tree after zig_Zig rotations.
Tree: root X; X has left child A and right child P; P has left child B and right child G; G has left child C and right child D.
AHeap
BBubble
CSplay
DBinary
Show answerHide answer
Correct answer: (C) Splay
Explanation
Zig-zig rotations are the restructuring steps of a splay tree, which move an accessed node up to the root.
Determine the function performed by the combinational circuit of the given figure.
Circuit: three 2-to-1 MUXes. MUX-1 has inputs I3 (to its I1) and I2 (to its I0). MUX-2 has inputs I1 (to its I1) and I0 (to its I0). The select lines of MUX-1 and MUX-2 are tied together to S1. The output Y of MUX-1 goes to input I1 of MUX-3 and the output Y of MUX-2 goes to input I0 of MUX-3. MUX-3 has select S0 and output F.
A4-to-1 multiplexer
B8-to-1 multiplexer
C16-to-1 multiplexer
D32-to1 multiplexer
Show answerHide answer
Correct answer: (A) 4-to-1 multiplexer
Explanation
MUX-1 and MUX-2 choose between I3/I2 and I1/I0 using S1, and MUX-3 chooses between their outputs using S0. Four inputs and two select lines make a 4-to-1 multiplexer.
How many characters does an escape sequence (\On, \Hn, \n, \f) in C++ consume?
A1
B3
C2
DNone of these
Show answerHide answer
Correct answer: (A) 1
Explanation
An escape sequence is written with two or more characters in the source code, but it represents and stores a single character, so it takes 1 character (1 byte).
Which of the following topologies gives highest reliability ?
AMesh topology
BBus topology
CStar topology
DRing topology
Show answerHide answer
Correct answer: (A) Mesh topology
Explanation
In a mesh topology each device has dedicated links to the others, so a single link failure does not affect the network. This gives the highest reliability.
Consider the following code segment:
if ( Y<0 )
{X = −X; Y = − Y;}
Z = 0;
while (Y>0)
{Z = Z + X; Y = Y −1;}
Assume that X, Y and Z are inter variables, and that X and Y have be initialized. Which of the following best describes what this code segment does?
ASets Z to be the product X* Y
BSets Z to be the sum X+Y
CSets Z to be the absolute value of X
DSets Z to be the value of Y
Show answerHide answer
Correct answer: (A) Sets Z to be the product X* Y
Explanation
If Y is negative, both signs are flipped. The loop then adds X to Z Y times, so Z = X × Y.
Consider a set of n tasks with known runtimes r1, r2 ........ rn, to be run on a uniprocessor machine, Which of the following processor scheduling algorithm will result in the maximum throughput.
APriority scheduling
BRound-robin
CFCFS
DShortest job first
Show answerHide answer
Correct answer: (D) Shortest job first
Explanation
Shortest Job First runs the shortest tasks first, so the average waiting time is minimised and the most jobs are completed per unit time.
Consider a set of n tasks with known runtimes r1, r2 ........ rn, to be run on a uniprocessor machine, Which of the following processor scheduling algorithm will result in the maximum throughput.
APriority scheduling
BRound-robin
CFCFS
DShortest job first
Show answerHide answer
Correct answer: (D) Shortest job first
Explanation
Shortest Job First runs the shortest tasks first, so the average waiting time is minimised and the most jobs are completed per unit time.
How many page faults occur in LRU page replacement algorithm for the given reference string, with four page frames.
7, 0, 1, 2, 0, 3, 0, 4, 2, 3, 0, 3, 2, 1, 2, 0, 1
A6
B8
C7
D9
Show answerHide answer
Correct answer: (C) 7
Explanation
With LRU and 4 frames: 7, 0, 1, 2 are 4 faults; 3 replaces 7; 4 replaces 1; then 1 replaces 4. All other references are hits, so there are 7 page faults.
The producer and Consumer processes share the following Variables:
int n,
Semaphore M = 1
Semaphore E = n
Semaphore F = 0
The consumer process must execute ______ and ______ before removing an item from buffer.
ASignal (M), Signal (F)
BSignal (M), Wait (F)
CSignal (F), Wait (M)
DWait (F), Wait (M)
Show answerHide answer
Correct answer: (D) Wait (F), Wait (M)
Explanation
A consumer first does wait(F) to make sure a full slot exists, then wait(M) for mutual exclusion on the buffer, and only then removes the item.
AIn asymmetric multiprocessing, the processors are peers.
BIn symmetric multiprocessing, the processors are placed symmetrically on the mother board.
CClustered systems are used for high performance computing.
DAll multiprocessor systems are multicore systems.
Show answerHide answer
Correct answer: (C) Clustered systems are used for high performance computing.
Explanation
Clustered systems join several computers to provide high availability and high-performance computing. In asymmetric multiprocessing the processors are not peers, and multiprocessor does not always mean multicore.
______ monitors user's activity on Internet and transmits that information in the backgroud to someone else.
AMalware
BSpyware
CAdware
DNone of the above
Show answerHide answer
Correct answer: (B) Spyware
Explanation
Spyware secretly monitors a user's activity, such as browsing and keystrokes, and sends that information to a third party in the background. Adware mainly shows unwanted advertisements.
The following postfix expression with single-digit operands is evaluated using a stack:
823^/23*+51*-
(Note that ^ is the exponentiation operator.) The top two elements of the stack after the first * is evaluated, are
A6, 1
B5, 7
C3, 2
D1, 5
Show answerHide answer
Correct answer: (A) 6, 1
Explanation
8 2 3 ^ gives 2³ = 8, then 8 / 8 = 1. Next 2 and 3 are pushed and * gives 6. The stack now holds 1, 6, so the top two elements are 6 and 1.
A hash function defined as f(key) = key mod 7 with linear probing is used to insert the keys 37, 38, 72, 48, 98, 11, 56 into a table indexed from 0 to 6. What will be the location of 11?
A3
B4
C5
D6
Show answerHide answer
Correct answer: (C) 5
Explanation
37→2, 38→3, 72→2 (taken, goes to 3, then 4), 48→6, 98→0. 11 mod 7 = 4 is taken, so linear probing places 11 at slot 5.
Assume X and Y are non-zero positive integers. Consider the following pseudo-code fragment:
while X<>Y do
if X>Y then
X ← X−Y
else
Y ← Y−X
endif
end while
print (X)
What is the code doing?
AIt computes the GCD of two numbers.
BIt computes the LCM of two numbers.
CIt finds the smallest of two numbers.
DIt divides the largest number by the smaller.
Show answerHide answer
Correct answer: (A) It computes the GCD of two numbers.
Explanation
This is the subtraction form of Euclid's algorithm: repeatedly subtracting the smaller number from the larger one until both are equal leaves their GCD.
Which of the following is not a program control instruction ?
ACMP
BMOV
CJMP
DCALL
Show answerHide answer
Correct answer: (B) MOV
Explanation
MOV is a data transfer instruction. JMP and CALL change the flow of control, and CMP is used with jumps to make decisions, so these are program control instructions.
For a tree with just one node, the root node is the height of a binary tree is defined to zero; if there are 2 levels of nodes, the height is 1 and so on.
A Binary Search Tree is built according to the usual rules with the following six key inserted one at a time as given :
B, I, N, A, R, Y. What is the height of the tree?
A5
B2
C3
D4
Show answerHide answer
Correct answer: (D) 4
Explanation
Inserting B, I, N, A, R, Y gives root B with A on the left and the chain I → N → R → Y to the right. The longest path B-I-N-R-Y has 4 edges, so the height is 4.
Which of the following methods in Java Script will display a window having a dialog box with a specified message, along with an OK and CANCEL button as options?
Aprompt ()
Balert ()
Cconfirm ()
Drequest ()
Show answerHide answer
Correct answer: (C) confirm ()
Explanation
confirm() shows a dialog with a message and OK and Cancel buttons and returns true or false. alert() has only OK, and prompt() also asks for text input.
To declare the version of XML. the correct syntax is :
A</xml version = '1.0'/>
B<?xml version = "1.0"/>
C<*xml version = '1.0'/>
D<?xml version = 1.0"/>
Show answerHide answer
Correct answer: (B) <?xml version = "1.0"/>
Explanation
The XML declaration is a processing instruction: <?xml version="1.0"?>. It begins with <?xml and the version value is quoted. Option B is the closest to this form.
Observe the following flowchart and find the output.
Flowchart: START → A = 100, S = 0 → decision "IS A >= 20 ?": if YES → S += A → A −= 40 → back to the decision; otherwise → OUTPUT S → STOP.
A180
B120
C100
D160
Show answerHide answer
Correct answer: (A) 180
Explanation
A=100: S=100, A=60. A=60: S=160, A=20. A=20 (still ≥ 20): S=180, A=−20. The condition is now false, so the output is 180.
Observe the following graph and find the missing statement in the Python code.
import matplotlib.pyplot as pl
______
pl. show()
Graph: a single line joining the points (0.0, 5), (1.0, 2), (2.0, 3), (3.0, 1); x-axis 0.0 to 3.0, y-axis 1.0 to 5.0.
Apl.bar ([5, 2, 3, 1])
Bpl.scatter ([5, 2, 3, 1])
Cpl.plot ([5, 2, 3, 1])
Dpl.line ([5, 2, 3, 1])
Show answerHide answer
Correct answer: (C) pl.plot ([5, 2, 3, 1])
Explanation
pl.plot([5, 2, 3, 1]) draws a line graph, using the indexes 0-3 as x values. bar and scatter give different charts, and pl.line does not exist.
A school organizes an educational trip for middle school students to the Jim Corbett National Park. What would be the teachers' advisory to the children during the visit?
AObserve everything without asking questions about it.
BNote down their doubts and ask the questions after reaching back.
CObserve keenly, make note and share observations with other fellow students and teacher.
DEnjoy the trip along with fellow students.
Show answerHide answer
Correct answer: (C) Observe keenly, make note and share observations with other fellow students and teacher.
Explanation
Observing keenly, making notes and sharing observations encourages active, inquiry-based and collaborative learning.
Rasleen is adding links to her company website. She wants to change the link colour as soon as the visitor's mouse hoven over the link and wants it should retain the original colour when visitor's mouse moves to any other location away from the link. Which of the following two event handless will be required to write a JavaScript code to achieve the same.
AOnMouseOver and OnMouseExit
BOnMouseOver and OnMouseOut
COnMouseIn and OnMouseOut
DOnMouseIn and OnMouseExit
Show answerHide answer
Correct answer: (B) OnMouseOver and OnMouseOut
Explanation
onmouseover fires when the pointer enters the link, and onmouseout fires when it leaves. There are no OnMouseIn or OnMouseExit events.
The number of pointer changes required for inserting a node between two given nodes in the linked implementation of a doubly linked list is ______.
AOne
BTwo
CThree
DFour
Show answerHide answer
Correct answer: (D) Four
Explanation
The new node's next and prev pointers are set, and the next pointer of the previous node and the prev pointer of the following node are updated. That makes 4 pointer changes.
Which of the following options is the correct code for traversing a link list staring at pointer P, upto element X ?
AWhile (P == NULL || P → Element ! = X)
P = P → Next ;
BWhile (P == NULL && P → Element ! = X)
P = P → Next ;
CWhile (P ! = NULL || P → Element ! = X)
P = P → Next ;
DWhile (P ! = NULL && P → Element ! = X)
P = P → Next ;
Show answerHide answer
Correct answer: (D) While (P ! = NULL && P → Element ! = X)
P = P → Next ;
Explanation
The loop must stop at the end of the list or when X is found, so it continues only while P != NULL && P→Element != X. Checking for NULL first also avoids dereferencing a null pointer.
Which of the following Boolean expression correctly represents the logic circuit diagram ?
Circuit: A and B feed a NOR gate; C and D feed a second NOR gate; the outputs of both NOR gates feed an AND gate, whose output is the circuit output.
A(A+B) . (C+D)
B(A . B)' + (C . D)'
CA . B + C . D
D(A+B)' . (C+D)'
Show answerHide answer
Correct answer: (D) (A+B)' . (C+D)'
Explanation
The NOR gates give (A+B)' and (C+D)', and the AND gate combines them, so the output is (A+B)' · (C+D)'.
Ms. Rabda is a CEO of a multinational company and she is planning to connect 3 offices of nearby cities with the help of wired media. Out of the following which wired media you would suggest for the same.
ACAT6 CABLE
BCOAXIAL CABLE
CTWO PAIR TELEPHONE CABLE
DOPTIC FIBER CABLE
Show answerHide answer
Correct answer: (D) OPTIC FIBER CABLE
Explanation
Optical fibre gives high bandwidth over long distances with little loss and no electromagnetic interference, so it is best for linking offices in different cities.
CCheck the arithmetical accuracy of ledger accounts
DPrepare invoices
Show answerHide answer
Correct answer: (C) Check the arithmetical accuracy of ledger accounts
Explanation
A Trial Balance lists all ledger balances to check that total debits equal total credits, which tests the arithmetical accuracy of the ledger accounts.
A child has a schema for a dog based on his experience with his pet, then when he sees another dog in the garden, he is able to recognize the animal. Which process of cognitive development is highlighted in the statement?
AAssimilation
BAccommodation
COperation
DEquilibrium
Show answerHide answer
Correct answer: (A) Assimilation
Explanation
Fitting a new experience (another dog) into an existing schema is assimilation in Piaget's theory. Accommodation means changing the schema itself.
During the pandemic, it has been on easy journey for students of private schools to continue their studies, while it has been a difficult one for students of government schools. Which characteristic of social culture is being highlighted in the above situation?
ACultural spread
BTechnical factor
CPhysical factor
DPolitical factor
Show answerHide answer
Correct answer: (B) Technical factor
Explanation
Private-school students could continue studying because they had better access to digital devices and the internet. The gap is a technological (digital divide) factor.