Vous êtes sur la page 1sur 360

Face Interviews Confidently!

Technical Aptitude Questions

Table of Contents

Data Structures Aptitude....................................................................................................3 C Aptitude ........................................................................................................................21 C++ Aptitude and OOPS................................................................................................142 Quantitative Aptitude......................................................................................................200 UNIX C ncepts...............................................................................................................23! "D#$S C ncepts...........................................................................................................2%& SQ'..................................................................................................................................30& C (puter Net) r*s........................................................................................................32! Operatin+ S,ste(s..........................................................................................................34-

2 Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

Data Structures Aptitude


Data Structures Aptitude 1. What is data structure? A data structure is a way of organi ing data that considers not only the ite!s stored" but also their relationship to each other# Advance $nowledge about the relationship between data ite!s allows designing of efficient algorith!s for the !anipulation of data# 2. List out the areas in which data structures are applied extensively? Co!piler Design" %perating Syste!"
& Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

Database 'anage!ent Syste!" Statistical analysis pac$age" (u!erical Analysis" )raphics" Artificial Intelligence" Si!ulation 3. What are the major data structures used in the following areas : !"#$% &etwor' data model ( )ierarchical data model. *D+'S , Array -i#e# Array of structures. (etwor$ data !odel , )raph /ierarchical data !odel , Trees *. +f you are using , language to implement the heterogeneous lin'ed list% what pointer type will you use? The heterogeneous lin$ed list contains different data types in its nodes and we need a lin$" pointer to connect the!# It is not possible to use ordinary pointers for this# So we go for void pointer# 0oid pointer is capable of storing pointer to any type as it is a generic pointer type# -. #inimum num.er of /ueues needed to implement the priority /ueue?
1 Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

Two# %ne 2ueue is used for actual storing of data and another for storing priorities# 0. What is the data structures used to perform recursion? Stac$# +ecause of its 3IF% -3ast In First %ut. property it re!e!bers its 4caller5 so $nows who! to return when the function has to return -that is last call gives first output.# *ecursion !a$es use of syste! stac$ for storing the return addresses of the function calls# 1very recursive function has its e/uivalent iterative 2non3recursive4 function. 6ven when such e2uivalent iterative procedures are written" e7plicit stac$ is to be used# 5. What are the notations used in 1valuation of 6rithmetic 1xpressions using prefix and postfix forms? 8olish and *everse 8olish notations# 7. ,onvert the expression 226 8 "4 9 , : 2! : 14 ; 2< 8 =44 to e/uivalent >refix and >ostfix notations. -9 is lowest i!portant. 8refi7 (otation: 9 ; < =A+C ; D6 = F) 8ostfi7 (otation: >
Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

A+ = C < D6 ; ; F) = 9 ?. $orting is not possi.le .y using which of the following methods? 2a4 +nsertion 2.4 $election 2c4 1xchange 2d4 !eletion -d. Deletion# ?sing insertion we can perfor! insertion sort" using selection we can perfor! selection sort" using e7change we can perfor! the bubble sort -and other si!ilar sorting !ethods.# +ut no sorting !ethod can be done @ust using deletion# 1@. 6 .inary tree with 2@ nodes has .ranches? 2A 3et us ta$e a tree with > nodes -nB>. null

(ull +ranches

C Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

It will have only C -ie">=A. null branches# In general" 6 .inary tree with n nodes has exactly n+1 null nodes. 11. What are the methods availa.le in storing se/uential files ? Straight !erging" (atural !erging" 8olyphase sort" Distribution of Initial runs# 12. )ow many different trees are possi.le with 1@ nodes ? ADA1 For e7a!ple" consider a tree with & nodes-nB&." it will have the !a7i!u! co!bination of > different -ie" 2& ; & B >. trees#

E Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

ii

iii

iv

In general: +f there are n nodes% there exist 2n.n different trees. 13. List out few of the 6pplication of tree data3 structure? The !anipulation of Arith!etic e7pression" Sy!bol Table construction" Synta7 analysis# 1*. List out few of the applications that ma'e use of #ultilin'ed $tructures? Sparse !atri7" Inde7 generation# 1-. +n tree construction which is the suita.le efficient data structure? 2a4 6rray 2.4 Lin'ed list 2c4 $tac' 2d4 Aueue 2e4 none -b. 3in$ed list

F Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

10. What is the type of the algorithm used in solving the 7 Aueens pro.lem? +ac$trac$ing 15. +n an 6BL tree% at what condition the .alancing is to .e done? If the 4pivotal value5 -or the 4/eight factor5. is greater than A or less than ,A# 17. What is the .uc'et siCe% when the overlapping and collision occur at same time? %ne# If there is only one entry possible in the buc$et" when the collision occurs" there is no way to acco!!odate the colliding value# This results in the overlapping of values# 1?. Draverse the given tree using +norder% >reorder and >ostorder traversals.
)iven tree:
A

/
G

Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

Inorder : D / + 6 A F C I ) H 8reorder: A + D / 6 C F ) I H 8ostorder: / D 6 + F I H ) C A 2@. Dhere are 7% 1-% 13% 1* nodes were there in * different trees. Which of them could have formed a full .inary tree? A># In general: Dhere are 2n.1 nodes in a full .inary tree. "y the method of elimination: Full binary trees contain odd nu!ber of nodes# So there cannot be full binary trees with F or A1 nodes" so re@ected# Iith A& nodes you can for! a complete binary tree but not a full binary tree# So the correct answer is A># N te:

AD Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

Full and Co!plete binary trees are different# 6ll full .inary trees are complete .inary trees .ut not vice versa. 21. +n the given .inary tree% using array you can store the node * at which location?
A

&

1 >

At location C A 2 & ; ; 1 ; ; >

*o 3 * 3 * 3 * 3 * ot CA CA C2 C2 C& C& C1 C1 where 3Cn !eans 3eft Child of node n and *Cn !eans *ight Child of node n AA
Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

22. $ort the given values using Auic' $ort? C> ED E> FD F> CD >> >D 1> Sorting ta$es place fro! the pivot value" which is the first value of the given ele!ents" this is !ar$ed bold# The values at the left pointer and right pointer are indicated using 3 and * respectively# 65 ED E> FD F> CD >> >D 1>
3 *

Since pivot is not yet changed the sa!e process is continued after interchanging the values at 3 and * positions 65 1> E> FD F> CD >> >D ED
3 *

65 1> >D FD F> CD >> E> ED


3 *

65 1> >D >> F> CD FD E> ED


3 *

A2 Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

65 1> >D >> CD F> FD E> ED


* 3

Ihen the 3 and * pointers cross each other the pivot value is interchanged with the value at right pointer# If the pivot is changed it !eans that the pivot has occupied its original position in the sorted order -shown in bold italics. and hence two different arrays are for!ed" one fro! start of the original array to the pivot position;A and the other fro! pivot position=A to end# 60 1> >D >> %- 85 FD E> ED
3 * 3 *

55 1> >D %0 %- 70 FD E> /3 * * 3

50 1> -- %0 %- !0 FD E> /3 * 3 *

In the ne7t pass we get the sorted for! of the array# 4- -0 -- %0 %- !0 !- /0 /23. <or the given graph% draw the !<$ and "<$?
A& Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions The given graph:

A J )

/ 6 8

K ' H

"<$: A J ) / 8 6 ' K H !<$: A J / 8 6 K ' H ) 2*. ,lassify the )ashing <unctions .ased on the various methods .y which the 'ey value is found. Direct !ethod" Subtraction !ethod" 'odulo;Division !ethod" Digit;67traction !ethod" 'id;S2uare !ethod" Folding !ethod" 8seudo;rando! !ethod#
A1 Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

2-. What are the types of ,ollision esolution Dechni/ues and the methods used in each of the type? %pen addressing -closed hashing." The !ethods used include: %verflow bloc$" Closed addressing -open hashing. The !ethods used include: 3in$ed list" +inary treeL 20. +n !"#$% what is the efficient data structure used in the internal storage representation? += tree# +ecause in += tree" all the data is stored only in leaf nodes" that !a$es searching easier# This corresponds to the records that shall be stored in leaf nodes# 25. !raw the "3tree of order 3 created .y inserting the following data arriving in se/uence : ?2 2* 0 5 11 7 22 * - 10 1? 2@ 57
AA

>

AG

21

1 A>

AC

2D

22

EF

G2

Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

27. Ef the following tree structure% which is% efficient considering space and time complexities? 2a4 +ncomplete "inary Dree 2.4 ,omplete "inary Dree 2c4 <ull "inary Dree -b. Co!plete +inary Tree# "y the method of elimination: Full binary tree loses its nature when operations of insertions and deletions are done# For inco!plete binary trees" e7tra storage is re2uired and overhead of (?33 node chec$ing ta$es place# So co!plete binary tree is the better one since the property of co!plete binary tree is !aintained even after operations li$e additions and deletions are done on it# 2?. What is a spanning Dree? A spanning tree is a tree associated with a networ$# All the nodes of the graph appear on the tree once# A !ini!u! spanning tree is a spanning tree organi ed so that the total edge weight between nodes is !ini!i ed# AC
Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

3@. !oes the minimum spanning tree of a graph give the shortest distance .etween any 2 specified nodes? (o# 'ini!al spanning tree assures that the total weight of the tree is $ept at its !ini!u!# +ut it doesnFt !ean that the distance between any two nodes involved in the !ini!u!;spanning tree is !ini!u!# 31. ,onvert the given graph with weighted edges to minimal spanning tree.

A
1AD

CDD

CA2
2GF>

&
&AD

2DD

>
1DD

A12A

the e2uivalent !ini!al spanning tree is:


A

& CA2 &AD 2DD

AE

1AD

2 1 > Reserved Copyright: Vyom Network (http://www.vyomworld.com) - All Rights

Technical Aptitude Questions

32. Which is the simplest file structure? 2a4 $e/uential 2.4 +ndexed 2c4 andom -a. Se2uential 33. Whether Lin'ed List is linear or &on3linear data structure? According to Access strategies 3in$ed list is a linear one# According to Storage 3in$ed 3ist is a (on;linear one# 3*. !raw a .inary Dree for the expression : 6 9 " 3 2, 8 !4 9 2> G A4
< < ;

AF

Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

3-. <or the following ,E"EL code% draw the "inary tree? DA ST?D6(TN*6C# D2 (A'6# D& FI*STN(A'6 8IC J-AD.# D& 3ASTN(A'6 8IC J-AD.# D2 K6A*N%FNST?DK# D& FI*STNS6' 8IC JJ# DA D& S6C%(DNS6' 8IC JJ# ST?D6(TN*6C
D2
AG

D2
K6A*N%FNST?DK

(A'6

Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

D&
FI*STN(A'6

D&
3ASTN(A'6

D&
FI*STNS6'

D&
S6C%(DNS6'

Technical Aptitude Questions

2D Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

C CAptitude Aptitude

N te 0 All the progra!s are tested under Turbo CMC== co!pilers# It is assu!ed that" 8rogra!s run under D%S environ!ent" The underlying !achine is an 7FC syste!" 8rogra! is co!piled using Turbo CMC== co!piler# The progra! output !ay depend on the infor!ation based on this assu!ptions -for e7a!ple si eof-int. BB 2 !ay be assu!ed.# 8redict the output or error-s. for the following: 1. void main24 H int const 9 pI-J printf2KLdK%8829p44J
2A Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

M Ans)er0 Co!piler error: Cannot !odify a constant value# 12p3anati n: p is a pointer to a Oconstant integerO# +ut we tried to change the value of the Oconstant integerO# 2. main24 H char sN OIKmanKJ int iJ for2iI@JsN i OJi884 printf2KPnLcLcLcLcK%sN i O%92s8i4%92i8s4%iNsO4J M Ans)er0 !!!! aaaa nnnn 12p3anati n: sPiQ" <-i=s." <-s=i." iPsQ are all different ways of e7pressing the sa!e idea# )enerally array na!e is the base address for that array# /ere s is the base address# i is the inde7 nu!berMdisplace!ent fro! the base address# So" indirecting it with < is sa!e as sPiQ# iPsQ !ay be surprising# +ut in the case of C it is sa!e as sPiQ#
22 Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

3. main24 H float me I 1.1J dou.le you I 1.1J if2meIIyou4 printf2K+ love QK4J else printf2K+ hate QK4J M Ans)er0 I hate ? 12p3anati n: For floating point nu!bers (float" double" long double) the values cannot be predicted e7actly# Depending on the nu!ber of bytes" the precession with of the value represented varies# Float ta$es 1 bytes and long double ta$es AD bytes# So float stores D#G with less precision than long double# Rule of Thumb: (ever co!pare or at;least be cautious when using floating point nu!bers with relational operators (BB " R" S" SB" RB"!B ) # *. main24 H static int var I -J printf2KLd K%var334J if2var4 2&
Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

main24J M Ans)er0 >1&2A 12p3anati n0 Ihen static storage class is given" it is initiali ed once# The change in the value of a static variable is retained even between the function calls# 'ain is also treated li$e any other ordinary function" which can be called recursively# -. main24 H int cN OIH2.7%3.*%*%0.5%-MJ int j%9pIc%9/IcJ for2jI@JjR-Jj884 H printf2K Ld K%9c4J 88/J M for2jI@JjR-Jj884H printf2K Ld K%9p4J 88pJ M M Ans)er0 222222&1C> 12p3anati n0 Initially pointer c is assigned to both p and q # In the first loop" since only q is incre!ented and 21
Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

not c " the value 2 will be printed > ti!es# In second loop p itself is incre!ented# So the values 2 & 1 C > will be printed# 0. main24 H extern int iJ iI2@J printf2KLdK%i4J M Ans)er0 Lin'er 1rror : ?ndefined sy!bol TNiT 12p3anati n0 e7tern storage class in the following declaration" extern int i; specifies to the co!piler that the !e!ory for i is allocated in so!e other progra! and that address will be given to the current progra! at the ti!e of lin$ing# +ut lin$er finds that no other variable of na!e i is available in any other progra! with !e!ory space allocated for it# /ence a lin$er error has occurred # 5. main24 H int iI31%jI31%'I@%lI2%mJ mIi88((j88(('88SSl88J 2>
Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

printf2KLd Ld Ld Ld LdK%i%j%'%l%m4J M Ans)er0 DDA&A 12p3anati n 0 3ogical operations always give a result of 1 or 0 # And also the logical A(D -UU. operator has higher priority over the logical %* -VV. operator# So the e7pression 4i++ && ++ && !++" is e7ecuted first# The result of this e7pression is D -;A UU ;A UU D B D.# (ow the e7pression is D VV 2 which evaluates to A -because %* operator always gives A e7cept for 4D VV D5 co!bination; for which it gives D.# So the value of ! is A# The values of other variables are also incre!ented by A# 7. main24 H char 9pJ printf2KLd Ld K%siCeof29p4%siCeof2p44J M Ans)er0 A2 12p3anati n0 The si eof-. operator gives the nu!ber of bytes ta$en by its operand# 8 is a character pointer" which needs one byte for storing its value -a 2C
Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

character.# /ence si eof-<p. gives a value of A# Since it needs two bytes to store the address of the character pointer si eof-p. gives 2# ?. main24 H int iI3J switch2i4 H default:printf2KCeroK4J case 1: printf2KoneK4J .rea'J case 2:printf2KtwoK4J .rea'J case 3: printf2KthreeK4J .rea'J M M Ans)er 0 three 12p3anati n 0 The default case can be placed anywhere inside the loop# It is e7ecuted only when all other cases doesnTt !atch# 1@. main24 H printf2KLxK%31RR*4J 2E
Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

M Ans)er0 fffD 12p3anati n 0 ;A is internally represented as all ATs# Ihen left shifted four ti!es the least significant 1 bits are filled with DTs#The W7 for!at specifier specifies that the integer value be printed as a he7adeci!al value# 11. main24 H char stringNOIK)ello WorldKJ display2string4J M void display2char 9string4 H printf2KLsK%string4J M Ans)er0 ,ompiler 1rror : Type !is!atch in redeclaration of function display 12p3anati n 0 In third line" when the function #ispl$% is encountered" the co!piler doesnTt $now anything about the function display# It assu!es the argu!ents and return types to be integers" -which is the default type.# Ihen it sees the actual function #ispl$%& the argu!ents and type contradicts with what it has 2F
Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

assu!ed previously# /ence a co!pile ti!e error occurs# 12. main24 H int cI3 32J printf2KcILdK%c4J M Ans)er0 cB2X 12p3anati n0 /ere unary !inus -or negation. operator is used twice# Sa!e !aths rules applies" ie# !inus < !inusB plus# 'ote: /owever you cannot give li$e ;;2# +ecause ;; operator can only be applied to variables as a #e(rement operator -eg#" i;;.# 2 is a constant and not a variable# 13. Tdefine int char main24 H int iI0-J printf2KsiCeof2i4ILdK%siCeof2i44J M Ans)er0 si eof-i.BA 2G
Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

12p3anati n0 Since the Ydefine replaces the string int by the !acro (h$r 1*. main24 H int iI1@J iIUiV1*J printf2KiILdK%i4J M Ans)er0 iBD 12p3anati n0 In the e7pression )i*1+ " (%T -!. operator has !ore precedence than 4 R5 sy!bol# ) is a unary logical operator# !i -!AD. is D -not of true is false.# DRA1 is false - ero.# 1-. TincludeRstdio.hV main24 H char sNOIHWaW%W.W%WcW%WPnW%WcW%WP@WMJ char 9p%9str%9str1J pI(sN3OJ strIpJ str1IsJ &D
Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

printf2KLdK%889p 8 889str13324J M Ans)er0 EE 12p3anati n0 p is pointing to character TZnT# strA is pointing to character TaT ==<p# Op is pointing to TZnT and that is incre!ented by one#O the ASCII value of TZnT is AD" which is then incre!ented to AA# The value of ==<p is AA# ==<strA" strA is pointing to TaT that is incre!ented by A and it beco!es TbT# ASCII value of TbT is GF# (ow perfor!ing -AA = GF , &2." we get EE-O'O.X So we get the output EE :: O'O -Ascii is EE.# 10. TincludeRstdio.hV main24 H int aN2ON2ON2O I H H1@%2%3%*M% H-%0%5%7M MJ int 9p%9/J pI(aN2ON2ON2OJ 9/I999aJ printf2KLd3333LdK%9p%9/4J M Ans)er0 So!e)arbage0alue;;;A 12p3anati n0 &A
Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

pBUaP2QP2QP2Q you declare only two 2D arrays" but you are trying to access the third 2D-which you are not declared. it will print garbage values# <2B<<<a starting address of a is assigned integer pointer# (ow 2 is pointing to starting address of a# If you print <2" it will print first ele!ent of &D array# 15. TincludeRstdio.hV main24 H struct xx H int xI3J char nameNOIKhelloKJ MJ struct xx 9sJ printf2KLdK%s3Vx4J printf2KLsK%s3Vname4J M Ans)er0 Co!piler 6rror 12p3anati n0 Kou should not initiali e variables in declaration 17. TincludeRstdio.hV main24 &2
Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

H struct xx H int xJ struct yy H char sJ struct xx 9pJ MJ struct yy 9/J MJ M Ans)er0 Co!piler 6rror 12p3anati n0 The structure yy is nested within structure 77# /ence" the ele!ents are of yy are to be accessed through the instance of structure 77" which needs an instance of yy to be $nown# If the instance is created after defining the structure the co!piler will not $now about the instance relative to 77# /ence for nested structure yy you have to declare !e!ber# 1?. main24 H printf2KPna.K4J printf2KP.siK4J printf2KPrhaK4J &&
Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

M Ans)er0 hai 12p3anati n0 Zn ; newline Zb ; bac$space Zr ; linefeed 2@. main24 H int iI-J printf2KLdLdLdLdLdLdK%i88%i33%88i%33i%i4J M Ans)er0 1>>1> 12p3anati n0 The argu!ents in a function call are pushed into the stac$ fro! left to right# The evaluation is by popping out fro! the stac$# and the evaluation is fro! right to left" hence the result# 21. Tdefine s/uare2x4 x9x main24 H int iJ i I 0*Gs/uare2*4J printf2KLdK%i4J M &1
Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

Ans)er0 C1 12p3anati n0 the !acro call s2uare-1. will substituted by 1<1 so the e7pression beco!es i B C1M1<1 # Since M and < has e2ual priority the e7pression will be evaluated as -C1M1.<1 i#e# AC<1 B C1 22. main24 H char 9pIKhai friendsK%9p1J p1IpJ while29pUIWP@W4 889p88J printf2KLs LsK%p%p14J M Ans)er0 ib@!gs@foet 12p3anati n0 ==<p== will be parse in the given order <p that is value at the location currently pointed by p will be ta$en ==<p the retrieved value will be incre!ented when X is encountered the location will be incre!ented that is p== will be e7ecuted /ence" in the while loop initial value pointed by p is 4h5" which is changed to 4i5 by e7ecuting ==<p and pointer !oves to point" 4a5 which is si!ilarly
&> Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

changed to 4b5 and so on# Si!ilarly blan$ space is converted to 4!5# Thus" we obtain value in p beco!es [ib@!gs@foet\ and since p reaches 4ZD5 and pA points to p thus pAdoesnot print anything# 23. Tinclude Rstdio.hV Tdefine a 1@ main24 H Tdefine a -@ printf2KLdK%a4J M Ans)er0 >D 12p3anati n0 The preprocessor directives can be redefined anywhere in the progra!# So the !ost recently assigned value will be ta$en# 2*. Tdefine clrscr24 1@@ main24 H clrscr24J printf2KLdPnK%clrscr244J M Ans)er0 ADD 12p3anati n0 &C
Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

8reprocessor e7ecutes as a seperate pass before the e7ecution of the co!piler# So te7tual replace!ent of clrscr-. to ADD occurs#The input progra! to co!piler loo$s li$e this : !ain-. ] ADDX printf-OWdZnO"ADD.X ^ 'ote: ADDX is an e7ecutable state!ent but with no action# So it doesnTt give any proble! 2-. main24 H printf2KLpK%main4J M Ans)er0 So!e address will be printed# 12p3anati n0 Function na!es are @ust addresses -@ust li$e array na!es are addresses.# !ain-. is also a function# So the address of function !ain will be printed# Wp in printf specifies that the argu!ent is an address# They are printed as he7adeci!al nu!bers# 2E. !ain-. &E
Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

] clrscr-.X ^ clrscr-.X Ans)er0 (o outputMerror 12p3anati n0 The first clrscr-. occurs inside a function# So it beco!es a function call# In the second clrscr-.X is a function declaration -because it is not inside any function.# 2F. enu! colors ]+3AC_"+3?6")*66(^ !ain-. ] printf-OWd##Wd##WdO"+3AC_"+3?6")*66(.X return-A.X ^ Ans)er0 D##A##2 12p3anati n0 enu! assigns nu!bers starting fro! D" if not e7plicitly defined# 2G. void !ain-. &F
Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

] char far <farther"<farthestX printf-OWd##WdO"si eof-farther."si eof-farthest..X ^ Ans)er0 1##2 12p3anati n0 the second pointer is of char type and not a far pointer &D. !ain-. ] int iB1DD"@B&DDX printf-OWd##WdO.X ^ Ans)er0 1DD##&DD 12p3anati n0 printf ta$es the values of the first two assign!ents of the progra!# Any nu!ber of printfTs !ay be given# All of the! ta$e only the first two values# If !ore nu!ber of assign!ents given in the progra!"then printf will ta$e garbage values# &A. !ain-. &G
Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

] char <pX pBO/elloOX printf-OWcZnO"<U<p.X ^ Ans)er0 / 12p3anati n0 < is a dereference operator U is a reference operator# They can be applied any nu!ber of ti!es provided it is !eaningful# /ere p points to the first character in the string O/elloO# <p dereferences it and so its value is /# Again U references it to an address and < dereferences it to the value /# &2. !ain-. ] int iBAX while -iSB>. ] printf-OWdO"i.X if -iR2. goto hereX i==X ^ ^ fun-. 1D
Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

] here: printf-O88O.X ^ Ans)er0 Co!piler error: ?ndefined label ThereT in function !ain 12p3anati n0 3abels have functions scope" in other words The scope of the labels is li!ited to functions # The label ThereT is available in function fun-. /ence it is not visible in function !ain# &&. !ain-. ] static char na!esP>Q P2DQB]OpascalO"OadaO"OcobolO"OfortranO"OperlO^X int iX char <tX tBna!esP&QX na!esP&QBna!esP1QX na!esP1QBtX for -iBDXiSB1Xi==. printf-OWsO"na!esPiQ.X ^ Ans)er0
1A Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

Co!piler error: 3value re2uired in function !ain 12p3anati n0 Array na!es are pointer constants# So it cannot be !odified# &1. void !ain-. ] int iB>X printf-OWdO"i== = ==i.X ^ Ans)er0 %utput Cannot be predicted e7actly# 12p3anati n0 Side effects are involved in the evaluation of i &>. void !ain-. ] int iB>X printf-OWdO"i=====i.X ^ Ans)er0 Co!piler 6rror 12p3anati n0 The e7pression i=====i is parsed as i == == = i which is an illegal co!bination of operators# 12
Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

&C. YincludeSstdio#hR !ain-. ] int iBA"@B2X switch-i. ] case A: printf-O)%%DO.X brea$X case @: printf-O+ADO.X brea$X ^ ^ Ans)er0 Co!piler 6rror: Constant e7pression re2uired in function !ain# 12p3anati n0 The case state!ent can have only constant e7pressions -this i!plies that we cannot use variable na!es directly so an error.# 'ote: 6nu!erated types can be used in case state!ents# &E. !ain-. ] int iX
1& Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

printf-OWdO"scanf-OWdO"Ui..X MM value AD is given as input here ^ Ans)er0 A 12p3anati n0 Scanf returns nu!ber of ite!s successfully read and not AMD# /ere AD is given as input which should have been scanned successfully# So nu!ber of ite!s read is A# &F. Ydefine f-g"g2. gYYg2 !ain-. ] int varA2BADDX printf-OWdO"f-var"A2..X ^ Ans)er0 ADD &G. !ain-. ] int iBDX for-Xi==Xprintf-OWdO"i.. X printf-OWdO"i.X ^ Ans)er0

11

Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

A 12p3anati n0 before entering into the for loop the chec$ing condition is OevaluatedO# /ere it evaluates to D -false. and co!es out of the loop" and i is incre!ented -note the se!icolon after the for loop.# 1D. YincludeSstdio#hR !ain-. ] char sPQB]TaT"TbT"TcT"TZnT"TcT"TZDT^X char <p"<str"<strAX pBUsP&QX strBpX strABsX printf-OWdO"==<p = ==<strA;&2.X ^ Ans)er0 ' 12p3anati n0 p is pointing to character TZnT#strA is pointing to character TaT ==<p !eAnswer:Op is pointing to TZnT and that is incre!ented by one#O the ASCII value of TZnT is AD# then it is incre!ented to AA# the value of ==<p is AA# ==<strA !eAnswer:OstrA is pointing to TaT that is incre!ented by A and it beco!es TbT# 1>
Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

ASCII value of TbT is GF# both AA and GF is added and result is subtracted fro! &2# i#e# -AA=GF;&2.BEE-O'O.X 1A. YincludeSstdio#hR !ain-. ] struct 77 ] int 7B&X char na!ePQBOhelloOX ^X struct 77 <sB!alloc-si eof-struct 77..X printf-OWdO"s;R7.X printf-OWsO"s;Rna!e.X ^ Ans)er0 Co!piler 6rror 12p3anati n0 Initiali ation should not be done for structure !e!bers inside the structure declaration 12. YincludeSstdio#hR !ain-. ] struct 77 ] 1C
Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

int 7X struct yy ] char sX struct 77 <pX ^X struct yy <2X ^X ^ Ans)er0 Co!piler 6rror 12p3anati n0 in the end of nested structure yy a !e!ber have to be declared# 1&. !ain-. ] e7tern int iX iB2DX printf-OWdO"si eof-i..X ^ Ans)er0 3in$er error: undefined sy!bol TNiT# 12p3anati n0 e7tern declaration specifies that the variable i is defined so!ewhere else# The co!piler passes the e7ternal variable to be resolved by the lin$er# So co!piler doesnTt find an 1E
Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

error# During lin$ing the lin$er searches for the definition of i# Since it is not found the lin$er flags an error# 11. !ain-. ] printf-OWdO" out.X ^ int outBADDX Ans)er0 Co!piler error: undefined sy!bol out in function !ain# 12p3anati n0 The rule is that a variable is available for use fro! the point of declaration# 6ven though a is a global variable" it is not available for !ain# /ence an error# 1>. !ain-. ] e7tern outX printf-OWdO" out.X ^ int outBADDX Ans)er0 ADD 12p3anati n0
1F Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

This is the correct way of writing the previous progra!# 1C. !ain-. ] show-.X ^ void show-. ] printf-OIT! the greatestO.X ^ Ans)er0 Co!pier error: Type !is!atch in redeclaration of show# 12p3anati n0 Ihen the co!piler sees the function show it doesnTt $now anything about it# So the default return type -ie" int. is assu!ed# +ut when co!piler sees the actual definition of show !is!atch occurs since it is declared as void# /ence the error# The solutions are as follows: A# declare void show-. in !ain-. # 2# define show-. before !ain-.# &# declare e7tern void show-. before the use of show-.# 1E. !ain- . 1G
Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

] int aP2QP&QP2Q B ]]]2"1^"]E"F^"]&"1^^"]]2"2^" ]2"&^"]&"1^^^X printf-[Wu Wu Wu Wd Zn\"a"<a"<<a"<<<a.X printf-[Wu Wu Wu Wd Zn\"a=A"<a=A"<<a=A"<<<a=A.X ^ Ans)er0 ADD" ADD" ADD" 2 AA1" AD1" AD2" & 12p3anati n0 The given array is a &;D one# It can also be viewed as a A;D array# 2 1 E F & 1 2 2 2 & & 1 ADD AD2 AD1 ADC ADF AAD AA2 AA1 AAC AAF A2D A22 thus" for the first printf state!ent a" <a" <<a give address of first ele!ent # since the indirection <<<a gives the value# /ence" the first line of the output# for the second printf a=A increases in the third di!ension thus points to value at AA1" <a=A incre!ents in second di!ension thus points to AD1" <<a =A incre!ents the first di!ension thus points to AD2 and <<<a=A

>D

Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

first gets the value at first location and then incre!ents it by A# /ence" the output# 1F. !ain- . ] int aP Q B ]AD"2D"&D"1D">D^"@"<pX for-@BDX @S>X @==. ] printf-[Wd\ "<a.X a==X ^ p B aX for-@BDX @S>X @==. ] printf-[Wd \ "<p.X p==X ^ ^ Ans)er0 Co!piler error: lvalue re2uired# 12p3anati n0 6rror is in line with state!ent a==# The operand !ust be an lvalue and !ay be of any of scalar type for the any operator" array na!e only when subscripted is an lvalue# Si!ply array na!e is a non;!odifiable lvalue#

>A

Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

1G. !ain- . ] static int aP Q B ]D"A"2"&"1^X int <pP Q B ]a"a=A"a=2"a=&"a=1^X int <<ptr B pX ptr==X printf-[Zn Wd Wd Wd\" ptr;p" <ptr;a" <<ptr.X <ptr==X printf-[Zn Wd Wd Wd\" ptr;p" <ptr;a" <<ptr.X <==ptrX printf-[Zn Wd Wd Wd\" ptr;p" <ptr;a" <<ptr.X ==<ptrX printf-[Zn Wd Wd Wd\" ptr;p" <ptr;a" <<ptr.X ^ Ans)er0 111 222 333 3** 12p3anati n0 3et us consider the array and the two pointers with so!e address $ D A 2 & 1 ADD AD2 AD1 ADC ADF p AD AD AD AD AD >2
Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

>&

D 2 1 C F ADDD ADD2 ADD1 ADDC ADDF ptr ADD D 2DDD After e7ecution of the instruction ptr== value in ptr beco!es ADD2" if scaling factor for integer is 2 bytes# (ow ptr , p is value in ptr , starting location of array p" -ADD2 , ADDD. M -scaling factor. B A" <ptr , a B value at address pointed by ptr , starting value of array a" ADD2 has a value AD2 so the value is -AD2 , ADD.M-scaling factor. B A" <<ptr is the value stored in the location pointed by the pointer of ptr B value pointed by value pointed by ADD2 B value pointed by AD2 B A# /ence the output of the firs printf is A" A" A# After e7ecution of <ptr== incre!ents value of the value in ptr by scaling factor" so it beco!esADD1# /ence" the outputs for the second printf are ptr , p B 2" <ptr , a B 2" <<ptr B 2# After e7ecution of <==ptr incre!ents value of the value in ptr by scaling factor" so it beco!esADD1# /ence" the outputs for the third printf are ptr , p B &" <ptr , a B &" <<ptr B &#

Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

After e7ecution of ==<ptr value in ptr re!ains the sa!e" the value pointed by the value is incre!ented by the scaling factor# So the value in array p at location ADDC changes fro! ADC AD ADF"# /ence" the outputs for the fourth printf are ptr , p B ADDC , ADDD B &" <ptr , a B ADF , ADD B 1" <<ptr B 1# >D. !ain- . ] char <2X int @X for -@BDX @S&X @==. scanf-[Ws\ "-2=@..X for -@BDX @S&X @==. printf-[Wc\ "<-2=@..X for -@BDX @S&X @==. printf-[Ws\ "-2=@..X ^ 12p3anati n0 /ere we have only one pointer to type char and since we ta$e input in the sa!e pointer thus we $eep writing over in the sa!e location" each ti!e shifting the pointer value by A# Suppose the inputs are '%?S6" T*AC_ and 0I*T?A3# Then for the first input suppose the pointer starts at location ADD then the input one is stored as
>1 Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

' % ? S 6 ZD Ihen the second input is given the pointer is incre!ented as @ value beco!es A" so the input is filled in !e!ory starting fro! ADA# ' T * A C _ ZD The third input starts filling fro! the location AD2 ' T 0 I * T ? A 3 ZD This is the final value stored # The first printf prints the values at the position 2" 2=A and 2=2 B ' T 0 The second printf prints three strings starting fro! locations 2" 2=A" 2=2 i#e 'T0I*T?A3" T0I*T?A3 and 0I*T?A3# >A. !ain- . ] void <vpX char ch B 4g5" <cp B [goofy\X int @ B 2DX vp B UchX printf-[Wc\" <-char <.vp.X vp B U@X printf-[Wd\"<-int <.vp.X vp B cpX printf-[Ws\"-char <.vp = &.X ^ >>
Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

Ans)er0 g2Dfy 12p3anati n0 Since a void pointer is used it can be type casted to any other type pointer# vp B Uch stores address of char ch and the ne7t state!ent prints the value stored in vp after type casting it to the proper data type pointer# the output is 4g5# Si!ilarly the output fro! second printf is 42D5# The third printf state!ent type casts it to print the string fro! the 1th value hence the output is 4fy5# >2. !ain - . ] static char <sP Q B ][blac$\" [white\" [yellow\" [violet\^X char <<ptrP Q B ]s=&" s=2" s=A" s^" <<<pX p B ptrX <<==pX printf-[Ws\"<;;<==p = &.X ^ Ans)er0 c$ 12p3anati n0 In this proble! we have an array of char pointers pointing to start of 1 strings# Then >C
Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

we have ptr which is a pointer to a pointer of type char and a variable p which is a pointer to a pointer to a pointer of type char# p hold the initial value of ptr" i#e# p B s=&# The ne7t state!ent incre!ent value in p by A " thus now value of p B s=2# In the printf state!ent the e7pression is evaluated <==p causes gets value s=A then the pre decre!ent is e7ecuted and we get s=A , A B s # the indirection operator now gets the value fro! the array of s and adds & to the starting address# The string is printed starting fro! this position# Thus" the output is 4c$5# >&. !ain-. ] int i" nX char <7 B [girl\X n B strlen-7.X <7 B 7PnQX for-iBDX iSnX ==i. ] printf-[WsZn\"7.X 7==X ^ ^ Ans)er0 -blan$ space. >E
Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

irl rl l 12p3anati n0 /ere a string -a pointer to char. is initiali ed with a value [girl\# The strlen function returns the length of the string" thus n has a value 1# The ne7t state!ent assigns value at the nth location -4ZD5. to the first location# (ow the string beco!es [ZDirl\ # (ow the printf state!ent prints the string after each iteration it incre!ents it starting position# 3oop starts fro! D to 1# The first ti!e 7PDQ B 4ZD5 hence it prints nothing and pointer value is incre!ented# The second ti!e it prints fro! 7PAQ i#e [irl\ and the third ti!e it prints [rl\ and the last ti!e it prints [l\ and the loop ter!inates# >1. int i"@X for-iBDXiSBADXi==. ] @=B>X assert-iS>.X ^ Ans)er0 *unti!e error: Abnor!al progra! ter!ination# >F
Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

assert failed -iS>." Sfile na!eR"Sline nu!berR 12p3anati n0 asserts are used during debugging to !a$e sure that certain conditions are satisfied# If assertion fails" the progra! will ter!inate reporting the sa!e# After debugging use" Yundef (D6+?) and this will disable all the assertions fro! the source code# Assertion is a good debugging tool to !a$e use of# >>. !ain-. ] int iB;AX =iX printf-Oi B Wd" =i B Wd ZnO"i"=i.X ^ Ans)er0 i B ;A" =i B ;A 12p3anati n0 ?nary = is the only du!!y operator in C# Ihere;ever it co!es you can @ust ignore it @ust because it has no effect in the e7pressions -hence the na!e du!!y operator.#
>G Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

>C. Ihat are the files which are auto!atically opened when a C file is e7ecuted` Ans)er0 stdin" stdout" stderr -standard input"standard output"standard error.# >E. what will be the position of the file !ar$er` a: fsee$-ptr"D"S66_NS6T.X b: fsee$-ptr"D"S66_NC?*.X Ans)er 0 a: The S66_NS6T sets the file position !ar$er to the starting of the file# b: The S66_NC?* sets the file position !ar$er to the current position of the file# >F. !ain-. ] char na!ePADQ"sPA2QX scanf-O ZOWP9ZOQZOO"s.X ^ /ow scanf will e7ecute` Ans)er0 First it chec$s for the leading white space and discards it#Then it !atches with a 2uotation !ar$ and then it reads all character upto another 2uotation !ar$# CD
Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

>G. Ihat is the proble! with the following code seg!ent` while --fgets-receiving array">D"fileNptr.. !B 6%F. X Ans)er 4 12p3anati n0 fgets returns a pointer# So the correct end of file chec$ is chec$ing for !B (?33# CD. !ain-. ] !ain-.X ^ Ans)er0 *unti!e error : Stac$ overflow# 12p3anati n0 !ain function calls itself again and again# 6ach ti!e the function is called its return address is stored in the call stac$# Since there is no condition to ter!inate the function call" the call stac$ overflows at runti!e# So it ter!inates the progra! and results in an error# CA. !ain-. ] char <cptr"cX CA
Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

void <vptr"vX cBADX vBDX cptrBUcX vptrBUvX printf-OWcWvO"c"v.X ^ Ans)er0 Co!piler error -at line nu!ber 1.: si e of v is ?n$nown# 12p3anati n0 Kou can create a variable of type void < but not of type void" since void is an e!pty type# In the second line you are creating variable vptr of type void < and v of type void hence an error# C2. !ain-. ] char <strABOabcdOX char str2PQBOabcdOX printf-OWd Wd WdO"si eof-strA."si eof-str2."si eof-OabcdO..X ^ Ans)er0 2>> 12p3anati n0 In first si eof" strA is a character pointer so it gives you the si e of the pointer variable# In second si eof the na!e str2 indicates the C2
Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

na!e of the array whose si e is > -including the TZDT ter!ination character.# The third si eof is si!ilar to the second one# C&. !ain-. ] char notX notB!2X printf-OWdO"not.X ^ Ans)er0 D 12p3anati n0 ! is a logical operator# In C the value D is considered to be the boolean value FA3S6" and any non; ero value is considered to be the boolean value T*?6# /ere 2 is a non; ero value so T*?6# !T*?6 is FA3S6 -D. so it prints D# C1. Ydefine FA3S6 ;A Ydefine T*?6 A Ydefine (?33 D !ain-. ] if-(?33. puts-O(?33O.X else if-FA3S6. puts-OT*?6O.X C&
Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

else puts-OFA3S6O.X ^ Ans)er0 T*?6 12p3anati n: The input progra! to the co!piler after processing by the preprocessor is" !ain-.] if-D. puts-O(?33O.X else if-;A. puts-OT*?6O.X else puts-OFA3S6O.X ^ 8reprocessor doesnTt replace the values given inside the double 2uotes# The chec$ by if condition is boolean value false so it goes to else# In second if ;A is boolean value true hence OT*?6O is printed# C>. !ain-. ] int $BAX printf-OWdBBA OOWsO"$"$BBA`OT*?6O:OFA3S6O.X ^ C1
Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

is

Technical Aptitude Questions

Ans)er0 ABBA is T*?6 12p3anati n0 Ihen two strings are placed together -or separated by white;space. they are concatenated -this is called as Ostringi ationO operation.# So the string is as if it is given as OWdBBA is WsO# The conditional operator- `: . evaluates to OT*?6O# CC. !ain-. ] int yX scanf-OWdO"Uy.X MM input given is 2DDD if- -yW1BBD UU yWADD !B D. VV yWADD BB D . printf-OWd is a leap yearO.X else printf-OWd is not a leap yearO.X ^ Ans)er0 2DDD is a leap year 12p3anati n0 An ordinary progra! to chec$ if leap year or not# CE.
C>

Ydefine !a7 > Ydefine int arrAP!a7Q !ain-.

Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

] typedef char arr2P!a7QX arrA listB]D"A"2"&"1^X arr2 na!eBOna!eOX printf-OWd WsO"listPDQ"na!e.X ^ Ans)er0 Co!piler error -in the line arrA list B ]D"A"2"&"1^. 12p3anati n0 arr2 is declared of type array of si e > of characters# So it can be used to declare the variable na!e of the type arr2# +ut it is not the case of arrA# /ence an error# Rule of Thumb: Ydefines are used for te7tual replace!ent whereas typedefs are used for declaring new types# CF. int iBADX !ain-. ] e7tern int iX ] int iB2DX ] const volatile unsigned iB&DX printf-OWdO"i.X CC
Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

^ printf-OWdO"i.X ^ printf-OWdO"i.X ^ Ans)er0 &D"2D"AD 12p3anati n0 T]T introduces new bloc$ and thus new scope# In the inner!ost bloc$ i is declared as" const volatile unsigned which is a valid declaration# i is assu!ed of type int# So printf prints &D# In the ne7t bloc$" i has value 2D and so printf prints 2D# In the outer!ost bloc$" i is declared as e7tern" so no storage space is allocated for it# After co!pilation is over the lin$er resolves it to global variable i -since it is the only variable visible there.# So it prints iTs value as AD# CG. !ain-. ] int <@X ] int iBADX @BUiX CE
Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

^ printf-OWdO"<@.X ^ Ans)er0 AD 12p3anati n: The variable i is a bloc$ level variable and the visibility is inside that bloc$ only# +ut the lifeti!e of i is lifeti!e of the function so it lives upto the e7it of !ain function# Since the i is still allocated space" <@ prints the value stored in i since @ points i# ED. !ain-. ] int iB;AX ;iX printf-Oi B Wd" ;i B Wd ZnO"i";i.X ^ Ans)er0 i B ;A" ;i B A 12p3anati n0 ;i is e7ecuted and this e7ecution doesnTt affect the value of i# In printf first you @ust print the value of i# After that the value of the e7pression ;i B ;-;A. is printed# EA. YincludeSstdio#hR CF
Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

!ain-. ] const int iB1X float @X @ B ==iX printf-OWd WfO" i"==@.X ^ Ans)er: Co!piler error 12p3anati n: i is a constant# you cannot change the value of constant E2. YincludeSstdio#hR !ain-. ] int aP2QP2QP2Q B ] ]AD"2"&"1^" ]>"C"E"F^ ^X int <p"<2X pBUaP2QP2QP2QX <2B<<<aX printf-OWd##WdO"<p"<2.X ^ Ans)er0 garbagevalue##A 12p3anati n0 pBUaP2QP2QP2Q you declare only two 2D arrays# but you are trying to access the third 2D-which you are not declared. it will print CG
Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

garbage values# <2B<<<a starting address of a is assigned integer pointer# now 2 is pointing to starting address of a#if you print <2 !eAnswer:it will print first ele!ent of &D array# E&. YincludeSstdio#hR !ain-. ] register iB>X char @PQB OhelloOX printf-OWs WdO"@"i.X ^ Ans)er0 hello > 12p3anati n: if you declare i as register co!piler will treat it as ordinary integer and it will ta$e integer value# i value !ay be stored either in register or in !e!ory# E1. !ain-. ] int iB>"@BC" X printf-OWdO"i===@.X ^ Ans)er0 AA ED
Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

12p3anati n0 the e7pression i===@ is treated as -i== = @. EC. struct aaa] struct aaa <prevX int iX struct aaa <ne7tX ^X !ain-. ] struct aaa abc"def"ghi"@$lX int 7BADDX abc#iBDXabc#prevBU@$lX abc#ne7tBUdefX def#iBAXdef#prevBUabcXdef#ne7tBUghiX ghi#iB2Xghi#prevBUdefX ghi#ne7tBU@$lX @$l#iB&X@$l#prevBUghiX@$l#ne7tBUabcX 7Babc#ne7t;Rne7t;Rprev;Rne7t;RiX printf-OWdO"7.X ^ Ans)er0 2 12p3anati n0 above all state!ents for! a double circular lin$ed listX abc#ne7t;Rne7t;Rprev;Rne7t;Ri
EA Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

this one points to OghiO node the value of at particular node is 2# EE. struct point ] int 7X int yX ^X struct point origin"<ppX !ain-. ] ppBUoriginX printf-Oorigin is-WdWd.ZnO"-<pp.#7"-<pp.#y.X printf-Oorigin is -WdWd.ZnO"pp;R7"pp;Ry.X ^ Ans)er0 origin is-D"D. origin is-D"D. 12p3anati n: pp is a pointer to structure# we can access the ele!ents of the structure either with arrow !ar$ or with indirection operator# 'ote: Since structure point is globally declared 7 U y are initiali ed as eroes EF. !ain-. E2
Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

] int iBNlNabc-AD.X printf-OWdZnO";;i.X ^ int NlNabc-int i. ] return-i==.X ^ Ans)er0 G 12p3anati n0 return-i==. it will first return i and then incre!ents# i#e# AD will be returned# EG. !ain-. ] char <pX int <2X long <rX pB2BrBDX p==X 2==X r==X printf-OWp###Wp###WpO"p"2"r.X ^ Ans)er0 DDDA###DDD2###DDD1 12p3anati n0 E&
Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

== operator when applied to pointers incre!ents address according to their corresponding data;types# FD. !ain-. ] char cBT T"7"convert- .X getc-c.X if--cRBTaT. UU -cSBT T.. 7Bconvert-c.X printf-OWcO"7.X ^ convert- . ] return ;&2X ^ Ans)er0 Co!piler error 12p3anati n0 declaration of convert and for!at of getc-. are wrong# FA. !ain-int argc" char <<argv. ] printf-Oenter the characterO.X getchar-.X su!-argvPAQ"argvP2Q.X ^ E1
Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

su!-nu!A"nu!2. int nu!A"nu!2X ] return nu!A=nu!2X ^ Ans)er0 Co!piler error# 12p3anati n0 argvPAQ U argvP2Q are strings# They are passed to the function su! without converting it to integer values# F2. Y include Sstdio#hR int oneNdPQB]A"2"&^X !ain-. ] int <ptrX ptrBoneNdX ptr=B&X printf-OWdO"<ptr.X ^ Ans)er: garbage value 12p3anati n0 ptr pointer is pointing to out of the array range of oneNd# F&. Y includeSstdio#hR E>
Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

aaa-. ] printf-OhiO.X ^ bbb-.] printf-OhelloO.X ^ ccc-.] printf-ObyeO.X ^ !ain-. ] int -<ptrP&Q.-.X ptrPDQBaaaX ptrPAQBbbbX ptrP2QBcccX ptrP2Q-.X ^ Ans)er: bye 12p3anati n0 ptr is array of pointers to functions of return type int#ptrPDQ is assigned to address of the function aaa# Si!ilarly ptrPAQ and ptrP2Q for bbb and ccc respectively# ptrP2Q-. is in effect of writing ccc-." since ptrP2Q points to ccc# F>. YincludeSstdio#hR !ain-. EC
Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

] FI36 <ptrX char iX ptrBfopen-O #cO"OrO.X while--iBfgetch-ptr..!B6%F. printf-OWcO"i.X ^ Ans)er0 contents of #c followed by an infinite loop 12p3anati n0 The condition is chec$ed against 6%F" it should be chec$ed against (?33# FC. !ain-. ] int i BDX@BDX if-i UU @==. printf-OWd##WdO"i=="@.X printf-OWd##Wd"i"@.X ^ Ans)er0 D##D 12p3anati n0 The value of i is D# Since this infor!ation is enough to deter!ine the truth value of the boolean e7pression# So the state!ent following the if state!ent is not e7ecuted# EE
Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

The values of i and @ re!ain unchanged and get printed# FE. !ain-. ] int iX i B abc-.X printf-OWdO"i.X ^ abc-. ] NAJ B ADDDX ^ Ans)er0 ADDD 12p3anati n0 (or!ally the return value fro! the function is through the infor!ation fro! the accu!ulator# /ere NA/ is the pseudo global variable denoting the accu!ulator# /ence" the value of the accu!ulator is set ADDD so the function returns value ADDD# FF. int iX !ain-.] int tX for - tB1Xscanf-OWdO"Ui.;tXprintf-OWdZnO"i.. printf-OWd;;O"t;;.X EF
Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

^ MM If the inputs are D"A"2"& find the oMp Ans)er0 1;;D &;;A 2;;2 12p3anati n0 3et us assu!e so!e 7B scanf-OWdO"Ui.;t the values during e7ecution will be" t i 7 1 D ;1 & A ;2 2 2 D FG. !ain-.] int aB DXint b B 2DXchar 7 BAXchar y BADX if-a"b"7"y. printf-OhelloO.X ^ Ans)er0 hello 12p3anati n0 The co!!a operator has associativity fro! left to right# %nly the right!ost value is returned and the other values are evaluated and ignored# Thus the value of last variable y is returned to chec$ in if# Since it is a non EG
Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

ero value if beco!es true so" OhelloO will be printed# GD. !ain-.] unsigned int iX for-iBAXiR;2Xi;;. printf-Oc aptitudeO.X ^ 12p3anati n0 i is an unsigned integer# It is co!pared with a signed value# Since the both types doesnTt !atch" signed is pro!oted to unsigned value# The unsigned e2uivalent of ;2 is a huge value so condition beco!es false and control co!es out of the loop# GA. In the following pg! add a st!t in the function fun such that the address of TaT gets stored in T@T# !ain-.] int < @X void fun-int <<.X fun-U@.X ^ void fun-int <<$. ] int a BDX M< add a st!t here<M ^ FD
Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

Ans)er0 <$ B Ua 12p3anati n0 The argu!ent of the function is a pointer to a pointer# G2. Ihat are the following notations of defining functions $nown as` i# int abc-int a"float b. ] M< so!e code <M ^ ii# int abc-a"b. int aX float bX ] M< so!e code<M ^ Ans)er0 i# A(SI C notation ii# _ernighan U *itche notation G&. !ain-. ] char <pX pBOWdZnOX p==X p==X printf-p;2"&DD.X FA
Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

^ Ans)er0 &DD 12p3anati n0 The pointer points to W since it is incre!ented twice and again decre!ented by 2" it points to TWdZnT and &DD is printed# G1. !ain-.] char aPADDQX aPDQBTaTXaPAQQBTbTXaP2QBTcTXaP1QBTdTX abc-a.X ^ abc-char aPQ.] a==X printf-OWcO"<a.X a==X printf-OWcO"<a.X ^ 12p3anati n0 The base address is !odified only in function and as a result a points to TbT then after incre!enting to TcT so bc will be printed# G>. func-a"b. int a"bX ] F2
Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

return- aB -aBBb. .X ^ !ain-. ] int process-."func-.X printf-OThe value of process is Wd !Zn O"process-func"&"C..X ^ process-pf"valA"val2. int -<pf. -.X int valA"val2X ] return--<pf. -valA"val2..X ^ Ans)er0 The value if process is D ! 12p3anati n0 The function TprocessT has & para!eters ; A" a pointer to another function 2 and &" integers# Ihen this function is invo$ed fro! !ain" the following substitutions for for!al para!eters ta$e place: func for pf" & for valA and C for val2# This function returns the result of the operation perfor!ed by the function TfuncT# The function func has two integer para!eters# The for!al para!eters are substituted as & for a and C for b# since & is not e2ual to C" aBBb returns D# therefore F&
Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

the function returns D which in turn is returned by the function TprocessT# GC. void !ain-. ] static int iB>X if-;;i.] !ain-.X printf-OWd O"i.X ^ ^ Ans)er0 DDDD 12p3anati n0 The variable OIO is declared as static" hence !e!ory for I will be allocated for only once" as it encounters the state!ent# The function !ain-. will be called recursively unless I beco!es e2ual to D" and since !ain-. is recursively called" so the value of static I ie#" D will be printed every ti!e the control is returned# GE. void !ain-. ] int $Bret-si eof-float..X printf-OZn here value is WdO"==$.X ^ int ret-int ret. F1
Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

] ret =B 2#>X return-ret.X ^ Ans)er0 /ere value is E 12p3anati n0 The int ret-int ret." ie#" the function na!e and the argu!ent na!e can be the sa!e# Firstly" the function ret-. is called in which the si eof-float. ie#" 1 is passed" after the first e7pression the value in ret will be C" as ret is integer hence the value stored in ret will have i!plicit type conversion fro! float to int# The ret is returned in !ain-. it is printed after and preincre!ent# GF. void !ain-. ] char aPQBOA2&1>ZDOX int iBstrlen-a.X printf-Ohere in & WdZnO"==i.X ^ Ans)er0 here in & C 12p3anati n0 The char array TaT will hold the initiali ed string" whose length will be counted fro! D till F>
Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

the null character# /ence the TIT will hold the value e2ual to >" after the pre;incre!ent in the printf state!ent" the C will be printed# GG. void !ain-. ] unsigned giveitB;AX int gotitX printf-OWu O"==giveit.X printf-OWu ZnO"gotitB;;giveit.X ^ Ans)er0 D C>>&> 12p3anati n0 ADD. ] void !ain-. int iX char aPQBOZDOX if-printf-OWsZnO"a.. printf-O%$ here ZnO.X else printf-OForget itZnO.X ^ Ans)er0 %$ here 12p3anati n0
FC Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

8rintf will return how !any characters does it print# /ence printing a null character returns A which !a$es the if state!ent true" thus O%$ hereO is printed# ADA. ] void !ain-. void <vX int integerB2X int <iBUintegerX vBiX printf-OWdO"-int<.<v.X ^ Ans)er0 Co!piler 6rror# Ie cannot apply indirection on type void<# 12p3anati n0 0oid pointer is a generic pointer type# (o pointer arith!etic can be done on it# 0oid pointers are nor!ally used for" A# 8assing generic pointers to functions and returning such pointers# 2# As a inter!ediate pointer type# &# ?sed when the e7act pointer type will be $nown at a later point of ti!e# AD2. FE void !ain-.

Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

] int iBi=="@B@=="$B$==X printf-[WdWdWd\"i"@"$.X ^ Ans)er0 )arbage values# 12p3anati n0 6n identifier is availa.le to use in program code from the point of its declaration. So e7pressions such as i B i== are valid state!ents# The i" @ and $ are auto!atic variables and so they contain so!e garbage value# =ar.age in is gar.age out 2=+=E4# AD&. ] void !ain-. static int iBi==" @B@==" $B$==X printf-[i B Wd @ B Wd $ B Wd\" i" @" $.X ^ Ans)er0 iBA@BA$BA 12p3anati n0 Since static variables are initiali ed to ero by default# AD1. ] FF void !ain-.

Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

while-A.] if-printf-OWdO"printf-OWdO... brea$X else continueX ^ ^ Ans)er0 )arbage values 12p3anati n0 The inner printf e7ecutes first to print so!e garbage value# The printf returns no of characters printed and this value also cannot be predicted# Still the outer printf prints so!ething and so returns a non; ero value# So it encounters the brea$ state!ent and co!es out of the while state!ent# AD1. ] !ain-. unsigned int iBADX while-i;;RBD. printf-OWu O"i.X ^ Ans)er0 AD G F E C > 1 & 2 A D C>>&> C>>&1L## 12p3anati n0

FG

Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

Since i is an unsigned integer it can never beco!e negative# So the e7pression i;; RBD will always be true" leading to an infinite loop# AD>. YincludeSconio#hR !ain-. ] int 7"yB2" "aX if-7ByW2. B2X aB2X printf-OWd Wd O" "7.X ^ Ans)er0 )arbage;value D 12p3anati n0 The value of yW2 is D# This value is assigned to 7# The condition reduces to if -7. or in other words if-D. and so goes uninitiali ed# 56u(7 "u3e0 ,hec$ all control paths to write bug free code# ADC. ] ^ !ain-. int aPADQX printf-OWdO"<a=A;<a=&.X
GD Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

Ans)er0 1 12p3anati n0 <a and ;<a cancels out# The result is as si!ple as A = & B 1 ! ADE. Ydefine prod-a"b. a<b !ain-. ] int 7B&"yB1X printf-OWdO"prod-7=2"y;A..X ^ Ans)er0 AD 12p3anati n0 The !acro e7pands and evaluates to as: 7=2<y;A BR 7=-2<y.;A BR AD ADF. ] !ain-. unsigned int iBC>DDDX while-i==!BD.X printf-OWdO"i.X ^ Ans)er0 A 12p3anati n0
GA Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

(ote the se!icolon after the while state!ent# Ihen the value of i beco!es D it co!es out of while loop# Due to post; incre!ent on i the value of i while printing is A# ADG. ] !ain-. int iBDX while-=-=i;;.!BD. i;Bi==X printf-OWdO"i.X ^ Ans)er0 ;A 12p3anati n0 Qnary 8 is the only dummy operator in ,# So it has no effect on the e7pression and now the while loop is" while-i;;!BD. which is false and so brea$s out of while loop# The value ,A is printed due to the post; decre!ent operator# AA&. ] !ain-. float fB>"gBADX enu!]iBAD"@B2D"$B>D^X printf-OWdZnO"==$.X

G2

Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

printf-OWfZnO"fSS2.X printf-OWlfZnO"fWg.X printf-OWlfZnO"f!od-f"g..X ^ Ans)er0 3ine no >: 6rror: 3value re2uired 3ine no C: Cannot apply leftshift to float 3ine no E: Cannot apply !od to float 12p3anati n0 6nu!eration constants cannot be !odified" so you cannot apply ==# +it;wise operators and W operators cannot be applied on float values# f!od-. is to find the !odulus values for floats as W operator is for ints# AAD. ] !ain-. int iBADX void pascal f-int"int"int.X f-i=="i=="i==.X printf-O WdO"i.X ^ void pascal f-integer :i"integer:@"integer :$. ] write-i"@"$.X ^ Ans)er0

G&

Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

Co!piler error: un$nown type integer Co!piler error: undeclared function write 12p3anati n0 8ascal $eyword doesn5t !ean that pascal code can be used# It !eans that the function follows 8ascal argu!ent passing !echanis! in calling the functions# AAA. ] void pascal f-int i"int @"int $. printf-[Wd Wd Wd\"i" @" $.X ^ void cdecl f-int i"int @"int $. ] printf-[Wd Wd Wd\"i" @" $.X ^ !ain-. ] int iBADX f-i=="i=="i==.X printf-O WdZnO"i.X iBADX f-i=="i=="i==.X printf-O WdO"i.X ^ Ans)er0 AD AA A2 A& A2 AA AD A&

G1

Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

12p3anati n0 8ascal argu!ent passing !echanis! forces the argu!ents to be called fro! left to right# cdecl is the nor!al C argu!ent passing !echanis! where the argu!ents are passed fro! right to left# AA2.# Ihat is the output of the progra! given below !ain-. ] signed char iBDX for-XiRBDXi==. X printf-OWdZnO"i.X ^ Ans)er ;A2F 12p3anati n (otice the se!icolon at the end of the for loop# T/e initial value of the i is set to D# The inner loop e7ecutes to incre!ent the value fro! D to A2E -the positive range of char. and then it rotates to the negative value of ;A2F# The condition in the for loop fails and so co!es out of the for loop# It prints the current value of i that is ;A2F#
G> Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

AA&. !ain-. ] unsigned char iBDX for-XiRBDXi==. X printf-OWdZnO"i.X ^ Ans)er infinite loop 12p3anati n The difference between the previous 2uestion and this one is that the char is declared to be unsigned# So the i== can never yield negative value and iRBD never beco!es false so that it can co!e out of the for loop# AA1. !ain-. ] char iBDX for-XiRBDXi==. X printf-OWdZnO"i.X ^ Ans)er0 +ehavior is i!ple!entation dependent# 12p3anati n0 The detail if the char is signedMunsigned by default is i!ple!entation dependent# If the i!ple!entation treats the char to be

GC

Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

signed by default the progra! will print , A2F and ter!inate# %n the other hand if it considers char to be unsigned by default" it goes to infinite loop# Rule: Kou can write progra!s that have i!ple!entation dependent behavior# +ut dont write progra!s that depend on such behavior# AA>. Is the following state!ent a declarationMdefinition# Find what does it !ean` int -<7.PADQX Ans)er Definition# 7 is a pointer to array of-si e AD. integers# Apply cloc$;wise rule to find the !eaning of this definition# AAC.# Ihat is the output for the progra! given below typedef enu! errorType]warning" error" e7ception"^errorX !ain-.

GE

Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

] error gAX gABAX printf-OWdO"gA.X ^ Ans)er Co!piler error: 'ultiple declaration for error 12p3anati n The na!e error is used in the two !eanings# %ne !eans that it is a enu!erator constant with value A# The another use is that it is a type na!e -due to typedef. for enu! errorType# )iven a situation the co!piler cannot distinguish the !eaning of error to $now in what sense the error is used: error gAX gABerrorX MM which error it refers in each case` Ihen the co!piler can distinguish between usages then it will not issue error -in pure technical ter!s" na!es can only be overloaded in different na!espaces.# N te: the e7tra co!!a in the declaration" enu! errorType]warning" error" e7ception"^

GF

Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

is not an error# An e7tra co!!a is valid and is provided @ust for progra!!er5s convenience# AAE. typedef struct error]int warning" error" e7ceptionX^errorX !ain-. ] error gAX gA#error BAX printf-OWdO"gA#error.X ^ Ans)er A 12p3anati n The three usages of na!e errors can be distinguishable by the co!piler at any instance" so valid -they are in different na!espaces.# Typedef struct error]int warning" error" e7ceptionX^errorX This error can be used only by preceding the error by struct $ayword as in: struct error so!e6rrorX typedef struct error]int warning" error" e7ceptionX^errorX
GG Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

This can be used only after # -dot. or ;R -arrow. operator preceded by the variable na!e as in : gA#error BAX printf-OWdO"gA#error.X typedef struct error]int warning" error" e7ceptionX^errorX This can be used to define variables without using the preceding struct $eyword as in: error gAX Since the co!piler can perfectly distinguish between these three usages" it is perfectly legal and valid# 'ote This code is given here to @ust e7plain the concept behind# In real progra!!ing don5t use such overloading of na!es# It reduces the readability of the code# 8ossible doesn5t !ean that we should use it! AAF. Yifdef so!ething int so!eBDX Yendif !ain-. ] int thing B DX printf-OWd WdZnO" so!e "thing.X

ADD

Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

^ Ans)er0 Co!piler error : undefined sy!bol so!e 12p3anati n0 This is a very si!ple e7a!ple for conditional co!pilation# The na!e so!ething is not already $nown to the co!piler !a$ing the declaration int so!e B DX effectively re!oved fro! the source code# AAG. Yif so!ething BB D int so!eBDX Yendif !ain-. ] int thing B DX printf-OWd WdZnO" so!e "thing.X ^ Ans)er DD 12p3anati n
ADA Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

This code is to show that preprocessor e7pressions are not the sa!e as the ordinary e7pressions# If a na!e is not $nown the preprocessor treats it to be e2ual to ero# A2D.# Ihat is the output for the following progra! !ain-. ] int arr2DP&QP&QX printf-OWdZnO" --arr2DBB< arr2D.UU-< arr2D BB arr2DPDQ.. .X ^ Ans)er A 12p3anati n This is due to the close relation between the arrays and pointers# ( di!ensional arrays are !ade up of -(;A. di!ensional arrays# arr2D is !ade up of a & single arrays that contains & integers each #
arr2D arr2DPAQ arr2DP2Q
AD2 Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions arr2DP&Q

The na!e arr2D refers to the beginning of all the & arrays# <arr2D refers to the start of the first AD array -of & integers. that is the sa!e address as arr2D# So the e7pression -arr2D BB <arr2D. is true -A.# Si!ilarly" <arr2D is nothing but <-arr2D = D." adding a ero doesn5t change the valueM!eaning# Again arr2DPDQ is the another way of telling <-arr2D = D.# So the e7pression -<-arr2D = D. BB arr2DPDQ. is true -A.# Since both parts of the e7pression evaluates to true the result is true-A. and the sa!e is printed# A2A. void !ain-. ] if-aD BB -unsigned int.;A. printf-[Kou can answer this if you $now how values are represented in !e!ory\.X ^ Answer
AD& Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

Kou can answer this if you $now how values are represented in !e!ory 67planation a -tilde operator or bit;wise negation operator. operates on D to produce all ones to fill the space for an integer# ,A is represented in unsigned value as all A5s and so both are e2ual# A22. int swap-int <a"int <b. ] <aB<a=<bX<bB<a;<bX<aB<a;<bX ^ !ain-. ] int 7BAD"yB2DX swap-U7"Uy.X printf-O7B Wd y B WdZnO"7"y.X ^ Answer 7 B 2D y B AD 67planation This is one way of swapping two values# Si!ple chec$ing will help understand this# A2&. !ain-. ] char <p B [ay2!\X

AD1

Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

printf-[Wc\"==<-p==..X ^ Answer: b A21. ] !ain-. int iB>X printf-OWdO"==i==.X ^ Ans)er0 Co!piler error: 3value re2uired in function !ain 12p3anati n0 ==i yields an rvalue# For postfi7 == to operate an lvalue is re2uired# A2>. ] !ain-. char <p B [ay2!\X char cX c B ==<p==X printf-[Wc\"c.X ^ Ans)er0 b 12p3anati n0
AD> Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

There is no difference between the e7pression ==<-p==. and ==<p==# 8arenthesis @ust wor$s as a visual clue for the reader to see which e7pression is first evaluated# A2C. int aaa-. ]printf-[/i\.X^ int bbb-.]printf-[hello\.X^ iny ccc-.]printf-[bye\.X^ !ain-. ] int - < ptrP&Q. -.X ptrPDQ B aaaX ptrPAQ B bbbX ptrP2Q BcccX ptrP2Q-.X ^ Answer: b%e 67planation: int -< ptrP&Q.-. says that ptr is an array of pointers to functions that ta$es no argu!ents and returns the type int# +y the assign!ent ptrPDQ B aaaX it !eans that the first function pointer in the array is initiali ed with the address of the function aaa# Si!ilarly" the

ADC

Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

other two array ele!ents also get initiali ed with the addresses of the functions bbb and ccc# Since ptrP2Q contains the address of the function ccc" the call to the function ptrP2Q-. is sa!e as calling ccc-.# So it results in printing ObyeO# A2E. !ain-. ] int iB>X printf-[Wd\"iB==i BBC.X ^ Ans)er0 1 12p3anati n0 The e7pression can be treated as i B -= =iBBC." because BB is of higher precedence than B operator# In the inner e7pression" ==i is e2ual to C yielding true-A.# /ence the result# A2F. ] !ain-. char pP QBOWdZnOX pPAQ B TcTX printf-p"C>.X

ADE

Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

^ Ans)er0 A 12p3anati n0 Due to the assign!ent pPAQ B 4c5 the string beco!es" [WcZn\# Since this string beco!es the for!at string for printf and ASCII value of C> is 4A5" the sa!e gets printed# A2G. void - < abc- int" void - <def. -. . . -.X

Answer:: abc is a ptr to a function which ta$es 2 para!eters #-a.# an integer variable#-b.# a ptrto a funtion which returns void# the return type of the function is void# 12p3anati n0 Apply the cloc$;wise rule to find the result# A&D. !ain-. ] while -strc!p-[so!e\"\so!eZD\.. printf-[Strings are not e2ualZn\.X ^ Ans)er0 (o output 12p3anati n0 ADF
Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

6nding the string constant with ZD e7plicitly !a$es no difference# So [so!e\ and [so!eZD\ are e2uivalent# So" strc!p returns D -false. hence brea$ing out of the while loop# A&A. ] !ain-. char strAPQ B ]4s5"5o5"5!5"5e5^X char str2PQ B ]4s5"5o5"5!5"5e5"5ZD5^X while -strc!p-strA"str2.. printf-[Strings are not e2ualZn\.X ^ Ans)er0 [Strings are not e2ual\ [Strings are not e2ual\ L# 12p3anati n0 If a string constant is initiali ed e7plicitly with characters" 4ZD5 is not appended auto!atically to the string# Since strA doesn5t have null ter!ination" it treats whatever the values that are in the following positions as part of the string until it rando!ly reaches a 4ZD5# So strA and str2 are not the sa!e" hence the result# A&2. ADG !ain-.

Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

] int i B &X for -Xi==BDX. printf-[Wd\"i.X ^ Ans)er0 Co!piler 6rror: 3value re2uired# 12p3anati n0 As we $now that incre!ent operators return rvalues and hence it cannot appear on the left hand side of an assign!ent operation# A&&. ] void !ain-. int <!ptr" <cptrX !ptr B -int<.!alloc-si eof-int..X printf-[Wd\"<!ptr.X int <cptr B -int<.calloc-si eof-int."A.X printf-[Wd\"<cptr.X ^ Ans)er0 garbage;value D 12p3anati n0 The !e!ory space allocated by !alloc is uninitiali ed" whereas calloc returns the allocated !e!ory space initiali ed to eros#
AAD Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

A&1. ]

void !ain-. static int iX while-iSBAD. -iR2.`i==:i;;X printf-[Wd\" i.X

^ Ans)er0 &2ECE 12p3anati n0 Since i is static it is initiali ed to D# Inside the while loop the conditional operator evaluates to false" e7ecuting i;;# This continues till the integer value rotates to positive value -&2ECE.# The while condition beco!es false and hence" co!es out of the while loop" printing the i value# A&>. ] !ain-. int iBAD"@B2DX @ B i" @`-i"@.`i:@:@X printf-OWd WdO"i"@.X ^ Ans)er0 AD AD 12p3anati n0

AAA

Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

The Ternary operator - ` : . is e2uivalent for if;then;else state!ent# So the 2uestion can be written as: if-i"@. ] if-i"@. @ B iX else @ B @X ^ else @ B @X A&C. A# const char <aX 2# char< const aX &# char const <aX ;Differentiate the above declarations# Ans)er0 A# TconstT applies to char < rather than TaT - pointer to a constant char . <aBTFT : illegal aBO/iO : legal 2# TconstT applies to TaT rather than to the value of a -constant pointer to char . <aBTFT : legal

AA2

Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

aBO/iO &# Sa!e as A# A&E. ] !ain-.

: illegal

int iB>"@BADX iBiUB@UUADX printf-OWd WdO"i"@.X ^ Ans)er0 A AD 12p3anati n0 The e7pression can be written as iB-iUB-@UUAD..X The inner e7pression -@UUAD. evaluates to A because @BBAD# i is ># i B >UA is A# /ence the result# A&F. ] !ain-. int iB1"@BEX @ B @ VV i== UU printf-OK%? CA(O.X printf-OWd WdO" i" @.X ^ Ans)er0 1A

AA&

Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

12p3anati n0 Dhe .oolean expression needs to .e evaluated only till the truth value of the expression is not 'nown. @ is not e2ual to ero itself !eans that the e7pression5s truth value is A# +ecause it is followed by VV and true SS 2anything4 IV true where 2anything4 will not .e evaluated. So the re!aining e7pression is not evaluated and so the value of i re!ains the sa!e# Si!ilarly when UU operator is involved in an e7pression" when any of the operands beco!e false" the whole e7pression5s truth value beco!es false and hence the re!aining e7pression will not be evaluated# false (( 2anything4 IV false where 2anything4 will not .e evaluated. A&G. ] !ain-. register int aB2X printf-OAddress of a B WdO"Ua.X printf-O0alue of a B WdO"a.X ^ Ans)er0 Co!pier 6rror: TUT on register variable "u3e t "e(e(7er0
AA1 Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

4 8address 9 : perat r cann t 7e app3ied n re+ister varia73es. A1D. ] !ain-. float iBA#>X switch-i. ] case A: printf-OAO.X case 2: printf-O2O.X default : printf-ODO.X ^ ^ Ans)er0 Co!piler 6rror: switch e7pression not integral 12p3anati n0 $witch statements can .e applied only to integral types. A1A. ] !ain-. e7tern iX printf-OWdZnO"i.X ] int iB2DX printf-OWdZnO"i.X ^

AA>

Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

^ Ans)er0 3in$er 6rror : ?nresolved e7ternal sy!bol i 12p3anati n0 The identifier i is available in the inner bloc$ and so using e7tern has no use in resolving it# A12. ] !ain-. int aB2"<fA"<f2X fABf2BUaX <f2=B<f2=Ba=B2#>X printf-OZnWd Wd WdO"a"<fA"<f2.X ^ Ans)er0 AC AC AC 12p3anati n0 fA and f2 both refer to the sa!e !e!ory location a# So changes through fA and f2 ulti!ately affects only the value of a# A1&. ] !ain-. char <pBO)%%DOX char aP QBO)%%DOX
AAC Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

printf-OZn si eof-p. B Wd" si eof-<p. B Wd" strlen-p. B WdO" si eof-p." si eof-<p." strlen-p..X printf-OZn si eof-a. B Wd" strlen-a. B WdO" si eof-a." strlen-a..X ^ Ans)er0 si eof-p. B 2" si eof-<p. B A" strlen-p. B 1 si eof-a. B >" strlen-a. B 1 12p3anati n0 si eof-p. BR si eof-char<. BR 2 si eof-<p. BR si eof-char. BR A Si!ilarly" si eof-a. BR si e of the character array BR > When siCeof operator is applied to an array it returns the siCeof the array and it is not the sa!e as the si eof the pointer variable# /ere the si eof-a. where a is the character array and the si e of the array is > because the space necessary for the ter!inating (?33 character should also be ta$en into account# A11. Ydefine DI'si eof-array.Msi eof-type. !ain-. ] int arrPADQX AAE array" type.

Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

printf-[The di!ension of the array is Wd\" DI'-arr" int..X ^ Ans)er0 AD 12p3anati n0 The si e of integer array of AD ele!ents is AD < si eof-int.# The !acro e7pands to si eof-arr.Msi eof-int. BR AD < si eof-int. M si eof-int. BR AD# A1>. int DI'-int arrayPQ. ] return si eof-array.Msi eof-int .X ^ !ain-. ] int arrPADQX printf-[The di!ension of the array is Wd\" DI'-arr..X ^ Ans)er0 A 12p3anati n0 6rrays cannot .e passed to functions as arguments and only the pointers can .e passed# So the argu!ent is e2uivalent to int < array -this is one of the very few places AAF
Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

where PQ and < usage are e2uivalent.# The return state!ent beco!es" si eof-int <.M si eof-int. that happens to be e2ual in this case# A1C. ] !ain-. static int aP&QP&QB]A"2"&"1">"C"E"F"G^X int i"@X static <pPQB]a"a=A"a=2^X for-iBDXiS&Xi==. ] for-@BDX@S&X@==. printf-OWdZtWdZtWdZtWdZnO"<-<-p=i.=@." <-<-@=p.=i."<-<-i=p.=@."<-<-p=@.=i..X ^ ^ Ans)er0 A 2 & 1 > C E F G 12p3anati n0 A 1 E 2 > F & C G A 2 & 1 > C E F G A 1 E 2 > F & C G

AAG

Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

<-<-p=i.=@. is e2uivalent to pPiQP@Q# A1E. ] !ain-. void swap-.X int 7BAD"yBFX swap-U7"Uy.X printf-O7BWd yBWdO"7"y.X ^ void swap-int <a" int <b. ] <a 9B <b" <b 9B <a" <a 9B <bX ^ Ans)er0 7BAD yBF 12p3anati n0 ?sing 9 li$e this is a way to swap two variables without using a te!porary variable and that too in a single state!ent# Inside !ain-." void swap-.X !eans that swap is a function that !ay ta$e any nu!ber of argu!ents -not no argu!ents. and returns nothing# So this doesn5t issue a co!piler error by the call swap-U7"Uy.X that has two argu!ents# This convention is historically due to pre; A(SI style -referred to as _ernighan and *itchie style. style of function declaration#

A2D

Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

In that style" the swap function will be defined as follows" void swap-. int <a" int <b ] <a 9B <b" <b 9B <a" <a 9B <bX ^ where the argu!ents follow the -.# So naturally the declaration for swap will loo$ li$e" void swap-. which !eans the swap can ta$e any nu!ber of argu!ents# A1F. ] !ain-.

int i B 2>EX int <i8tr B UiX printf-OWd WdO" <--char<.i8tr." <--char<.i8tr=A. .X ^ Ans)er0 AA 12p3anati n0 The integer value 2>E is stored in the !e!ory as" DDDDDDDA DDDDDDDA" so the individual bytes are ta$en by casting it to char < and get printed# A1G. A2A !ain-.

Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

] int i B 2>FX int <i8tr B UiX printf-OWd WdO" <--char<.i8tr." <--char<.i8tr=A. .X ^ Ans)er0 2A 12p3anati n0 The integer value 2>E can be represented in binary as" DDDDDDDA DDDDDDDA# *e!e!ber that the I(T63 !achines are 4s!all;endian5 !achines# $mall3endian means that the lower order .ytes are stored in the higher memory addresses and the higher order .ytes are stored in lower addresses# The integer value 2>F is stored in !e!ory as: DDDDDDDA DDDDDDAD# A>D. ] !ain-. int iB&DDX char <ptr B UiX <==ptrB2X printf-OWdO"i.X ^ Ans)er0 >>C

A22

Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

12p3anati n0 The integer value &DD in binary notation is: DDDDDDDA DDADAADD# It is stored in !e!ory -s!all;endian. as: DDADAADD DDDDDDDA# *esult of the e7pression <==ptr B 2 !a$es the !e!ory representation as: DDADAADD DDDDDDAD# So the integer corresponding to it is DDDDDDAD DDADAADD BR >>C# A>A. Yinclude Sstdio#hR !ain-. ] char < str B OhelloOX char < ptr B strX char least B A2EX while -<ptr==. least B -<ptrSleast . `<ptr :leastX printf-OWdO"least.X ^ Ans)er0 D 12p3anati n0 After 4ptr5 reaches the end of the string the value pointed by 4str5 is 4ZD5# So the value of 4str5 is less than that of 4least5# So the value of 4least5 finally is D#
A2& Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

A>2. Declare an array of ( pointers to functions returning pointers to functions returning pointers to characters` Ans)er0 -char<-<.- .. -<ptrP(Q.- .X A>&. ] !ain-. struct student ] char na!eP&DQX struct date dobX ^studX struct date ] int day"!onth"yearX ^X scanf-OWsWdWdWdO" stud#rollno" Ustudent#dob#day" Ustudent#dob#!onth" Ustudent#dob#year.X ^ Ans)er0 Co!piler 6rror: ?ndefined structure date 12p3anati n0 Inside the struct definition of 4student5 the !e!ber of type struct date is given# The co!piler doesn5t have the definition of date
A21 Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

structure -forward reference is not allowed in C in this case. so it issues an error# A>1. ] ] char na!eP&DQX struct date dobX ^studX struct date ] int day"!onth"yearX ^X scanf-OWsWdWdWdO" stud#rollno" Ustudent#dob#day" Ustudent#dob#!onth" Ustudent#dob#year.X ^ Ans)er0 Co!piler 6rror: ?ndefined structure date 12p3anati n0 %nly declaration of struct date is available inside the structure definition of 4student5 but to have a variable of type struct date the definition of the structure is re2uired#
A2> Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

!ain-. struct dateX struct student

Technical Aptitude Questions

A>>. There were AD records stored in [so!efile#dat\ but the following progra! printed AA na!es# Ihat went wrong` void !ain-. ] struct student ] char na!eP&DQ" rollnoPCQX ^studX FI36 <fp B fopen-[so!efile#dat\"\r\.X while-!feof-fp.. ] fread-Ustud" si eof-stud." A " fp.X puts-stud#na!e.X ^ ^ 12p3anati n0 fread reads AD records and prints the na!es successfully# It will return 6%F only when fread tries to read another record and fails reading 6%F -and returning 6%F.# So it prints the last record again# After this only the condition feof-fp. beco!es false" hence co!es out of the while loop# A>C. Is there any difference between the two declarations" A2C
Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

A# int foo-int <arrPQ. and 2# int foo-int <arrP2Q. Ans)er0 (o 12p3anati n0 Functions can only pass pointers and not arrays# The nu!bers that are allowed inside the PQ is @ust for !ore readability# So there is no difference between the two declarations# A>E. Ihat is the subtle error in the following code seg!ent` void fun-int n" int arrPQ. ] int <pBDX int iBDX while-i==Sn. p B UarrPiQX <p B DX ^ Ans)er 4 12p3anati n0 If the body of the loop never e7ecutes p is assigned no address# So p re!ains (?33 where <p BD !ay result in proble! -!ay rise to runti!e error [(?33 pointer assign!ent\ and ter!inate the progra!.# A2E
Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

A>F. Ihat is wrong with the following code` int <foo-. ] int <s B !alloc-si eof-int.ADD.X assert-s !B (?33.X return sX ^ Ans)er 4 12p3anati n0 assert !acro should be used for debugging and finding out bugs# The chec$ s !B (?33 is for errorMe7ception handling and for that assert shouldn5t be used# A plain if and the corresponding re!edy state!ent has to be given# A>G. Ihat is the hidden bug with the following state!ent` assert-val== !B D.X Ans)er 4 12p3anati n0 Assert !acro is used for debugging and re!oved in release version# In assert" the e7perssion involves side;effects# So the behavior of the code beco!es different in case of debug version and the release version thus leading to a subtle bug# "u3e t "e(e(7er0
A2F Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

!onFt use expressions that have side3effects in assert statements. ACD. void !ain-. ] int <i B D71DDX MM i points to the address 1DD <i B DX MM set the value of !e!ory location pointed by iX ^ Ans)er0 ?ndefined behavior 12p3anati n0 The second state!ent results in undefined behavior because it points to so!e location whose value !ay not be available for !odification# Dhis type of pointer in which the non3availa.ility of the implementation of the referenced location is 'nown as Wincomplete typeW# ACA. Ydefine assert-cond. if-!-cond.. Z -fprintf-stderr" Oassertion failed: Ws" file Ws" line Wd ZnO"Ycond"Z NNFI36NN"NN3I(6NN." abort-.. void !ain-. ] int i B ADX

A2G

Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

if-iBBD. assert-i S ADD.X else printf-OThis state!ent beco!es else for if in assert !acroO.X ^ Answer: (o output 12p3anati n0 The else part in which the printf is there beco!es the else for if in the assert !acro# /ence nothing is printed# The solution is to use conditional operator instead of if state!ent" Ydefine assert-cond. --cond.`-D.: -fprintf -stderr" Oassertion failed: Z Ws" file Ws" line Wd ZnO"Ycond" NNFI36NN"NN3I(6NN." abort-... (ote: /owever this proble! of [!atching with nearest else\ cannot be solved by the usual !ethod of placing the if state!ent inside a bloc$ li$e this" Ydefine assert-cond. ] Z if-!-cond.. Z -fprintf-stderr" Oassertion failed: Ws" file Ws" line Wd ZnO"Ycond"Z NNFI36NN"NN3I(6NN." abort-.. Z

A&D

Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

^ AC2. Is the following code legal` struct a ] int 7X struct a bX ^ Answer: (o 12p3anati n0 Is it not legal for a structure to contain a !e!ber that is of the sa!e type as in this case# +ecause this will cause the structure declaration to be recursive without end# AC&. Is the following code legal` struct a ] int 7X struct a <bX ^ Ans)er0 Kes# 12p3anati n0 <b is a pointer to type struct a and so is legal# The co!piler $nows" the si e of the A&A
Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

pointer to a structure even before the si e of the structure is deter!ined-as you $now the pointer to any type is of sa!e si e.# This type of structures is $nown as 4self;referencing5 structure# AC1. Is the following code legal` typedef struct a ] int 7X aType <bX ^aType Ans)er0 (o 12p3anati n0 The typena!e aType is not $nown at the point of declaring the structure -forward references are not !ade for typedefs.# AC>. Is the following code legal` typedef struct a aTypeX struct a ] int 7X aType <bX ^X Ans)er0 A&2
Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

Kes 12p3anati n0 The typena!e aType is $nown at the point of declaring the structure" because it is already typedefined# ACC. Is the following code legal` void !ain-. ] typedef struct a aTypeX aType so!e0ariableX struct a ] int 7X aType <bX ^X ^ Ans)er0 (o 12p3anati n0 Ihen the declaration" typedef struct a aTypeX is encountered body of struct a is not $nown# This is $nown as 4inco!plete types5# ACE. void !ain-. ] printf-[si eof -void <. B Wd Zn[" si eof- void <..X A&&
Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

printf-[si eof -int <. B Wd Zn\" si eof-int <..X printf-[si eof -double <. B Wd Zn\" si eof-double <..X printf-[si eof-struct un$nown <. B Wd Zn\" si eof-struct un$nown <..X ^ Ans)er 0 si eof -void <. B 2 si eof -int <. B 2 si eof -double <. B 2 si eof-struct un$nown <. B 2 12p3anati n0 The pointer to any type is of sa!e si e# ACF. char inputStringPADDQ B ]D^X To get string input fro! the $eyboard which one of the following is better` A. gets-inputString. 2. fgets-inputString" si eof-inputString." fp. Ans)er 4 12p3anati n0 The second one is better because gets-inputString. doesnTt $now the si e of the string passed and so" if a very big input -here" !ore than ADD chars. the charactes will be written past the input string# Ihen fgets is used with stdin perfor!s the sa!e operation as gets but is safe#
A&1 Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

ACG. Ihich version do you prefer of the following two" A. printf-[Ws\"str.X MM or the !ore curt one 2. printf-str.X Ans)er 4 12p3anati n0 8refer the first one# If the str contains any for!at characters li$e Wd then it will result in a subtle bug# AED. ] void !ain-. int iBAD" @B2X int <ipB Ui" <@p B U@X int $ B <ipM<@pX printf-[Wd\"$.X ^ Ans)er0 Co!piler 6rror: [?ne7pected end of file in co!!ent started in line >\# 12p3anati n0 The progra!!er intended to divide two integers" but by the [!a7i!u! !unch\ rule" the co!piler treats the operator se2uence M and < as M< which happens to be the starting of co!!ent# To force what is intended by the progra!!er" int $ B <ipM <@pX
A&> Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

MM give space e7plicity separating M and < MMor int $ B <ipM-<@p.X MM put braces to force the intention will solve the proble!# AEA. void !ain-. ] char chX for-chBDXchSBA2EXch==. printf-[Wc Wd Zn[" ch" ch.X ^ Ans)er0 I!ple!entaion dependent 12p3anati n0 The char type !ay be signed or unsigned by default# If it is signed then ch== is e7ecuted after ch reaches A2E and rotates bac$ to ;A2F# Thus ch is always s!aller than A2E# AE2. Is this code legal` int <ptrX ptr B -int <. D71DDX Ans)er0 Kes 12p3anati n0
A&C Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

The pointer ptr will point at the integer in the !e!ory location D71DD# AE&. ] !ain-. char aP1QBO/633%OX printf-OWsO"a.X ^ Ans)er0 Co!piler error: Too !any initiali ers 12p3anati n0 The array a is of si e 1 but the string constant re2uires C bytes to get stored# AE1. ] !ain-. char aP1QBO/633OX printf-OWsO"a.X ^ Ans)er0 /633Wb!ab!b```baa! 12p3anati n0 The character array has the !e!ory @ust enough to hold the string [/633\ and doesnt have enough space to store the ter!inating null character# So it prints the /633 correctly and continues to print
A&E Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

garbage values till it accidentally across a (?33 character# AE>. ] !ain-. int aBAD"<@X void <$X @B$BUaX @==X $==X printf-OZn Wu Wu O"@"$.X

co!es

^ Ans)er0 Co!piler error: Cannot incre!ent a void pointer 12p3anati n0 0oid pointers are generic pointers and they can be used only when the type is not $nown and as an inter!ediate address storage type# (o pointer arith!etic can be done on it and you cannot apply indirection operator -<. on void pointers# AEC. !ain-. ] e7tern int iX ] int iB2DX ]

A&F

Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

const

volatile

unsigned

iB&DX

printf-OWdO"i.X ^ printf-OWdO"i.X ^ printf-OWdO"i.X ^ int iX AEE. 8rintf can be i!ple!ented by using NNNNNNNNNN list# Ans)er0 0ariable length argu!ent lists AEF. char <so!eFun-. ] char <te!p B [string constantOX return te!pX ^ int !ain-. ] puts-so!eFun-..X ^ Answer: string constant 12p3anati n: The progra! suffers no proble! and gives the output correctly because the character constants are
A&G Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

stored in codeMdata area and not allocated in stac$" so this doesn5t lead to dangling pointers# AEG. char <so!eFunA-. ] char te!pP Q B [stringOX return te!pX ^ char <so!eFun2-. ] char te!pP Q B ]4s5" 4t5"5r5"5i5"5n5"5g5^X return te!pX ^ int !ain-. ] puts-so!eFunA-..X puts-so!eFun2-..X ^ Answer: )arbage values# 12p3anati n: +oth the functions suffer fro! the proble! of dangling pointers# In so!eFunA-. te!p is a character array and so the space for it is allocated in heap and is initiali ed with character string [string\# This is created dyna!ically as the function is called" so is also deleted dyna!ically on e7iting the function so the string data is not available in the calling function A1D
Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

!ain-. leading to print so!e garbage values# The function so!eFun2-. also suffers fro! the sa!e proble! but the proble! can be easily identified in this case#

A1A Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

C++ Aptitude and OOPS

C== Aptitude and %%8S (ote : All the progra!s are tested under Turbo C= = &#D" 1#> and 'icrosoft 0C== C#D co!pilers# It is assu!ed that" 8rogra!s run under Iindows environ!ent" The underlying !achine is an 7FC based syste!" 8rogra! is co!piled using Turbo CMC== co!piler# The progra! output !ay depend on the infor!ation based on this assu!ptions -for e7a!ple si eof-int. BB 2 !ay be assu!ed.# A. class Sa!ple ] public: int <ptrX Sa!ple-int i. ]
A12 Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

ptr B new int-i.X ^ aSa!ple-. ] delete ptrX ^ void 8rint0al-. ] cout SS OThe value is O SS <ptrX ^ ^X void So!eFunc-Sa!ple 7. ] cout SS OSay i a! in so!eFunc O SS endlX ^ int !ain-. ] Sa!ple sAB ADX So!eFunc-sA.X sA#8rint0al-.X ^ Ans)er0 Say i a! in so!eFunc (ull pointer assign!ent-*un;ti!e error. 12p3anati n: As the ob@ect is passed by value to So!eFunc the destructor of the ob@ect is called when the control returns fro! the function# So when 8rint0al is called A1&
Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

it !eets up with ptr that has been freed#The solution is to pass the Sa!ple ob@ect by reference to So!eFunc: void So!eFunc-Sa!ple U7. ] cout SS OSay i a! in so!eFunc O SS endlX ^ because when we pass ob@ects by refernece that ob@ect is not destroyed# while returning fro! the function# 2.Ihich is the para!eter that is added to every non; static !e!ber function when it is called` Ans)er0 4this5 pointer &. class base ] public: int bvalX base-.] bvalBDX^ ^X class deri:public base ] public: int dvalX A11
Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

deri-.] dvalBAX^ ^X void So!eFunc-base <arr"int si e. ] for-int iBDX iSsi eX i=="arr==. coutSSarr;RbvalX coutSSendlX ^ int !ain-. ] base +aseArrP>QX So!eFunc-+aseArr">.X deri DeriArrP>QX So!eFunc-DeriArr">.X ^ Ans)er0 DDDDD DADAD 12p3anati n0 The function So!eFunc e7pects two argu!ents#The first one is a pointer to an array of base class ob@ects and the second one is the si eof the array#The first call of so!eFunc calls it with an array of bae ob@ects" so it wor$s correctly and prints the bval of all the ob@ects# Ihen So!efunc is called the second ti!e the argu!ent passed is the pointeer to an A1>
Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

array of derived class ob@ects and not the array of base class ob@ects# +ut that is what the function e7pects to be sent# So the derived class pointer is pro!oted to base class pointer and the address is sent to the function# So!eFunc-. $nows nothing about this and @ust treats the pointer as an array of base class ob@ects# So when arr== is !et" the si e of base class ob@ect is ta$en into consideration and is incre!ented by si eof-int. bytes for bval -the deri class ob@ects have bval and dval as !e!bers and so is of si e RB si eof-int.=si eof-int. .# 1. class base ] public: void baseFun-.] baseOSSendlX^ ^X class deri:public base ] public: void baseFun-.] derivedOSSendlX^ ^X void So!eFunc-base <base%b@. ] base%b@;RbaseFun-.X ^ A1C

coutSSOfro!

coutSS

Ofro!

Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

int !ain-. ] base base%b@ectX So!eFunc-Ubase%b@ect.X deri deri%b@ectX So!eFunc-Uderi%b@ect.X ^ Ans)er0 fro! base fro! base 12p3anati n0 As we have seen in the previous case" So!eFunc e7pects a pointer to a base class# Since a pointer to a derived class ob@ect is passed" it treats the argu!ent only as a base class pointer and the corresponding base function is called# >. class base ] public: virtual void baseFun-.] coutSSOfro! baseOSSendlX^ ^X class deri:public base ] public: void baseFun-.] coutSS Ofro! derivedOSSendlX^ A1E
Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

^X void So!eFunc-base <base%b@. ] base%b@;RbaseFun-.X ^ int !ain-. ] base base%b@ectX So!eFunc-Ubase%b@ect.X deri deri%b@ectX So!eFunc-Uderi%b@ect.X ^ Ans)er0 fro! base fro! derived 12p3anati n0 *e!e!ber that baseFunc is a virtual function# That !eans that it supports run;ti!e poly!orphis!# So the function corresponding to the derived class ob@ect is called# void !ain-. ] int a" <pa" UraX pa B UaX ra B aX cout SSOaBOSSa SSO<paBOSS<pa SSOraOSSra X A1F
Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

^ M< Answer : Co!piler 6rror: TraT"reference !ust be initiali ed 67planation : 8ointers are different fro! references# %ne of the !ain differences is that the pointers can be both initiali ed and assigned" whereas references can only be initiali ed# So this code issues an error# <M const int si e B >X void print-int <ptr. ] coutSSptrPDQX ^ void print-int ptrPsi eQ. ] coutSSptrPDQX ^ void !ain-. ] int aPsi eQ B ]A"2"&"1">^X int <b B new int-si e.X A1G
Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

print-a.X print-b.X ^ M< Answer: Co!piler 6rror : function Tvoid print-int <.T already has a body 67planation: -rr$%s ($nnot be p$sse# to fun(tions& onl% pointers (for $rr$%s& b$se $##resses) ($n be p$sse#. /o the $r0uments int 1ptr $n# int prt2si3e4 h$5e no #ifferen(e $s fun(tion $r0uments. 6n other 7or#s& both the fun(toins h$5e the s$me si0n$ture $n# so ($nnot be o5erlo$#e## <M class so!e] public: aso!e-. ] coutSSOso!eTs destructorOSSendlX ^ ^X void !ain-. ] A>D
Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

so!e sX s#aso!e-.X ^ M< Answer: so!eTs destructor so!eTs destructor 67planation: 8estru(tors ($n be ($lle# expli(itl%. 9ere :s.;some(): expli(itl% ($lls the #estru(tor of :s:. <hen m$in() returns& #estru(tor of s is ($lle# $0$in& hen(e the result. <M Yinclude Siostrea!#hR class fig2d ] int di!AX int di!2X public: fig2d-. ] di!AB>X di!2BCX^ virtual void operatorSS-ostrea! U rhs.X ^X
A>A Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

void fig2d::operatorSS-ostrea! Urhs. ] rhs SSthis;Rdi!ASSO OSSthis;Rdi!2SSO OX ^ M<class fig&d : public fig2d ] int di!&X public: fig&d-. ] di!&BEX^ virtual void operatorSS-ostrea! Urhs.X ^X void fig&d::operatorSS-ostrea! Urhs. ] fig2d::operator SS-rhs.X rhsSSthis;Rdi!&X ^ <M void !ain-. ] fig2d ob@AX MM fig&d ob@2X MM ^ M< A>2 ob@A SS coutX ob@2 SS coutX

Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

Answer : >C 67planation: In this progra!" the SS operator is overloaded with ostrea! as argu!ent# This enables the TcoutT to be present at the right;hand; side# (or!ally" TcoutT is i!ple!ented as global function" but it doesnTt !ean that TcoutT is not possible to be overloaded as !e!ber function# %verloading SS as virtual !e!ber function beco!es handy when the class in which it is overloaded is inherited" and this beco!es available to be overrided# This is as opposed to global friend functions" where friendTs are not inherited# <M class op%verload] public: bool operatorBB-op%verload te!p.X ^X bool op%verload::operatorBB-op%verload te!p.] if-<this BB te!p .] coutSSOThe both are sa!e ob@ectsZnOX return trueX ^ A>&
Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

else] coutSSOThe both are differentZnOX return falseX ^ ^ void !ain-.] op%verload aA" a2X aAB Ba2X ^ Answer : *unti!e 6rror: Stac$ %verflow 67planation : =ust li!e norm$l fun(tions& oper$tor fun(tions ($n be ($lle# re(ursi5el%. This pro0r$m ust illustr$tes th$t point& b% ($llin0 the oper$tor >> fun(tion re(ursi5el%& le$#in0 to $n infinite loop. 6n fun(tion bo#% there is >>& it ($use# re(urression. class co!ple7] double reX double i!X public: co!ple7-. : re-A."i!-D#>. ]^ bool operatorBB-co!ple7 Urhs.X operator int-.]^ A>1
Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

^X bool co!ple7::operator BB -co!ple7 Urhs.] if--this;Rre BB rhs#re. UU -this;Ri! BB rhs#i!.. return trueX else return falseX ^ int !ain-.] co!ple7 cAX coutSS cAX ^ Answer : )arbage value 67planation: The progra!!er wishes to print the co!ple7 ob@ect using output re;direction operator"which he has not defined for his lass#+ut the co!piler instead of giving an error sees the conversion function and converts the user defined ob@ect to standard ob@ect and prints so!e garbage value# class co!ple7] A>>
Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

double reX double i!X public: co!ple7-. : re-D."i!-D. ]^ co!ple7-double n. ] reBn"i!BnX^X co!ple7-int !"int n. ] reB!"i!BnX^ void print-. ] coutSSreX coutSSi!X^ ^X void !ain-.] co!ple7 c&X double iB>X c& B iX c&#print-.X ^ Answer: >"> 67planation: Though no operatorB function ta$ing co!ple7" double is defined" the double on the rhs is converted into a te!porary ob@ect using the single argu!ent constructor ta$ing double and assigned to the lvalue# void !ain-. ] int a" <pa" UraX A>C
Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

pa B UaX ra B aX cout SSOaBOSSa SSO<paBOSS<pa SSOraOSSra X ^ Answer : Co!piler 6rror: TraT"reference !ust be initiali ed 67planation : 8ointers are different fro! references# %ne of the !ain differences is that the pointers can be both initiali ed and assigned" whereas references can only be initiali ed# So this code issues an error# 5r, it ; urse39 A. Deter!ine the output of the TC==T Codelet# class base ] public : out-. ] coutSSObase OX ^ ^X class deri] public : out-. A>E
Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

] coutSSOderi OX ^ ^X void !ain-. ] deri dpP&QX base <bp B -base<.dpX for -int iBDX iS&Xi==. -bp==.;Rout-.X ^ 2. Hustify the use of virtual constructors and destructors in C==# &. 6ach C== ob@ect possesses the 1 !e!ber fns" -which can be declared by the progra!!er e7plicitly or by the i!ple!entation if they are not available.# Ihat are those 1 functions` 1. Ihat is wrong with this class declaration` class so!ething ] char <strX public: so!ething-.] st B new charPADQX ^ aso!ething-. ] A>F
Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

delete strX ^ ^X >. Inheritance is also $nown as ;;;;;;;; relationship# Containership as NNNNNNNN relationship# C. Ihen is it necessary to use !e!ber;wise initiali ation list -also $nown as header initiali ation list. in C==` E. Ihich is the only operator in C== which can be overloaded but (%T inherited# F. Is there anything wrong with this C== class declaration` class te!p ] int valueAX !utable int value2X public : void fun-int val. const] --te!p<. this.;RvalueA B ADX value2 B ADX ^ ^X
A>G Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

1. What is a modifier? Ans)er0 A !odifier" also called a !odifying function is a !e!ber function that changes the value of at least one data !e!ber# In other words" an operation that !odifies the state of an ob@ect# 'odifiers are also $nown as 4!utators5# 2. What is an accessor? Ans)er0 An accessor is a class operation that does not !odify the state of an ob@ect# The accessor functions need to be declared as const operations 3. !ifferentiate .etween a template class and class template. Ans)er0 5e(p3ate c3ass0 A generic definition or a para!eteri ed class not instantiated until the client provides the needed infor!ation# It5s @argon for plain te!plates# C3ass te(p3ate0 A class te!plate specifies how individual classes can be constructed !uch li$e the way a class specifies how individual ob@ects can be constructed# It5s @argon for plain classes# *. When does a name clash occur? ACD
Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

Ans)er0 A na!e clash occurs when a na!e is defined in !ore than one place# For e7a!ple" two different class libraries could give two different classes the sa!e na!e# If you try to use !any class libraries at the sa!e ti!e" there is a fair chance that you will be unable to co!pile or lin$ the progra! because of na!e clashes# -. De9ine na(espace. Ans)er0 It is a feature in c== to !ini!i e na!e collisions in the global na!e space# This na!espace $eyword assigns a distinct na!e to a library that allows other libraries to use the sa!e identifier na!es without creating any na!e collisions# Further!ore" the co!piler uses the na!espace signature for differentiating the definitions# 0. What is the use of XusingF declaration. Ans)er0 A using declaration !a$es it possible to use a na!e fro! a na!espace without the scope operator# 5. What is an +terator class? Ans)er0
ACA Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

A class that is used to traverse through the ob@ects !aintained by a container class# There are five categories of iterators: input iterators" output iterators" forward iterators" bidirectional iterators" rando! access# An iterator is an entity that gives access to the contents of a container ob@ect without violating encapsulation constraints# Access to the contents is granted on a one;at;a;ti!e basis in order# The order can be storage order -as in lists and 2ueues. or so!e arbitrary order -as in array indices. or according to so!e ordering relation -as in an ordered binary tree.# The iterator is a construct" which provides an interface that" when called" yields either the ne7t ele!ent in the container" or so!e value denoting the fact that there are no !ore ele!ents to e7a!ine# Iterators hide the details of access to and update of the ele!ents of a container class# The si!plest and safest iterators are those that per!it read;only access to the contents of a container class# The following code frag!ent shows how an iterator !ight appear in code: contNiter:Bnew contNiterator-.X 7:BcontNiter#ne7t-.X
AC2 Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

while 7MBnone do ### s-7.X ### 7:BcontNiter#ne7t-.X endX In this e7a!ple" contNiter is the na!e of the iterator# It is created on the first line by instantiation of contNiterator class" an iterator class defined to iterate over so!e container class" cont# Succesive ele!ents fro! the container are carried to 7# The loop ter!inates when 7 is bound to so!e e!pty value# -/ere" none.In the !iddle of the loop" there is s-7. an operation on 7" the current ele!ent fro! the container# The ne7t ele!ent of the container is obtained at the botto! of the loop# ?. List out some of the EE!"#$ availa.le. Ans)er0 )6'ST%(6M%8A3 of )e!stone syste!s# %(T%S of %ntos# %b@ectivity of %b@ectivity inc# 0ersant of 0ersant ob@ect technology# %b@ect store of %b@ect Design# A*D6(T of A*D6(T software# 8%6T of 8%6T software#
AC& Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

1@. List out some of the o.ject3oriented methodologies. Ans)er0 %b@ect %riented Develop!ent -%%D. -+ooch AGGA"AGG1.# %b@ect %riented Analysis and Design -%%AMD. -Coad and Kourdon AGGA.# %b@ect 'odelling Techni2ues -%'T. -*u!baugh AGGA.# %b@ect %riented Software 6ngineering -%b@ectory. -Hacobson AGG2.# %b@ect %riented Analysis -%%A. -Shlaer and 'ellor AGG2.# The Fusion 'ethod -Cole!an AGGA.# 11. What is an incomplete type? Ans)er0 Inco!plete types refers to pointers in which there is non availability of the i!ple!entation of the referenced location or it points to so!e location whose value is not available for !odification# 12a(p3e0 int <iBD71DD MM i points to address 1DD <iBDX MMset the value of !e!ory location pointed by i# Inco!plete types are otherwise called uninitiali ed pointers#
AC1 Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

12. What is a dangling pointer? Ans)er0 A dangling pointer arises when you use the address of an ob@ect after its lifeti!e is over# This !ay occur in situations li$e returning addresses of the auto!atic variables fro! a function or using the address of the !e!ory bloc$ after it is freed# 13. !ifferentiate .etween the message and method. Ans)er0 $essa+e $et6 d %b@ects co!!unicate by sending !essages 8rovides response to a !essage# to each other# A !essage is sent to invo$e a !ethod# It is an i!ple!entation of an operation# 1*. What is an adaptor class or Wrapper class? Ans)er0 A class that has no functionality of its own# Its !e!ber functions hide the use of a third party software co!ponent or an ob@ect with the non; co!patible interface or a non; ob@ect; oriented i!ple!entation# 1-. What is a &ull o.ject? AC>
Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

Ans)er0 It is an ob@ect of so!e class whose purpose is to indicate that a real ob@ect of that class does not e7ist# %ne co!!on use for a null ob@ect is a return value fro! a !e!ber function that is supposed to return an ob@ect with so!e specified properties but cannot find such an ob@ect# 10. What is class invariant? Ans)er0 A class invariant is a condition that defines all valid states for an ob@ect# It is a logical condition to ensure the correct wor$ing of a class# Class invariants !ust hold when an ob@ect is created" and they !ust be preserved under all operations of the class# In particular all class invariants are both preconditions and post;conditions for all operations or !e!ber functions of the class# 15. <6at d , u (ean 7, Stac* un)indin+? Ans)er0 It is a process during e7ception handling when the destructor is called for all local ob@ects between the place where the e7ception was thrown and where it is caught# 17. !efine precondition and post3condition to a mem.er function. ACC
Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

Ans)er0 Prec nditi n0 A precondition is a condition that !ust be true on entry to a !e!ber function# A class is used correctly if preconditions are never false# An operation is not responsible for doing anything sensible if its precondition fails to hold# For e7a!ple" the interface invariants of stac' class say nothing about pushing yet another ele!ent on a stac$ that is already full# Ie say that isful 24 is a precondition of the push operation# P st.c nditi n0 A post;condition is a condition that !ust be true on e7it fro! a !e!ber function if the precondition was valid on entry to that function# A class is i!ple!ented correctly if post;conditions are never false# For e7a!ple" after pushing an ele!ent on the stac$" we $now that isempty24 !ust necessarily hold# This is a post;condition of the push operation# 1?. What are the conditions that have to .e met for a condition to .e an invariant of the class? Ans)er0 The condition should hold at the end of every constructor#
ACE Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

The condition should hold at the end of every !utator-non;const. operation# 2@. What are proxy o.jects? Ans)er0 %b@ects that stand for other ob@ects are called pro7y ob@ects or surrogates# 12a(p3e0 te!plateSclass TR class Array2D ] public: class ArrayAD ] public: TU operatorPQ -int inde7.X const TU operatorPQ -int inde7. constX ### ^X ArrayAD operatorPQ -int inde7.X const ArrayAD operatorPQ -int inde7. constX ### ^X The following then beco!es legal: Array2DSfloatRdata-AD"2D.X

ACF

Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

######## coutSSdataP&QPCQX

MM fine

/ere dataP&Q yields an ArrayAD ob@ect and the operator PQ invocation on that ob@ect yields the float in position-&"C. of the original two di!ensional array# Clients of the Array2D class need not be aware of the presence of the ArrayAD class# %b@ects of this latter class stand for one;di!ensional array ob@ects that" conceptually" do not e7ist for clients of Array2D# Such clients progra! as if they were using real" live" two;di!ensional arrays# 6ach ArrayAD ob@ect stands for a one;di!ensional array that is absent fro! a conceptual !odel used by the clients of Array2D# In the above e7a!ple" ArrayAD is a pro7y class# Its instances stand for one;di!ensional arrays that" conceptually" do not e7ist# 21. &ame some pure o.ject oriented languages# Ans)er0 S!alltal$" Hava" 6iffel" Sather# 22. &ame the operators that cannot .e overloaded. Ans)er0
ACG Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

si eof

#<

#;R ::

`:

23. What is a node class? Ans)er0 A node class is a class that" relies on the base class for services and i!ple!entation" provides a wider interface to the users than its base class" relies pri!arily on virtual functions in its public interface depends on all its direct and indirect base class can be understood only in the conte7t of the base class can be used as base for further derivation Can be used to create ob@ects# A node class is a class that has added new services or functionality beyond the services inherited fro! its base class# 2*. What is an orthogonal .ase class? Ans)er0 If two base classes have no overlapping !ethods or data they are said to be independent of" or orthogonal to each other# %rthogonal in the sense !eans that two classes operate in different di!ensions and do not interfere with each other in
AED Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

any way# The sa!e derived class !ay inherit such classes with no difficulty# 2-. What is a container class? What are the types of container classes? Ans)er0 A container class is a class that is used to hold ob@ects in !e!ory or e7ternal storage# A container class acts as a generic holder# A container class has a predefined behavior and a well;$nown interface# A container class is a supporting class whose purpose is to hide the topology used for !aintaining the list of ob@ects in !e!ory# Ihen a container class contains a group of !i7ed ob@ects" the container is called a heterogeneous containerX when the container is holding a group of ob@ects that are all the sa!e" the container is called a ho!ogeneous container# 20. What is a protocol class? Ans)er0 An abstract class is a protocol class if: it neither contains nor inherits fro! classes that contain !e!ber data" non;virtual functions" or private -or protected. !e!bers of any $ind# it has a non;inline virtual destructor defined with an e!pty i!ple!entation"
AEA Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

All !e!ber functions other than the destructor including inherited functions" are declared pure virtual functions and left undefined# 25. What is a mixin class? Ans)er0 A class that provides so!e but not all of the i!ple!entation for a virtual base class is often called !i7in# Derivation done @ust for the purpose of redefining the virtual functions in the base classes is often called !i7in inheritance# 'i7in classes typically donTt share co!!on bases# 27. What is a concrete class? Ans)er0 A concrete class is used to define a useful ob@ect that can be instantiated as an auto!atic variable on the progra! stac$# The i!ple!entation of a concrete class is defined# The concrete class is not intended to be a base class and no atte!pt to !ini!i e dependency on other classes in the i!ple!entation or behavior of the class# 2?. What is the handle class? Ans)er0 A handle is a class that !aintains a pointer to an ob@ect that is progra!!atically accessible through the AE2 public interface of the handle class#
Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

12p3anati n0 In case of abstract classes" unless one !anipulates the ob@ects of these classes through pointers and references" the benefits of the virtual functions are lost# ?ser code !ay beco!e dependent on details of i!ple!entation classes because an abstract type cannot be allocated statistically or on the stac$ without its si e being $nown# ?sing pointers or references i!plies that the burden of !e!ory !anage!ent falls on the user# Another li!itation of abstract class ob@ect is of fi7ed si e# Classes however are used to represent concepts that re2uire varying a!ounts of storage to i!ple!ent the!# A popular techni2ue for dealing with these issues is to separate what is used as a single ob@ect in two parts: a handle providing the user interface and a representation holding all or !ost of the ob@ectTs state# The connection between the handle and the representation is typically a pointer in the handle# %ften" handles have a bit !ore data than the si!ple representation pointer" but not !uch !ore# /ence the layout of the handle is typically stable" even when the representation changes and also that handles are s!all enough to !ove around relatively freely so that the user needn5t use the pointers and the references#
AE&

3@. What is an action class?

Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

Ans)er0 The si!plest and !ost obvious way to specify an action in C== is to write a function# /owever" if the action has to be delayed" has to be trans!itted TelsewhereT before being perfor!ed" re2uires its own data" has to be co!bined with other actions" etc then it often beco!es attractive to provide the action in the for! of a class that can e7ecute the desired action and provide other services as well# 'anipulators used with iostrea!s is an obvious e7a!ple# 12p3anati n0 A co!!on for! of action class is a si!ple class containing @ust one virtual function# class Action ] public: virtual int doNit- int .BDX virtual aAction- .X ^ )iven this" we can write code say a !e!ber that can store actions for later e7ecution without using pointers to functions" without $nowing anything about the ob@ects involved" and without even $nowing the na!e of the operation it invo$es# For e7a!ple: class writeNfile : public Action ] FileU fX AE1
Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

public: int doNit-int. ] return fwrite- .#suceed- .X ^ ^X class errorN!essage: public Action ] responseNbo7 db-!essage#cstr- ."OContinueO"OCancelO"O*etryO.X switch -db#getresponse- .. ] case D: return DX case A: abort-.X case 2: currentNoperation#redo- .Xreturn AX ^ ^X A user of the Action class will be co!pletely isolated fro! any $nowledge of derived classes such as writeNfile and errorN!essage# 31. When can you tell that a memory lea' will occur? Ans)er0 A !e!ory lea$ occurs when a progra! loses the ability to free a bloc$ of dyna!ically allocated !e!ory# AE>
Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

32.What is a parameteriCed type? Ans)er0 A te!plate is a para!eteri ed construct or type containing generic code that can use or !anipulate any type# It is called para!eteri ed because an actual type is a para!eter of the code body# 8oly!orphis! !ay be achieved through para!eteri ed types# This type of poly!orphis! is called para!eteric poly!orphis!# 8ara!eteric poly!orphis! is the !echanis! by which the sa!e code is used on different types passed as para!eters# 33. !ifferentiate .etween a deep copy and a shallow copy? Ans)er0 Deep copy involves using the contents of one ob@ect to create another instance of the sa!e class# In a deep copy" the two ob@ects !ay contain ht sa!e infor!ation but the target ob@ect will have its own buffers and resources# the destruction of either ob@ect will not affect the re!aining ob@ect# The overloaded assign!ent operator would create a deep copy of ob@ects# Shallow copy involves copying the contents of one ob@ect into another instance of the sa!e class thus creating a !irror i!age# %wing to straight copying of references and pointers" the two ob@ects AEC
Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

will share the sa!e e7ternally contained contents of the other ob@ect to be unpredictable# 12p3anati n0 ?sing a copy constructor we si!ply copy the data values !e!ber by !e!ber# This !ethod of copying is called shallow copy# If the ob@ect is a si!ple class" co!prised of built in types and no pointers this would be acceptable# This function would use the values and the ob@ects and its behavior would not be altered with a shallow copy" only the addresses of pointers that are !e!bers are copied and not the value the address is pointing to# The data values of the ob@ect would then be inadvertently altered by the function# Ihen the function goes out of scope" the copy of the ob@ect with all its data is popped off the stac$# If the ob@ect has any pointers a deep copy needs to be e7ecuted# Iith the deep copy of an ob@ect" !e!ory is allocated for the ob@ect in free store and the ele!ents pointed to are copied# A deep copy is used for ob@ects that are returned fro! a function# 3*. What is an opa/ue pointer? Ans)er0 A pointer is said to be opa2ue if the definition of the type to which it points to is not included in the current translation unit# A translation unit is the result
AEE Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

of !erging an i!ple!entation file with all its headers and header files# 3-. What is a smart pointer? Ans)er0 A s!art pointer is an ob@ect that acts" loo$s and feels li$e a nor!al pointer but offers !ore functionality# In C==" s!art pointers are i!ple!ented as template classes that encapsulate a pointer and override standard pointer operators# They have a nu!ber of advantages over regular pointers# They are guaranteed to be initiali ed as either null pointers or pointers to a heap ob@ect# Indirection through a null pointer is chec$ed# (o delete is ever necessary# %b@ects are auto!atically freed when the last pointer to the! has gone away# %ne significant proble! with these s!art pointers is that unli$e regular pointers" they donTt respect inheritance# S!art pointers are unattractive for poly!orphic code# )iven below is an e7a!ple for the i!ple!entation of s!art pointers# 12a(p3e0 te!plate Sclass JR class s!artNpointer ] public: s!artNpointer-.X MM !a$es a null pointer AEF
Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

s!artNpointer-const JU 7. !a$es pointer to copy of 7 JU operator <- .X const JU operator<- . constX J< operator;R-. constX

MM

s!artNpointer-const s!artNpointer SJR U.X const s!artNpointer SJR U operator B-const s!artNpointerSJRU.X as!artNpointer-.X private: MM### ^X This class i!ple!ent a s!art pointer to an ob@ect of type J# The ob@ect itself is located on the heap# /ere is how to use it: s!artNpointer Se!ployeeR pB e!ployee-O/arrisO"A&&&.X 3i$e other overloaded operators" p will behave li$e a regular pointer" coutSS<pX p;RraiseNsalary-D#>.X 30. What is reflexive association? Ans)er0
AEG Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

The Tis;aT is called a refle7ive association because the refle7ive association per!its classes to bear the is;a association not only with their super;classes but also with the!selves# It differs fro! a Tspeciali es; fro!T as Tspeciali es;fro!T is usually used to describe the association between a super;class and a sub;class# For e7a!ple: 8rinter is;a printer# 35. What is slicing? Ans)er0 Slicing !eans that the data added by a subclass are discarded when an ob@ect of the subclass is passed or returned by value or fro! a function e7pecting a base class ob@ect# 12p3anati n0 Consider the following class declaration: class base ] ### baseU operator B-const baseU.X base -const baseU.X ^ void fun- . ] base eB!X eB!X ^ AFD
Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

As base copy functions donTt $now anything about the derived only the base part of the derived is copied# This is co!!only referred to as slicing# %ne reason to pass ob@ects of classes in a hierarchy is to avoid slicing# %ther reasons are to preserve poly!orphic behavior and to gain efficiency# 37. What is name mangling? Ans)er0 (a!e !angling is the process through which your c== co!pilers give each function in your progra! a uni2ue na!e# In C==" all progra!s have at;least a few functions with the sa!e na!e# (a!e !angling is a concession to the fact that lin$er always insists on all function na!es being uni2ue# 12a(p3e0 In general" !e!ber na!es are !ade uni2ue by concatenating the na!e of the !e!ber with that of the class e#g# given the declaration: class +ar ] public: int ivalX ### ^X ival beco!es so!ething li$e: MM a possible !e!ber na!e !angling ivalNN&+ar AFA
Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

Consider this derivation: class Foo : public +ar ] public: int ivalX ### ^ The internal representation of a Foo ob@ect is the concatenation of its base and derived class !e!bers# MM 8seudo C== code MM Internal representation of Foo class Foo ] public: int ivalNN&+arX int ivalNN&FooX ### ^X ?na!biguous access of either ival !e!bers is achieved through na!e !angling# 'e!ber functions" because they can be overloaded" re2uire an e7tensive !angling to provide each with a uni2ue na!e# /ere the co!piler generates the sa!e na!e for the two overloaded instances-Their argu!ent lists !a$e their instances uni2ue.# 3?. What are proxy o.jects? Ans)er0 AF2
Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

%b@ects that points to other ob@ects are called pro7y ob@ects or surrogates# Its an ob@ect that provides the sa!e interface as its server ob@ect but does not have any functionality# During a !ethod invocation" it routes data to the true server ob@ect and sends bac$ the return value to the ob@ect# *@. !ifferentiate .etween declaration and definition in ,88. Ans)er0 A declaration introduces a na!e into the progra!X a definition provides a uni2ue description of an entity -e#g# type" instance" and function.# Declarations can be repeated in a given scope" it introduces a na!e in a given scope# There !ust be e7actly one definition of every ob@ect" function or class used in a C== progra!# A declaration is a definition unless: it declares a function without specifying its body" it contains an e7tern specifier and no initiali er or function body" it is the declaration of a static class data !e!ber without a class definition" it is a class na!e definition" it is a typedef declaration# A definition is a declaration unless: it defines a static class data !e!ber"
AF& Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

it defines a non;inline !e!ber function# *1. What is cloning? Ans)er0 An ob@ect can carry out copying in two ways i#e# it can set itself to be a copy of another ob@ect" or it can return a copy of itself# The latter process is called cloning# *2. !escri.e the main characteristics of static functions. Ans)er0 The !ain characteristics of static functions include" It is without the a this pointer" It canTt directly access the non;static !e!bers of its class It canTt be declared const" volatile or virtual# It doesnTt need to be invo$ed through an ob@ect of its class" although for convenience" it !ay# *3. Will the inline function .e compiled as the inline function always? Yustify. Ans)er0 An inline function is a re2uest and not a co!!and# /ence it wonTt be co!piled as an inline function always#
AF1 Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

12p3anati n0 Inline;e7pansion could fail if the inline function contains loops" the address of an inline function is used" or an inline function is called in a co!ple7 e7pression# The rules for inlining are co!piler dependent# **. !efine a way other than using the 'eyword inline to ma'e a function inline. Ans)er0 The function !ust be defined inside the class# *-. )ow can a W::W operator .e used as unary operator? Ans)er0 The scope operator can be used to refer to !e!bers of the global na!espace# +ecause the global na!espace doesn5t have a na!e" the notation :: !e!ber;na!e refers to a !e!ber of the global na!espace# This can be useful for referring to !e!bers of global na!espace whose na!es have been hidden by na!es declared in nested local scope# ?nless we specify to the co!piler in which na!espace to search for a declaration" the co!piler si!ple searches the current scope" and any scopes in which the current scope is nested" to find the declaration for the na!e#
AF> Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

*0. What is placement new? Ans)er0 Ihen you want to call a constructor directly" you use the place!ent new# So!eti!es you have so!e raw !e!ory thatTs already been allocated" and you need to construct an ob@ect in the !e!ory you have# %perator newTs special version place!ent new allows you to do it# class Iidget ] public : Iidget-int widgetsi e.X ### Iidget< ConstructNwidgetNintNbuffer-void <buffer"int widgetsi e. ] return new-buffer. Iidget-widgetsi e.X ^ ^X This function returns a pointer to a Iidget ob@ect thatTs constructed within the buffer passed to the function# Such a function !ight be useful for applications using shared !e!ory or !e!ory; !apped IM%" because ob@ects in such applications !ust be placed at specific addresses or in !e!ory allocated by special routines# AFC
Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

??-8 1. What do you mean .y analysis and design? 6nalysis: +asically" it is the process of deter!ining what needs to be done before how it should be done# In order to acco!plish this" the developer refers the e7isting syste!s and docu!ents# So" si!ply it is an art of discovery# !esign: It is the process of adoptingMchoosing the one a!ong the !any" which best acco!plishes the users needs# So" si!ply" it is co!pro!ising !echanis!# 2. What are the steps involved in designing? +efore getting into the design the designer should go through the S*S prepared by the Syste! Analyst# The !ain tas$s of design are Architectural Design and Detailed Design# In Architectural Design we find what are the !ain !odules in the proble! do!ain# In Detailed Design we find what should be done within each !odule#
AFE Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

3. What are the main underlying concepts of o.ject orientation? %b@ects" !essages" class" inheritance and poly!orphis! are the !ain concepts of ob@ect orientation# *. What do u meant .y K$"+K of an o.ject? S+I stands for State" +ehavior and Identity# Since every ob@ect has the above three# $tate: It is @ust a value to the attribute of an ob@ect at a particular ti!e# "ehaviour: It describes the actions and their reactions of that ob@ect# +dentity: An ob@ect has an identity that characteri es its own e7istence# The identity !a$es it possible to distinguish any ob@ect in an una!biguous way" and independently fro! its state# -. !ifferentiate persistent ( non3persistent o.jects? 8ersistent refers to an ob@ectTs ability to transcend ti!e or space# A persistent ob@ect storesMsaves its state in a per!anent storage syste! with out losing the infor!ation represented by the ob@ect#
AFF Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

A non;persistent ob@ect is said to be transient or ephe!eral# +y default ob@ects are considered as non; persistent# 0. What do you meant .y active and passive o.jects? Active ob@ects are one which instigate an interaction which owns a thread and they are responsible for handling control to other ob@ects# In si!ple words it can be referred as client# 8assive ob@ects are one" which passively waits for the !essage to be processed# It waits for another ob@ect that re2uires its services# In si!ple words it can be referred as server# Diagra!: client server -Active. -8assive. 5. What is meant .y software development method` Software develop!ent !ethod describes how to !odel and build software syste!s in a reliable and reproducible way# To put it si!ple" !ethods that are used to represent onesT thin$ing using graphical notations# 7. What are models and meta models? #odel: +t is a co!plete description of so!ething AFG
Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

-i#e# syste!.# #eta model: It describes the !odel ele!ents" synta7 and se!antics of the notation that allows their !anipulation# ?. What do you meant .y static and dynamic modeling? Static !odeling is used to specify structure of the ob@ects that e7ist in the proble! do!ain# These are e7pressed using class" o.ject and Q$1,6$1 diagrams# +ut Dyna!ic !odeling refers representing the ob@ect interactions during runti!e# It is represented by se/uence" activity" colla.oration and statechart diagrams# 1@. )ow to represent the interaction .etween the modeling elements? #odel element is @ust a notation to represent -)raphically. the entities that e7ist in the proble! do!ain# e#g# for !odeling ele!ent is class notation" ob@ect notation etc# *elationships are used to represent the interaction between the !odeling ele!ents# The following are the *elationships# AGD6ssociation: ItsT @ust a se!antic connection two
Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

classes# e#g#:

uses class +

class A

6ggregation: ItsT the relationship between two classes which are related in the fashion that master and slave# The !aster ta$es full rights than the slave# Since the slave wor$s under the !aster# It is represented as line with dia!ond in the !aster area# e7: car contains wheels" etc# car
car wheels

,ontainment: This relationship is applied when the part contained with in the whole part" dies when the whole part dies# It is represented as dar$ed dia!ond at the whole part# e7a!ple: class A] MMso!e code ^X class + ]

AGA

Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

A aaX MM an ob@ect of class AX MM so!e code for class +X ^X In the above e7a!ple we see that an ob@ect of class A is instantiated with in the class +# so the ob@ect class A dies when the ob@ect class + dies#we can represnt it in diagra! li$e this#
class A class +

=eneraliCation: This relationship used when we want represents a class" which captures the co!!on states of ob@ects of different classes# It is represented as arrow line pointed at the class" which has captured the co!!on states#
class A

class +

class C

!ependency: It is the relationship between dependent and independent classes# Any change in AG2the independent class will affect the states of the
Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

dependent class# DIA)*A': class A

class +

11. Why generaliCation is very strong? 6ven though )enerali ation satisfies Structural" Interface" +ehaviour properties# It is !athe!atically very strong" as it is Antisy!!etric and Transitive# 6ntisymmetric: e!ployee is a person" but not all persons are e!ployees# 'athe!atically all As5 are +" but all +s5 not A# Dransitive: ABR+" +BRc then ABRc# A# Sales!an# +# 6!ployee# C# 8erson# 'ote: All the other relationships satisfy all the properties li$e Structural properties" Interface properties" +ehaviour properties# 12. !ifferentiate 6ggregation and containment? Aggregation is the relationship between the whole and a part# Ie can addMsubtract so!e properties in the part -slave. side# It wonTt affect the whole part# +est e7a!ple is Car" which contains the wheels and so!e e7tra parts# 6ven though the parts are not there we can call it as car# +ut" in the case of contain!ent the whole part is AG&
Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

affected when the part within that got affected# The hu!an body is an apt e7a!ple for this relationship# Ihen the whole body dies the parts -heart etc. are died# 13. ,an lin' and 6ssociation applied interchangea.ly? (o" Kou cannot apply the lin$ and Association interchangeably# Since lin$ is used represent the relationship between the two ob@ects# +ut Association is used represent the relationship between the two classes# lin$ :: student:Abhilash course:'CA Association:: student course 1*. what is meant .y Kmethod3warsK? +efore AGG1 there were different !ethodologies li$e *u!baugh" +ooch" Hacobson" 'eyer etc who followed their own notations to !odel the syste!s# The developers were in a dile!!a to choose the !ethod which best acco!plishes their needs# This particular span was called as O!ethod;warsO 1-. Whether unified method and unified modeling language are same or different? ?nified !ethod is convergence of the *u!baugh and +ooch# AG1
Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

?nified !odeling lang# is the fusion of *u!baugh" +ooch and Hacobson as well as +etrand 'eyer -whose contribution is Ose2uence diagra!O.# ItsT the superset of all the !ethodologies# 10. Who were the three famous amigos and what was their contri.ution to the o.ject community? The Three a!igos na!ely" Yames um.augh 2E#D4: A veteran in analysis who ca!e up with an idea about the ob@ects and their *elationships -in particular Associations.# =rady "ooch: A veteran in design who ca!e up with an idea about partitioning of syste!s into subsyste!s# +var Yaco.son 2E.jectory4: The father of ?S6CAS6S" who described about the user and syste! interaction# 15. !ifferentiate the class representation of "ooch% um.augh and Q#L? If you loo$ at the class representaiton of *u!baugh and ?'3" It is so!e what si!ilar and both are very easy to draw# Represent$tion: ?@T A@B# 8i$0r$m:
AG> Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

+ooch: In this !ethod classes are represented as OCloudsO which are not very easy to draw as for as the developerTs view is concern# 8i$0r$m:

17. What is an Q$1,6$1? Why it is needed? A ?se Case is a description of a set of se2uence of actions that a syste! perfor!s that yields an observable result of value to a particular action# In SSAD process SBR In %%AD ?S6CAS6# It is represented elliptically# Represent$tion:

1?. Who is an 6ctor? AGC


Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

An Actor is so!eone or so!ething that !ust interact with the syste!#In addition to that an Actor initiates the process-that is ?S6CAS6.# It is represented as a stic$!an li$e this# 8i$0r$m:

2@. What is guard condition? )uard condition is one" which acts as a firewall# The access fro! a particular ob@ect can be !ade only when the particular condition is !et# For 67a!ple" custo!er chec$ custo!er nu!ber AT'# /ere the ob@ect on the custo!er accesses the AT' facility only when the guard condition is !et# 21. !ifferentiate the following notations? +: :o.j1 :o.j2 ++: :o.j1 :o.j2

In the above representation I" ob@A sends !essage to ob@2# +ut in the case of II the data is transferred fro! ob@A to ob@2# AGE
Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

22. Q$1,6$1 is an implementation independent notation. )ow will the designer give the implementation details of a particular Q$1,6$1 to the programmer? This can be acco!plished by specifying the relationship called Orefine!ent\ which tal$s about the two different abstraction of the sa!e thing# %r e7a!ple" calculate pay calculate classA class2 class&

23. $uppose a class acts an 6ctor in the pro.lem domain% how to represent it in the static model? In this scenario you can use [stereotype\# Since stereotype is @ust a string that gives e7tra se!antic to the particular entityM!odel ele!ent# It is given with in the SS RR# class A SS ActorRR attributes !ethods# 2*. Why does the function arguments are called as AGF
Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

KsignaturesK? The argu!ents distinguish functions with the sa!e na!e -functional poly!orphis!.# The na!e alone does not necessarily identify a uni2ue function# /owever" the na!e and its argu!ents -signatures. will uni2uely identify a function# In real life we see suppose" in class there are two guys with sa!e na!e" but they can be easily identified by their signatures# The sa!e concept is applied here# e7: class person ] public: char getse7-.X void setse7-char.X void setse7-int.X ^X In the above e7a!ple we see that there is a function setse7-. with sa!e na!e but with different signature#

AGG Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

Quantitative Aptitude

Quantitative Aptitude 12ercise 1 S 3ve t6e 9 33 )in+ and c6ec* )it6 t6e ans)ers +iven at t6e end. A# It was calculated that E> !en could co!plete a piece of wor$ in 2D days# Ihen wor$ was scheduled to co!!ence" it was found necessary to send 2> !en to another pro@ect# /ow !uch longer will it ta$e to co!plete the wor$` A student divided a nu!ber by 2M& when he re2uired to !ultiply by &M2# Calculate the percentage of error in his result# A dishonest shop$eeper professes to sell pulses at the cost price" but he uses a false weight of G>Dg!# for a $g# /is gain is LW#

2#

&#

2DD Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

1#

A software engineer has the capability of thin$ing ADD lines of code in five !inutes and can type ADD lines of code in AD !inutes# /e ta$es a brea$ for five !inutes after every ten !inutes# /ow !any lines of codes will he co!plete typing after an hour` A !an was engaged on a @ob for &D days on the condition that he would get a wage of *s# AD for the day he wor$s" but he have to pay a fine of *s# 2 for each day of his absence# If he gets *s# 2AC at the end" he was absent for wor$ for ### days# A contractor agreeing to finish a wor$ in A>D days" e!ployed E> !en each wor$ing F hours daily# After GD days" only 2ME of the wor$ was co!pleted# Increasing the nu!ber of !en by NNNNNNNN each wor$ing now for AD hours daily" the wor$ can be co!pleted in ti!e# what is a percent of b divided by b percent of a` -a. a -b. b -c. A -d. AD -d. ADD A !an bought a horse and a cart# If he sold the horse at AD W loss and the cart at 2D W gain" he would not lose anythingX but if he sold the horse at >W loss and the cart at >W gain" he would lose *s# AD in the bargain# The a!ount paid by hi!

>#

C#

E# F#

2DA

Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

was *s#NNNNNNN for the horse and *s#NNNNNNNN for the cart# G# A tennis !ar$er is trying to put together a tea! of four players for a tennis tourna!ent out of seven available# !ales ; a" b and cX fe!ales , !" n" o and p# All players are of e2ual ability and there !ust be at least two !ales in the tea!# For a tea! of four" all players !ust be able to play with each other under the following restrictions: b should not play with !" c should not play with p" and a should not play with o# Ihich of the following state!ents !ust be false` A# b and p cannot be selected together 2# c and o cannot be selected together &# c and n cannot be selected together# AD;A2# The following figure depicts three views of a cube# +ased on this" answer 2uestions AD;A2# C
2

> A
2

1 22
&

&

2D2 Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

AD# The nu!ber on the face opposite to the face carrying A is NNNNNNN # AA# The nu!ber on the faces ad@acent to the face !ar$ed > are NNNNNNN # A2# Ihich of the following pairs does not correctly give the nu!bers on the opposite faces# -A. C"> -2. 1"A -&. A"& -1. 1"2 A&# Five far!ers have E" G" AA" A& U A1 apple trees" respectively in their orchards# 3ast year" each of the! discovered that every tree in their own orchard bore e7actly the sa!e nu!ber of apples# Further" if the third far!er gives one apple to the first" and the fifth gives three to each of the second and the fourth" they would all have e7actly the sa!e nu!ber of apples# Ihat were the yields per tree in the orchards of the third and fourth far!ers` A1# Five boys were cli!bing a hill# H was following /# * was @ust ahead of )# _ was between ) U /# They were cli!bing up in a colu!n# Iho was the second`
2D& Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

A>;AF Hohn is undecided which of the four novels to buy# /e is considering a spy thriller" a 'urder !ystery" a )othic ro!ance and a science fiction novel# The boo$s are written by *oth$o" )or$y" +urchfield and /opper" not necessary in that order" and published by /eron" 8iegon" +lue@a and sparrow" not necessary in that order# A -A. The boo$ by *oth$o is published by Sparrow# 2 -2. The Spy thriller is published by /eron# -&. The science fiction novel is by +urchfield and is not published by +lue@a# & -1.The )othic ro!ance is by /opper# 1 A># 8igeon publishes NNNNNNNNNNNN# AC# The novel by )or$y NNNNNNNNNNNNNNNN# AE# Hohn purchases boo$s by the authors whose na!es co!e first and third in alphabetical order# /e does not buy the boo$s NNNNNN# AF# %n the basis of the first paragraph and state!ent -2." -&. and -1. only" it is possible to deduce that A# *oth$o wrote the !urder !ystery or the spy thriller
2D1 Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

2# Sparrow published the !urder !ystery or the spy thriller &# The boo$ by +urchfield is published by Sparrow# AG# If a light flashes every C seconds" how !any ti!es will it flash in c of an hour` 2D# If point 8 is on line seg!ent A+" then which of the following is always true` -A. A8 B 8+ -2. A8 R 8+ -&. 8+ R A8 -1. A+ R A8 ->. A+ R A8 = 8+ 2A# All !en are vertebrates# So!e !a!!als are vertebrates# Ihich of the following conclusions drawn fro! the above state!ent is correct# All !en are !a!!als All !a!!als are !en So!e vertebrates are !a!!als# (one 22# Ihich of the following state!ents drawn fro! the given state!ents are correct` )iven: All watches sold in that shop are of high standard# So!e of the /'T watches are sold in that shop#
2D> Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

a. All watches of high standard were !anufactured by /'T# b.So!e of the /'T watches are of high standard# c. (one of the /'T watches is of high standard# d.So!e of the /'T watches of high standard are sold in that shop# 2&;2E# A# Ashland is north of 6ast 3iverpool and west of Coshocton# 2# +owling green is north of Ashland and west of Frederic$town# &# Dover is south and east of Ashland# 1# 6ast 3iverpool is north of Frederic$town and east of Dover# ># Frederic$town is north of Dover and west of Ashland# C# Coshocton is south of Frederic$town and west of Dover# 2&# Ihich of the towns !entioned is furthest of the north , west -a. Ashland -b. +owling green -c. Coshocton -d. 6ast 3iverpool -e. Frederic$town
2DC Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

21# Ihich of the following !ust be both north and east of Frederic$town` -a. Ashland -b. Coshocton -c. 6ast 3iverpool I a only II b only III c only I0 a U b0 a Uc 2># Ihich of the following towns !ust be situated both south and west of at least one other town` A# Ashland only +# Ashland and Frederic$town C# Dover and Frederic$town D# Dover" Coshocton and Frederic$town 6#Coshocton" Dover and 6ast 3iverpool# 2C# Ihich of the following state!ents" if true" would !a$e the infor!ation in the nu!bered state!ents !ore specific` -a. Coshocton is north of Dover# -b. 6ast 3iverpool is north of Dover -c. Ashland is east of +owling green# -d. Coshocton is east of Frederic$town -e. +owling green is north of Frederic$town 2E# Ihich of the nu!bered state!ents gives infor!ation that can be deduced fro! one or !ore of the other state!ents` 2DE
Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

-A. A

-+. 2 -6. C

-C. &

-D.

2F# 6ight friends /arsha" Fa$is" +ala@i" 6swar" Dhinesh" Chandra" )eetha" and Ah!ed are sitting in a circle facing the center# +ala@i is sitting between )eetha and Dhinesh# /arsha is third to the left of +ala@i and second to the right of Ah!ed# Chandra is sitting between Ah!ed and )eetha and +ala@i and 6shwar are not sitting opposite to each other# Iho is third to the left of Dhinesh` 2G# If every alternative letter starting fro! + of the 6nglish alphabet is written in s!all letter" rest all are written in capital letters" how the !onth [ Septe!ber\ be written# -A. Sept6'b6r -2. S6pTe'+6r -&. Septe!be* -1. Septe'ber ->. (one of the above# &D# The length of the side of a s2uare is represented by 7=2# The length of the side of an e2uilateral triangle is 27# If the s2uare and the e2uilateral triangle have e2ual peri!eter" then the value of 7 is NNNNNNN#
2DF Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

&A# It ta$es 'r# _arthi$ y hours to co!plete typing a !anuscript# After 2 hours" he was called away# Ihat fractional part of the assign!ent was left inco!plete` &2# Ihich of the following is larger than &M>` -A. d -2. &GM>D -&. EM2>-1. &MAD->. >GMADD &&# The nu!ber that does not have a reciprocal is ; NNNNNNNNNNNN# &1# There are & persons Sudhir" Arvind" and )auri# Sudhir lent cars to Arvind and )auri as !any as they had already# After so!e ti!e Arvind gave as !any cars to Sudhir and )auri as !any as they have# After so!eti!e )auri did the sa!e thing# At the end of this transaction each one of the! had 21# Find the cars each originally had# &># A !an bought a horse and a cart# If he sold the horse at AD W loss and the cart at 2D W gain" he would not lose anythingX but if he sold the horse at >W loss and the cart at >W gain" he would lose *s# AD in the bargain# The a!ount paid by hi! was *s#NNNNNNN for the horse and *s#NNNNNNNN for the cart#
2DG Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

-ns7ers: A# Ans)er0 &D days# 12p3anati n0 "efore: %ne day wor$ %ne !an5s one day wor$ &ow: (o# %f wor$ers B %ne day wor$ < E>.

B B

A M 2D A M - 2D < E>.

>D B >D < A M - 2D

The total no# of days re2uired to co!plete the wor$ B -E> < 2D. M >D B &D 2# Ans)er0 DW 12p3anati n0 Since &7 M 2 B 7 M -2 M &.

&#

Ans)er0 >#& W 12p3anati n0 /e sells G>D gra!s of pulses and gains >D gra!s# If he sells ADD gra!s of pulses then he will gain ->D M G>D. <ADD B >#2C 2AD
Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

1# >#

Ans)er0 2>D lines of codes

Ans)er0 E days 12p3anati n0 The e2uation portraying the given proble! is: AD < 7 , 2 < -&D , 7. B 2AC where 7 is the nu!ber of wor$ing days# Solving this we get 7 B 2& (u!ber of days he was absent was E -&D;2&. days# C# Ans)er0 A>D !en# 12p3anati n0 %ne day5s wor$ %ne hour5s wor$ %ne !an5s wor$

B B B

2 M -E < GD. 2 M -E < GD < F. 2 M -E < GD < F < E>.

The re!aining wor$ ->ME. has to be co!pleted within CD days" because the total nu!ber of days allotted for the pro@ect is A>D days#
2AA

So we get the e2uation

Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

-2 < AD < 7 < CD. M -E < GD < F < E>.B >ME where 7 is the nu!ber of !en wor$ing after the GDth day# Ie get 7 B 22> Since we have E> !en already" it is enough to add only A>D !en# E# Ans)er0 -c. A 12p3anati n0 a percent of b : -aMADD. < b b percent of a : -bMADD. < a a percent of b divided by b percent of a : --a M ADD .<b. M -bMADD. < a .. B A Ans)er0 Cost price of horse B *s# 1DD U the cost price of cart B 2DD# 12p3anati n0. 3et 7 be the cost price of the horse and y be the cost price of the cart# In the first sale there is no loss or profit# -i#e#. The loss obtained is e2ual to the gain# Therefore
2A2 Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

F#

-ADMADD. < 7 B -2DMADD. < y

Technical Aptitude Questions

B 2<y

;;;;;;;;;;;;;;;;;

-A. In the second sale" he lost *s# AD# -i#e#. The loss is greater than the profit by *s# AD# Therefore -> M ADD. < 7 B -> M ADD. < y = AD ;;;;;;;-2. Substituting -A. in -2. we get -AD M ADD. < y B -> M ADD. < y = AD -> M ADD. < y B AD % > C00 Fro! -A. 2 < 2DD B x > +00 G# Ans)er0 &# 12p3anati n0 Since inclusion of any !ale player will re@ect a fe!ale fro! the tea!# Since there should be four !e!ber in the tea! and only three !ales are available" the girl" n should included in the tea! always irrespective of others selection#

AD# Ans)er0 > AA# Ans)er0 A"2"& U 1 2A&


Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

A2# Ans)er0 + A&# Ans)er0 AA U G apples per tree# 12p3anati n0 3et a" b" c" d U e be the total nu!ber of apples bored per year in A" +" C" D U 6 4s orchard# )iven that a = A B b = & B c , A B d = &Be,C +ut the 2uestion is to find the nu!ber of apples bored per tree in C and D 4s orchard# If is enough to consider c , A B d = &# Since the nu!ber of trees in C5s orchard is AA and that of D5s orchard is A&# 3et 7 and y be the nu!ber of apples bored per tree in C U d 4s orchard respectively# Therefore AA 7 , A B A& y = & +y trial and error !ethod" we get the value for 7 and y as AA and G A1# Ans)er0 )# 12p3anati n0 The order in which they are cli!bing is * , ) , _,/,H
2A1 Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

A> , AF Ans)er0 (ovel (a!e Spy thriller 'urder !ystery )othic ro!ance Science fiction 12p3anati n0 )iven (ovel (a!e Spy thriller 'urder !ystery )othic ro!ance Science fiction

Author *ath$o )or$y +urchfield /opper

8ublisher /eron 8iegon +lue@a Sparrow

Author *ath$o )or$y +urchfield /opper

8ublisher /eron 8iegon +lue@a Sparrow

2A>

Since +lue@a doesn5t publish the novel by +urchfield and /eron publishes the novel spy thriller" 8iegon publishes the novel by +urchfield# Since /opper writes )othic ro!ance and /eron publishes the novel spy thriller" +lue@a publishes the novel by /opper# Since /eron publishes the novel spy thriller and /eron publishes the novel by )or$y" )or$y writes Spy thriller and *ath$o writes 'urder !ystery#

Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

AG# Ans)er0 1>A ti!es# 12p3anati n0 There are CD !inutes in an hour# In c of an hour there are -CD < c. !inutes B 1> !inutes# In c of an hour there are -CD < 1>. seconds B 2EDD seconds# 3ight flashed for every C seconds# In 2EDD seconds 2EDDMC B 1>D ti!es# The count start after the first flash" the light will flashes 1>A ti!es in c of an hour# 2D# Ans)er0 -1. 12p3anati n0 8 A + Since p is a point on the line seg!ent A+" A+ R A8 2A# Ans)er0 -c. 22# Ans)er0 -b. U -d.#

2AC Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

Ah!ed 2& ; 2E#Ans)er0 Fa$is 2F# Ans)er0 Fa$is 12p3anati n0 =eetha )arsha 6swar +ala@i Chandra

Dhinesh CD. Ans)er0 ->.# 12p3anati n0 Since every alternative letter starting fro! + of the 6nglish alphabet is written in s!all letter" the letters written in s!all letter are b" d" f### In the first two answers the letter 6 is written in both s!all U capital letters" so they are not the correct answers# +ut in third and fourth answers the letter is written in s!all letter instead capital letter" so they are not the answers.
2AE Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

E0. Ans)er0 7B1 12p3anati n0 Since the side of the s2uare is 7 = 2" its peri!eter B 1 -7 = 2. B 17 = F Since the side of the e2uilateral triangle is 27" its peri!eter B & < 27 B C7 Also" the peri!eters of both are e2ual# -i#e#. 17 = F B C7 -i#e#. 27 B F 7 B 1# &A# Ans)er0 > -y , 2. M y# 12p3anati n0 To type a !anuscript $arthi$ too$ y hours# Therefore his speed in typing B AMy# /e was called away after 2 hours of typing# Therefore the wor$ co!pleted B AMy < 2# Therefore the re!aining wor$ to be co!pleted B A , 2My# -i#e#. wor$ to be co!pleted B -y;2.My &2# Ans)er0 -2. &&# Ans)er0 A 12p3anati n0 2AF
Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

%ne is the only nu!ber e7ists without reciprocal because the reciprocal of one is one itself# &1# Ans)er0 Sudhir had &G cars" Arvind had 2A cars and )auri had A2 cars# 12p3anati n0 Sudhir Arvind )auri Finally 21 21 21 +efore )auri5s transaction A2 1F +efore Arvind5s transaction C 21 +efore Sudhir5 s transaction &G A2

A2 12 2A

&># Ans)er0 Cost price of horse: *s# 1DD U Cost price of cart:*s# 2DD 12p3anati n0 3et 7 be the cost of horse U y be the cost of the cart# AD W of loss in selling horse B 2D W of gain in selling the cart 2AG
Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

Therefore <y

-AD M ADD. < 7 B -2D < ADD.

7 B 2y ;;;;;;;;;;;-A. > W of loss in selling the horse is AD !ore than the > W gain in selling the cart# Therefore -> M ADD. < 7 ; AD B -> M ADD. < y >7 ; ADDD B >y Substituting -A. ADy ; ADDD B >y >y B ADDD y B 2DD 7 B 1DD fro! -A. 12ercise 2.1 For the follo7in0& fin# the next term in the series A# C" 21" CD"A2D" 2AD a. &&C b. &CC c. &&D d. CCD

Ans)er : a. &&C 12p3anati n : The series is A#2#&" 2#&#1" &#1#>" 1#>#C" >#C#E" ##### - T#T !eans product. 2# A" >" A&" 2>
22D

Ans)er : 1A

Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

12p3anati n : The series is of the for! D92=A92" A92=292"### &# D" >" F" AE Ans)er : 21 12p3anati n : A92;A" 292=A" &92;A" 192=A" >92;A 1# A" F" G" C1" 2> related. -/int : 6very successive ter!s are

Ans)er : 2AC 12p3anati n : A92" 29&" &92" 19&" >92" C9& ># F"21"A2"&C"AF">1 Ans)er : 2E C# EA"EC"CG"E1"CE"E2 Ans)er : C> E# >"G"AC"2G">1 Ans)er : AD& 12p3anati n : ><2;ABGX G<2;2BACX AC<2;&B2GX 2G<2;1B>1X >1<2;>BAD& F# A"2"1"AD"AC"1D"C1 -Successive ter!s are related. Ans)er : 2DD 22A
Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

12p3anati n : The series is powers of 2 -29D"29A"##.# All digits are less than F# 6very second nu!ber is in octal nu!ber syste!# A2F should follow C1# A2F base AD B 2DD base F# 12ercise 2.2 Fin# the o## m$n out. A# &">"E"A2"A&"AE"AG Ans)er : A2 12p3anati n : All but A2 are odd nu!bers 2# 2">"AD"AE"2C"&E">D"C1 Ans)er : C1 12p3anati n : 2=&B>X >=>BADX AD=EBAEX AE=GB2CX 2C=AAB&EX &E=A&B>DX >D=A>BC>X &# AD>"F>"CD"&D"D";1>";GD Ans)er : D 12p3anati n : AD>;2DBF>X F>;2>BCDX CD;&DB&DX &D;&>B;>X ;>;1DB;1>X ;1>;1>B;GDX 12ercise 3 /ol5e the follo7in0. 222
Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

A# Ihat is the nu!ber of eros at the end of the product of the nu!bers fro! A to ADD` Ans)er : A2E 2# A fast typist can type so!e !atter in 2 hours and a slow typist can type the sa!e in & hours# If both type co!binely" in how !uch ti!e will they finish` Ans)er : A hr A2 !in 12p3anati n 0 The fast typistTs wor$ done in A hr B AM2 The slow typistTs wor$ done in A hr B AM& If they wor$ co!binely" wor$ done in A hr B AM2=AM& B >MC So" the wor$ will be co!pleted in CM> hours# i#e#" A=AM> hours B Ahr A2 !in &# )avas$arTs average in his first >D innings was >D# After the >Ast innings" his average was >A# /ow !any runs did he score in his >Ast innings# -supposing that he lost his wic$et in his >Ast innings. Ans)er : ADA 12p3anati n : Total score after >D innings B >D<>D B 2>DD Total score after >A innings B >A<>A B 2CDA So" runs !ade in the >Ast innings B 2CDA; 2>DD B ADA
22& Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

If he had not lost his wic$et in his >Ast innings" he would have scored an unbeaten >D in his >Ast innings# 1# %ut of FD coins" one is counterfeit# Ihat is the !ini!u! nu!ber of weighings needed to find out the counterfeit coin` Ans)er : 1 ># Ihat can you conclude fro! the state!ent : All green are blue" all blue are red# ` -i. so!e blue are green -ii. so!e red are green -iii. so!e green are not red -iv. all red are blue -a. i or ii but not both -b. i U ii only -c. iii or iv but not both -d. iii U iv Ans)er : -b. C# A rectangular plate with length F inches" breadth AA inches and thic$ness 2 inches is available# Ihat is the length of the circular rod with dia!eter F inches and e2ual to the volu!e of the rectangular plate` Ans)er : &#> inches
221 Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

12p3anati n : 0olu!e of the circular rod -cylinder. B 0olu!e of the rectangular plate -22ME.<1<1<h B F<AA<2 h B EM2 B &#> E# Ihat is the su! of all nu!bers between ADD and ADDD which are divisible by A1 ` Ans)er : &>&G2 12p3anati n : The nu!ber closest to ADD which is greater than ADD and divisible by A1 is AA2" which is the first ter! of the series which has to be su!!ed# The nu!ber closest to ADDD which is less than ADDD and divisible by A1 is GG1" which is the last ter! of the series# AA2 = A2C = #### = GG1 B A1-F=G= ### = EA. B &>&G2 F# If s-a. denotes s2uare root of a" find the value of s-A2=s-A2=s-A2= ###### upto infinity# Ans)er : 1 12p3anati n : 3et 7 B s-A2=s-A2=s-A2=##### Ie can write 7 B s-A2=7.# i#e#" 792 B A2 = 7# Solving this 2uadratic e2uation" we get 7 B ;& or 7B1# Su! cannot be ;ve and hence su! B 1# G# A cylindrical container has a radius of eight inches with a height of three inches# Co!pute how !any
22> Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

inches should be added to either the radius or height to give the sa!e increase in volu!e` Ans)er : ACM& inches 12p3anati n : 3et 7 be the a!ount of increase# The volu!e will increase by the sa!e a!ount if the radius increased or the height is increased# So" the effect on increasing height is e2ual to the effect on increasing the radius# i#e#" -22ME.<F<F<-&=7. B -22ME.<-F=7.<-F=7.<& Solving the 2uadratic e2uation we get the 7 B D or ACM&# The possible increase would be by ACM& inches# AD# Iith @ust si7 weights and a balance scale" you can weigh any unit nu!ber of $gs fro! A to &C1# Ihat could be the si7 weights` Ans)er : A" &" G" 2E" FA" 21& -All powers of &. AA# Diophantus passed one si7th of his life in childhood" one twelfth in youth" and one seventh !ore as a bachelorX five years after his !arriage a son was born who died four years before his father at half his final age# /ow old is Diophantus` Ans)er : F1 years 12p3anati n : 7MC = 7MA2 = 7ME = > = 7M2 = 1 B 7 A2 # If ti!e at this !o!ent is G 8#'#" what will be the ti!e 2&GGGGGGGG2 hours later` 22C
Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

Ans)er : A 8#'# 12p3anati n : 21 billion hours later" it would be G 8#'# and F hours before that it would be A 8#'# A&# /ow big will an angle of one and a half degree loo$ through a glass that !agnifies things three ti!es` Ans)er : A AM2 degrees 12p3anati n : The !agnifying glass cannot increase the !agnitude of an angle# A1# Divide 1> into four parts such that when 2 is added to the first part" 2 is subtracted fro! the second part" 2 is !ultiplied by the third part and the fourth part is divided by two" all result in the sa!e nu!ber# Ans)er: F" A2" >" 2D 12p3anati n: a = b = c = d B1>X a=2 B b;2 B 2c B dM2X aBb;1X c B -b;2.M2X d B 2-b;2.X b;1 = b = -b;2.M2 = 2-b;2. B 1>X A># I drove CD $! at &D $!ph and then an additional CD $! at >D $!ph# Co!pute !y average speed over !y A2D $!# Ans)er : &E AM2 12p3anati n : Ti!e re2d for the first CD $! B A2D !in#X Ti!e re2d for the second CD $! B E2 !in#X Total ti!e re2d B AG2 !in Avg speed B -CD<A2D.MAG2 B &E AM2 22E
Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

Auestions 10 and 15 are .ased on the following : Five e7ecutives of 6uropean Corporation hold a Conference in *o!e 'r# A converses in Spanish U Italian 'r# +" a spaniard" $nows 6nglish also 'r# C $nows 6nglish and belongs to Italy 'r# D converses in French and Spanish 'r# 6 " a native of Italy $nows French AC# Ihich of the following can act as interpreter if 'r# C U 'r# D wish to converse a. only 'r# A b. %nly 'r# + c. 'r# A U 'r# + d. Any of the other three Ans)er : d. Any of the other three# 12p3anati n : Fro! the data given" we can infer the following# A $nows Spanish" Italian + $nows Spanish" 6nglish C $nows Italian" 6nglish D $nows Spanish" French 6 $nows Italian" French To act as an interpreter between C and D" a person has to $now one of the co!binations ItalianUSpanish" ItalianUFrench" 6nglishUSpanish" 6nglishUFrench 22F
Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

A" +" and 6 $now atleast one of the co!binations# AE# If a Cth e7ecutive is brought in" to be understood by !a7i!u! nu!ber of original five he should be fluent in a. 6nglish U French b. Italian U Spanish c. 6nglish U Frenchd. French U Italian Ans)er : b. Italian U Spanish 12p3anati n : (o of e7ecutives who $now i. 6nglish is 2 ii. Spanish is & iii. Italian is & iv. French is 2 Italian U Spanish are spo$en by the !a7i!u! no of e7ecutives# So" if the Cth e7ecutive is fluent in Italian U Spanish" he can co!!unicate with all the original five because everybody $nows either Spanish or Italian# AF# Ihat is the su! of the first 2> natural odd nu!bers` Ans)er : C2> 12p3anati n : The su! of the first n natural odd nos is s2uare-n.# A=& B 1 B s2uare-2. A=&=> B G B s2uare-&.
22G Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

AG# The su! of any seven consecutive nu!bers is divisible by a. 2 b. E c. & d. AA 12ercise 3 Tr% the follo7in0.
A#

There are seventy cler$s wor$ing in a co!pany" of which &D are fe!ales# Also" &D cler$s are !arriedX 21 cler$s are above 2> years of ageX AG !arried cler$s are above 2> years" of which E are !alesX A2 !ales are above 2> years of ageX and A> !ales are !arried# /ow !any bachelor girls are there and how !any of these are above 2>` A !an sailed off fro! the (orth 8ole# After covering 2"DDD !iles in one direction he turned Iest" sailed 2"DDD !iles" turned (orth and sailed ahead another 2"DDD !iles till he !et his friend# /ow far was he fro! the (orth 8ole and in what direction`

2#

/ere is a series of co!!ents on the ages of three persons H" *" S by the!selves# S : The difference between *Ts age and !ine is three years# H : * is the youngest# 2&D
&#
Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

* : 6ither I a! 21 years old or H 2> or S 2C# H : All are above 21 years of age# S : I a! the eldest if and only if * is not the youngest# * : S is elder to !e# H : I a! the eldest# * : S is not 2E years old# S : The su! of !y age and HTs is two !ore than twice *Ts age# %ne of the three had been telling a lie throughout whereas others had spo$en the truth# Deter!ine the ages of S"H"*#
1#

In a group of five people" what is the probability of finding two persons with the sa!e !onth of birth` A father and his son go out for a Twal$;and;runT every !orning around a trac$ for!ed by an e2uilateral triangle# The fatherTs wal$ing speed is 2 !ph and his running speed is > !ph# The sonTs wal$ing and running speeds are twice that of his father# +oth start together fro! one ape7 of the triangle" the son going cloc$wise and the father anti;cloc$wise# Initially the father runs and the son wal$s for a certain period of ti!e# Thereafter" as soon as the father starts wal$ing" the son starts running# +oth co!plete the course

>#

2&A

Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

in 1> !inutes# For how long does the father run` Ihere do the two cross each other`
C#

The Director of 'edical Services was on his annual visit to the 6(T /ospital# Ihile going through the out patientsT records he ca!e across the following data for a particular day : O 6ar consultations 1>X (ose >DX Throat EDX 6ar and (ose &DX (ose and Throat 2DX 6ar and Throat &DX 6ar" (ose and Throat ADX Total patients ADD#O Then he ca!e to the conclusion that the records were bogus# Ias he right` A!ongst *a!" Sha! and )obind are a doctor" a lawyer and a police officer# They are !arried to *adha" )ita and Sita -not in order.# 6ach of the wives have a profession# )obindTs wife is an artist# *a! is not !arried to )ita# The lawyerTs wife is a teacher# *adha is !arried to the police officer# Sita is an e7pert coo$# IhoTs who` Ihat should co!e ne7t` A" 2" 1" AD" AC" 1D" C1" Auestions ?312 are .ased on the following : Three adults , *oberto" Sarah and 0ic$y , will be traveling in a van with five children , Freddy" /illary" Honathan" 3upe" and 'arta# The van has

E#

F#

2&2

Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

a driver5s seat and one passenger seat in the front" and two benches behind the front seats" one beach behind the other# 6ach bench has roo! for e7actly three people# 6veryone !ust sit in a seat or on a bench" and seating is sub@ect to the following restrictions: An adult !ust sit on each bench# 6ither *oberto or Sarah !ust sit in the driver5s seat# Honathan !ust sit i!!ediately beside 'arta#
G#

%f the following" who can sit in the front passenger seat ` -a. Honathan -b. 3upe -c. *oberto -d. Sarah -e. 0ic$y

AD# Ihich of the following groups of three can sit together on a bench` -a. Freddy" Honathan and 'arta-b. Freddy" Honathan and 0ic$y -c. Freddy" Sarah and 0ic$y -d. /illary" 3upe and Sarah -e. 3upe" 'arta and *oberto AA# If Freddy sits i!!ediately beside 0ic$y" which of the following cannot be true ` a# Honathan sits i!!ediately beside Sarah 2&&
Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

b# 3upe sits i!!ediately beside 0ic$y c# /illary sits in the front passenger seat d# Freddy sits on the sa!e bench as /illary e# /illary sits on the sa!e bench as *oberto A2# If Sarah sits on a bench that is behind where Honathan is sitting" which of the following !ust be true ` a# /illary sits in a seat or on a bench that is in front of where 'arta is sitting b# 3upe sits in a seat or on a bench that is in front of where Freddy is sitting c# Freddy sits on the sa!e bench as /illary d# 3upe sits on the sa!e bench as Sarah e# 'arta sits on the sa!e bench as 0ic$y A&# 'a$e si7 s2uares of the sa!e si e using twelve !atch;stic$s# -/int : Kou will need an adhesive to arrange the re2uired figure. A1# A far!er has two rectangular fields# The larger field has twice the length and 1 ti!es the width of the s!aller field# If the s!aller field has area _" then the are of the larger field is greater than the area of the s!aller field by what a!ount` -a. C_ -b. F_ -c. A2_ -d. E_
2&1 Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

A># (ine e2ual circles are enclosed in a s2uare whose area is &Cs2 units# Find the area of each circle# AC# There are G cards# Arrange the! in a &<& !atri7# Cards are of 1 colors# They are red" yellow" blue" green# Conditions for arrange!ent: one red card !ust be in first row or second row# 2 green cards should be in &rd colu!n# Kellow cards !ust be in the & corners only# Two blue cards !ust be in the 2nd row# At least one green card in each row# AE# Is less than w` and w are real nu!bers# -I. 2 B 2> -II. w B G To answer the 2uestion" a. 6ither I or II is sufficient b. +oth I and II are sufficient but neither of the! is alone sufficient c. I U II are sufficient d. +oth are not sufficient

AF# A spea$s truth EDW of the ti!eX + spea$s truth FDW of the ti!e# Ihat is the probability that both are contradicting each other`
2&> Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

AG# In a fa!ily E children donTt eat spinach" C donTt eat carrot" > donTt eat beans" 1 donTt eat spinach U carrots" & donTt eat carrot U beans" 2 donTt eat beans U spinach# %ne doesnTt eat all &# Find the no# of children# 2D# Anna" +ena" Catherina and Diana are at their !onthly business !eeting# Their occupations are author" biologist" che!ist and doctor" but not necessarily in that order# Diana @ust told the neighbour" who is a biologist that Catherina was on her way with doughnuts# Anna is sitting across fro! the doctor and ne7t to the che!ist# The doctor was thin$ing that +ena was a good na!e for parentTs to choose" but didnTt say anything# Ihat is each personTs occupation`

2&C Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

UNIX Concepts

?(IJ Concepts S6CTI%( ; I FI36 'A(A)6'6(T I( ?(IJ )ow are devices represented in Q&+Z? All devices are represented by files called special files that are located inMdev directory# Thus" device files and other files are na!ed and accessed in the sa!e way# A Tregular fileT is @ust an ordinary data file in the dis$# A Tbloc$ special fileT represents a device with characteristics si!ilar to a dis$ -data transfer in ter!s of bloc$s.# A Tcharacter special fileT represents a device with characteristics si!ilar to a $eyboard -data transfer is by strea! of bits in se2uential order.#
1.

What is WinodeW? All ?(IJ files have its description stored in a structure called TinodeT# The inode contains info about the file;si e" its location" ti!e of last access" ti!e of 2&E
2.
Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

last !odification" per!ission and so on# Directories are also represented as files and have an associated inode# In addition to descriptions about the file" the inode contains pointers to the data bloc$s of the file# If the file is large" inode has indirect pointer to a bloc$ of pointers to additional data bloc$s -this further aggregates for larger files.# A bloc$ is typically F$# Inode consists of the following fields: File owner identifier File type File access per!issions File access ti!es (u!ber of lin$s File si e 3ocation of the file data "rief a.out the directory representation in Q&+Z A ?ni7 directory is a file containing a correspondence between filena!es and inodes# A directory is a special file that the $ernel !aintains# %nly $ernel !odifies directories" but processes can read directories# The contents of a directory are a list of filena!e and inode nu!ber pairs# Ihen new directories are created" $ernel !a$es two entries na!ed T#T -refers to the directory itself. and T##T -refers to parent directory.#
3.
2&F Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

Syste! call for -pathna!e" !ode.#


*.

creating

directory

is

!$dir

What are the Qnix system calls for +GE? open-pathna!e"flag"!ode. ; open file creat-pathna!e"!ode. ; create file close-filedes. ; close an open file read-filedes"buffer"bytes. ; read data fro! an open file write-filedes"buffer"bytes. ; write data to an open file lsee$-filedes"offset"fro!. ; position an open file dup-filedes. ; duplicate an e7isting file descriptor dup2-oldfd"newfd. ; duplicate to a desired file descriptor fcntl-filedes"c!d"arg. ; change properties of an open file ioctl-filedes"re2uest"arg. ; change the behaviour of an open file The difference between fcntl anf ioctl is that the for!er is intended for any open file" while the latter is for device;specific operations# )ow do you change <ile 6ccess >ermissions? 6very file has following attributes: ownerTs user ID - AC bit integer . ownerTs group ID - AC bit integer . 2&G
-.
Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

File access !ode word Tr w 7 ;r w 7; r w 7T -user per!ission;group per!ission;others per!ission. r;read" w;write" 7;e7ecute To change the access !ode" we use ch!od-filena!e"!ode.# 67a!ple A: To change !ode of !yfile to Trw;rw;r;;T -ie# read" write per!ission for user ; read"write per!ission for group ; only read per!ission for others. we give the args as: ch!od-!yfile"DCC1. # 6ach operation is represented by discrete values TrT is 1 TwT is 2 T7T is A Therefore" for TrwT the value is C-1=2.# 67a!ple 2: To change !ode of !yfile to Trw7r;;r;;T we give the args as: ch!od-!yfile"DE11.# What are lin's and sym.olic lin's in Q&+Z file system? A lin$ is a second na!e -not a file. for a file# 3in$s can be used to assign !ore than one na!e to a file" but cannot be used to assign a directory !ore 21D
0.
Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

than one na!e or lin$ filena!es on different co!puters# Sy!bolic lin$ TisT a file that only contains the na!e of another file#%peration on the sy!bolic lin$ is directed to the file pointed by the it#+oth the li!itations of lin$s are eli!inated in sy!bolic lin$s# Co!!ands for lin$ing files are: 3in$ ln filena!eA filena!e2 Sy!bolic lin$ ln ;s filena!eA filena!e2 What is a <+<E? FIF% are otherwise called as Tna!ed pipesT# FIF% -first;in;first;out. is a special file which is said to be data transient# %nce data is read fro! na!ed pipe" it cannot be read again# Also" data can be read only in the order written# It is used in interprocess co!!unication where a process writes to one end of the pipe -producer. and the other reads fro! the other end -consu!er.#
5.

)ow do you create special files li'e named pipes and device files? The syste! call !$nod creates special files in the following se2uence# A# $ernel assigns new inode" 2# sets the file type to indicate that the file is a pipe" directory or special file" &# If it is a device file" it !a$es the other entries li$e 21A
7.
Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

!a@or" !inor device nu!bers# For e7a!ple: If the device is a dis$" !a@or device nu!ber refers to the dis$ controller and !inor device nu!ber is the dis$# !iscuss the mount and unmount system calls The privileged !ount syste! call is used to attach a file syste! to a directory of another file syste!X the un!ount syste! call detaches a file syste!# Ihen you !ount another file syste! on to your directory" you are essentially splicing one directory tree onto a branch in another directory tree# The first argu!ent to !ount call is the !ount point" that is " a directory in the current file na!ing syste!# The second argu!ent is the file syste! to !ount to that point# Ihen you insert a cdro! to your uni7 syste!Ts drive" the file syste! in the cdro! auto!atically !ounts to MdevMcdro! in your syste!#
?.

)ow does the inode map to data .loc' of a file? Inode has A& bloc$ addresses# The first AD are direct bloc$ addresses of the first AD data bloc$s in the file# The AAth address points to a one;level inde7 bloc$# The A2th address points to a two;level -double in;direction. inde7 bloc$# The A&th address points to a three;level-triple in;direction.inde7 bloc$# This provides a very large !a7i!u! file si e with 212
1@.
Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

efficient access to large files" but also s!all files are accessed directly in one dis$ read# What is a shell? A shell is an interactive user interface to an operating syste! services that allows an user to enter co!!ands as character strings or through a graphical user interface# The shell converts the! to syste! calls to the %S or for$s off a process to e7ecute the co!!and# Syste! call results and other infor!ation fro! the %S are presented to the user through an interactive interface# Co!!only used shells are sh"csh"$s etc#
11.

S6CTI%( ; II 8*%C6SS '%D63 and I8C 1. "rief a.out the initial process se/uence while the system .oots up. Ihile booting" special process called the TswapperT or TschedulerT is created with 8rocess;ID D# The swapper !anages !e!ory allocation for processes and influences C8? allocation# The swapper inturn creates & children: the process dispatcher" vhand and dbflush
21& Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

with IDs A"2 and & respectively# This is done by e7ecuting the file MetcMinit# 8rocess dispatcher gives birth to the shell# ?ni7 $eeps trac$ of all the processes in an internal data structure called the 8rocess Table -listing co!!and is ps ;el.# 2. What are various +!s associated with a process? ?ni7 identifies each process with a uni2ue integer called 8rocessID# The process that e7ecutes the re2uest for creation of a process is called the Tparent processT whose 8ID is T8arent 8rocess IDT# 6very process is associated with a particular user called the TownerT who has privileges over the process# The identification for the user is T?serIDT# %wner is the user who e7ecutes the process# 8rocess also has T6ffective ?ser IDT which deter!ines the access privileges for accessing resources li$e files# getpid-. ;process id getppid-. ;parent process id getuid-. ;user id geteuid-. ;effective user id 3. 1xplain for'24 system call. The efor$-.T used to create a new process fro! an e7isting process# The new process is called the child process" and the e7isting process is called the parent# Ie can tell which is which by chec$ing the return value fro! efor$-.T# The parent gets the childTs 211
Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

pid returned to hi!" but the child gets D returned to hi!# *. >redict the output of the following program code !ain-. ] for$-.X printf-O/ello Iorld!O.X ^ Ans)er0 /ello Iorld!/ello Iorld! 12p3anati n: The for$ creates a child that is a duplicate of the parent process# The child begins fro! the for$-.#All the state!ents after the call to for$-. will be e7ecuted twice#-once by the parent process and other by child.# The state!ent before for$-. is e7ecuted only by the parent process# -. >redict the output of the following program code !ain-. ] for$-.X for$-.X for$-.X printf-O/ello Iorld!O.X ^ Ans)er0 O/ello IorldO will be printed F ti!es# 12p3anati n: 21>
Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

29n ti!es where n is the nu!ber of calls to for$-. 0. List the system calls used for process management: /%stem ($lls 8es(ription for$-. To create a new process e7ec-. To e7ecute a new progra! in a process wait-. To wait until a created process co!pletes its e7ecution e7it-. To e7it fro! a process e7ecution getpid-. To get a process identifier of the current process getppid-. To get parent process identifier nice-. To bias the e7isting priority of a process br$-. To increaseMdecrease the data seg!ent si e of a process 5. )ow can you getGset an environment varia.le from a program? )etting the value of an environ!ent variable is done by using egetenv-.T# Setting the value of an environ!ent variable is done by using eputenv-.T# 7. )ow can a parent and child process communicate? A parent and child can co!!unicate through any 21C
Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

of the nor!al inter;process co!!unication sche!es -pipes" soc$ets" !essage 2ueues" shared !e!ory." but also have so!e special ways to co!!unicate that ta$e advantage of their relationship as a parent and child# %ne of the !ost obvious is that the parent can get the e7it status of the child# ?. What is a Com.ie? Ihen a progra! for$s and the child finishes before the parent" the $ernel still $eeps so!e of its infor!ation about the child in case the parent !ight need it ; for e7a!ple" the parent !ay need to chec$ the childTs e7it status# To be able to get this infor!ation" the parent calls ewait-.TX In the interval between the child ter!inating and the parent calling ewait-.T" the child is said to be a e o!bieT -If you do epsT" the child will have a efT in its status field to indicate this#. 1@. What are the process states in Qnix? As a process e7ecutes it changes state according to its circu!stances# ?ni7 processes have the following states: *unning : The process is either running or it is ready to run # Iaiting : The process is waiting for an event or for a resource# Stopped : The process has been stopped" usually 21E
Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

by receiving a signal# fo!bie : The process is dead but have not been re!oved fro! the process table# 11. What )appens when you execute a program? Ihen you e7ecute a progra! on your ?(IJ syste!" the syste! creates a special environ!ent for that progra!# This environ!ent contains everything needed for the syste! to run the progra! as if no other progra! were running on the syste!# 6ach process has process conte7t" which is everything that is uni2ue about the state of the progra! you are currently running# 6very ti!e you e7ecute a progra! the ?(IJ syste! does a for$" which perfor!s a series of operations to create a process conte7t and then e7ecute your progra! in that conte7t# The steps include the following: Allocate a slot in the process table" a list of currently running progra!s $ept by ?(IJ# Assign a uni2ue process identifier -8ID. to the process# iCopy the conte7t of the parent" the process that re2uested the spawning of the new process# *eturn the new 8ID to the parent process# This enables the parent process to e7a!ine or control the process directly# After the for$ is co!plete" ?(IJ runs your progra!#
21F Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

12. What )appens when you execute a command? Ihen you enter TlsT co!!and to loo$ at the contents of your current wor$ing directory" ?(IJ does a series of things to create an environ!ent for ls and the run it: The shell has ?(IJ perfor! a for$# This creates a new process that the shell will use to run the ls progra!# The shell has ?(IJ perfor! an e7ec of the ls progra!# This replaces the shell progra! and data with the progra! and data for ls and then starts running that new progra!# The ls progra! is loaded into the new process conte7t" replacing the te7t and data of the shell# The ls progra! perfor!s its tas$" listing the contents of the current directory# 13. What is a !aemon? A dae!on is a process that detaches itself fro! the ter!inal and runs" disconnected" in the bac$ground" waiting for re2uests and responding to the!# It can also be defined as the bac$ground process that does not belong to a ter!inal session# 'any syste! functions are co!!only perfor!ed by dae!ons" including the send!ail dae!on" which handles !ail" and the ((T8 dae!on" which handles ?S6(6T news# 'any other dae!ons !ay e7ist# So!e of the !ost co!!on dae!ons are: 21Ginit: Ta$es over the basic running of the syste!
Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

when the $ernel has finished the boot process# inetd: *esponsible for starting networ$ services that do not have their own stand;alone dae!ons# For e7a!ple" inetd usually ta$es care of inco!ing rlogin" telnet" and ftp connections# cron: *esponsible for running repetitive tas$s on a regular schedule# 1*. What is WpsW command for? The ps co!!and prints the process status for so!e or all of the running processes# The infor!ation given are the process identification nu!ber -8ID."the a!ount of ti!e that the process has ta$en to e7ecute so far etc# 1-. )ow would you 'ill a process? The $ill co!!and ta$es the 8ID as one argu!entX this identifies which process to ter!inate# The 8ID of a process can be got using TpsT co!!and# 10. What is an advantage of executing a process in .ac'ground? The !ost co!!on reason to put a process in the bac$ground is to allow you to do so!ething else interactively without waiting for the process to co!plete# At the end of the co!!and you add the special bac$ground sy!bol" U# This sy!bol tells your shell to e7ecute the given co!!and in the 2>D
Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

bac$ground# 67a!ple: cp <#< ##Mbac$upU copy.

-cp is for

15. )ow do you execute one program from within another? The syste! calls used for low;level process creation are e7eclp-. and e7ecvp-.# The e7eclp call overlays the e7isting progra! with the new one " runs that and e7its# The original progra! gets bac$ control only when an error occurs# e7eclp-path"fileNna!e"argu!ents##.X MMlast argu!ent !ust be (?33 A variant of e7eclp called e7ecvp is used when the nu!ber of argu!ents is not $nown in advance# e7ecvp-path"argu!entNarray.X MMargu!ent array should be ter!inated by (?33 17. What is +>,? What are the various schemes availa.le? The ter! I8C -Inter;8rocess Co!!unication. describes various ways by which different process running on so!e operating syste! co!!unicate between each other# 0arious sche!es available are as follows: >ipes: %ne;way co!!unication sche!e through which different process can co!!unicate# The 2>A
Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

proble! is that the two processes should have a co!!on ancestor -parent;child relationship.# /owever this proble! was fi7ed with the introduction of na!ed;pipes -FIF%.# #essage Aueues : 'essage 2ueues can be used between related and unrelated processes running on a !achine# $hared #emory: This is the fastest of all I8C sche!es# The !e!ory to be shared is !apped into the address space of the processes -that are sharing.# The speed achieved is attributed to the fact that there is no $ernel involve!ent# +ut this sche!e needs synchroni ation# 0arious for!s of synchronisation are !ute7es" condition;variables" read;write loc$s" record;loc$s" and se!aphores# S6CTI%( ; III '6'%*K 'A(A)6'6(T 1. What is the difference .etween $wapping and >aging? $wapping:
2>2 Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

Ihole process is !oved fro! the swap device to the !ain !e!ory for e7ecution# 8rocess si e !ust be less than or e2ual to the available !ain !e!ory# It is easier to i!ple!entation and overhead to the syste!# Swapping syste!s does not handle the !e!ory !ore fle7ibly as co!pared to the paging syste!s# >aging: %nly the re2uired !e!ory pages are !oved to !ain !e!ory fro! the swap device for e7ecution# 8rocess si e does not !atter# )ives the concept of the virtual !e!ory# It provides greater fle7ibility in !apping the virtual address space into the physical !e!ory of the !achine# Allows !ore nu!ber of processes to fit in the !ain !e!ory si!ultaneously# Allows the greater process si e than the available physical !e!ory# De!and paging syste!s handle the !e!ory !ore fle7ibly# 2. What is major difference .etween the )istoric Qnix and the new "$! release of Qnix $ystem B in terms of #emory #anagement? /istoric ?ni7 uses Swapping , entire process is transferred to the !ain !e!ory fro! the swap device" whereas the ?ni7 Syste! 0 uses De!and 8aging , only the part of the process is !oved to the
2>& Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

!ain !e!ory# /istoric ?ni7 uses one Swap Device and ?ni7 Syste! 0 allow !ultiple Swap Devices# 3. What is the main goal of the #emory #anagement? It decides which process should reside in the !ain !e!ory" 'anages the parts of the virtual address space of a process which is non;core resident" 'onitors the available !ain !e!ory and periodically write the processes into the swap device to provide !ore processes fit in the !ain !e!ory si!ultaneously# *. What is a #ap? A 'ap is an Array" which contains the addresses of the free space in the swap device that are allocatable resources" and the nu!ber of the resource units available there#
Address A ?nits AD"DDD

This allows First;Fit allocation of contiguous bloc$s of a resource# Initially the 'ap contains one
2>1 Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

entry , address -bloc$ offset fro! the starting of the swap area. and the total nu!ber of resources# _ernel treats each unit of 'ap as a group of dis$ bloc$s# %n the allocation and freeing of the resources _ernel updates the 'ap for accurate infor!ation# -. What scheme does the [ernel in Qnix $ystem B follow while choosing a swap device among the multiple swap devices? _ernel follows *ound *obin sche!e choosing a swap device a!ong the !ultiple swap devices in ?ni7 Syste! 0# 0. What is a egion? A *egion is a continuous area of a process5s address space -such as te7t" data and stac$.# The $ernel in a 4*egion Table5 that is local to the process !aintains region# *egions are sharable a!ong the process# 5. What are the events done .y the [ernel after a process is .eing swapped out from the main memory? Ihen _ernel swaps the process out of the pri!ary !e!ory" it perfor!s the following: _ernel decre!ents the *eference Count of each region of the process# If the reference
2>> Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

count beco!es ero" swaps the region out of the !ain !e!ory" _ernel allocates the space for the swapping process in the swap device" _ernel loc$s the other swapping process while the current swapping operation is going on" The _ernel saves the swap address of the region in the region table# 7. +s the >rocess .efore and after the swap are the same? =ive reason. 8rocess before swapping is residing in the pri!ary !e!ory in its original for!# The regions -te7t" data and stac$. !ay not be occupied fully by the process" there !ay be few e!pty slots in any of the regions and while swapping _ernel do not bother about the e!pty slots while swapping the process out# After swapping the process resides in the swap -secondary !e!ory. device# The regions swapped out will be present but only the occupied region slots but not the e!pty slots that were present before assigning# Ihile swapping the process once again into the !ain !e!ory" the _ernel referring to the 8rocess 'e!ory 'ap" it assigns the !ain !e!ory accordingly ta$ing care of the e!pty slots in the regions#
2>C Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

?. What do you mean .y u3area 2user area4 or u3 .loc'? This contains the private data that is !anipulated only by the _ernel# This is local to the 8rocess" i#e# each process is allocated a u;area# 1@. What are the entities that are swapped out of the main memory while swapping the process out of the main memory? All !e!ory space occupied by the process" process5s u;area" and _ernel stac$ are swapped out" theoretically# 8ractically" if the process5s u;area contains the Address Translation Tables for the process then _ernel i!ple!entations do not swap the u;area# 11. What is <or' swap? for$-. is a syste! call to create a child process# Ihen the parent process calls for$-. syste! call" the child process is created and if there is short of !e!ory then the child process is sent to the read;to; run state in the swap device" and return to the user state without swapping the parent process# Ihen the !e!ory will be available the child process will be swapped into the !ain !e!ory# 12. What is 1xpansion swap? 2>E
Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

At the ti!e when any process re2uires !ore !e!ory than it is currently allocated" the _ernel perfor!s 67pansion swap# To do this _ernel reserves enough space in the swap device# Then the address translation !apping is ad@usted for the new virtual address space but the physical !e!ory is not allocated# At last _ernel swaps the process into the assigned space in the swap device# 3ater when the _ernel swaps the process into the !ain !e!ory this assigns !e!ory according to the new address translation !apping# 13. )ow the $wapper wor's? The swapper is the only process that swaps the processes# The Swapper operates only in the _ernel !ode and it does not uses Syste! calls instead it uses internal _ernel functions for swapping# It is the archetype of all $ernel process# 1*. What are the processes that are not .othered .y the swapper? =ive eason. fo!bie process: They do not ta$e any up physical !e!ory# 8rocesses loc$ed in !e!ories that are updating the region of the process# _ernel swaps only the sleeping processes rather than the 4ready;to;run5 processes" as
2>F Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

they have the higher probability of being scheduled than the Sleeping processes# 1-. What are the re/uirements for a swapper to wor'? The swapper wor$s on the highest scheduling priority# Firstly it will loo$ for any sleeping process" if not found then it will loo$ for the ready;to;run process for swapping# +ut the !a@or re2uire!ent for the swapper to wor$ the ready;to;run process !ust be core;resident for at least 2 seconds before swapping out# And for swapping in the process !ust have been resided in the swap device for at least 2 seconds# If the re2uire!ent is not satisfied then the swapper will go into the wait state on that event and it is awa$en once in a second by the _ernel# 10. What are the criteria for choosing a process for swapping into memory from the swap device? The resident ti!e of the processes in the swap device" the priority of the processes and the a!ount of ti!e the processes had been swapped out# 15. What are the criteria for choosing a process for swapping out of the memory to the swap device? The process5s !e!ory resident ti!e" 8riority of the process and
2>G Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

The nice value# 17. What do you mean .y nice value? (ice value is the value that controls ]incre!ents or decre!ents^ the priority of the process# This value that is returned by the nice -. syste! call# The e2uation for using nice value is: >riority I 2\recent ,>Q usage]Gconstant4 8 2.ase3 priority4 8 2nice value4 %nly the ad!inistrator can supply the nice value# The nice -. syste! call wor$s for the running process only# (ice value of one process cannot affect the nice value of the other process# 1?. What are conditions on which deadloc' can occur while swapping the processes? All processes in the !ain !e!ory are asleep# All 4ready;to;run5 processes are swapped out# There is no space in the swap device for the new inco!ing process that are swapped out of the !ain !e!ory# There is no space in the !ain !e!ory for the new inco!ing process# 2@. What are conditions for a machine to support !emand >aging? 'e!ory architecture !ust based on 8ages"
2CD Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

The !achine !ust support the 4restartable5 instructions# 21. What is Xthe principle of localityF? It5s the nature of the processes that they refer only to the s!all subset of the total data space of the process# i#e# the process fre2uently calls the sa!e subroutines or e7ecutes the loop instructions# 22. What is the wor'ing set of a process? The set of pages that are referred by the process in the last 4n5" references" where 4n5 is called the window of the wor$ing set of the process# 23. What is the window of the wor'ing set of a process? The window of the wor$ing set of a process is the total nu!ber in which the process had referred the set of pages in the wor$ing set of the process# 2*. What is called a page fault? 8age fault is referred to the situation when the process addresses a page in the wor$ing set of the process but the process fails to locate the page in the wor$ing set# And on a page fault the $ernel updates the wor$ing set by reading the page fro! the secondary device#
2CA Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

2-. What are data structures that are used for !emand >aging? _ernel contains 1 data structures for De!and paging# They are" 8age table entries" Dis$ bloc$ descriptors" 8age fra!e data table -pfdata." Swap;use table# 20. What are the .its that support the demand paging? 0alid" *eference" 'odify" Copy on write" Age# These bits are the part of the page table entry" which includes physical address of the page and protection bits# 8age Ag Copy on address e write 'od *efere 0al 8rotecti ify nce id on

25. )ow the [ernel handles the for'24 system call in traditional Qnix and in the $ystem B Qnix% while swapping? _ernel in traditional ?ni7" !a$es the duplicate copy of the parent5s address space and attaches it to the child5s process" while swapping# _ernel in Syste! 0 ?ni7" !anipulates the region tables" page
2C2 Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

table" and pfdata table entries" by incre!enting the reference count of the region table of shared regions# 27. !ifference .etween the for'24 and vfor'24 system call? During the for$-. syste! call the _ernel !a$es a copy of the parent process5s address space and attaches it to the child process# +ut the vfor$-. syste! call do not !a$es any copy of the parent5s address space" so it is faster than the for$-. syste! call# The child process as a result of the vfor$-. syste! call e7ecutes e7ec-. syste! call# The child process fro! vfor$-. syste! call e7ecutes in the parent5s address space -this can overwrite the parent5s data and stac$ . which suspends the parent process until the child process e7its# 2?. What is "$$2"loc' $tarted .y $ym.ol4? A data representation at the !achine level" that has initial values when a progra! starts and tells about how !uch space the $ernel allocates for the un; initiali ed data# _ernel initiali es it to ero at run; ti!e# 3@. What is >age3$tealer process? This is the _ernel process that !a$es roo!s for the inco!ing pages" by swapping the !e!ory pages that are not the part of the wor$ing set of a process# 2C&
Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

8age;Stealer is created by the _ernel at the syste! initiali ation and invo$es it throughout the lifeti!e of the syste!# _ernel loc$s a region when a process faults on a page in the region" so that page stealer cannot steal the page" which is being faulted in# 31. &ame two paging states for a page in memory? The two paging states are: The page is aging and is not yet eligible for swapping" The page is eligible for swapping but not yet eligible for reassign!ent to other virtual address space# 32. What are the phases of swapping a page from the memory? 8age stealer finds the page eligible for swapping and places the page nu!ber in the list of pages to be swapped# _ernel copies the page to a swap device when necessary and clears the valid bit in the page table entry" decre!ents the pfdata reference count" and places the pfdata table entry at the end of the free list if its reference count is D# 33. What is page fault? +ts types?
2C1 Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

8age fault refers to the situation of not having a page in the !ain !e!ory when any process references it# There are two types of page fault : 0alidity fault" 8rotection fault# 3*. +n what way the <ault )andlers and the +nterrupt handlers are different? Fault handlers are also an interrupt handler with an e7ception that the interrupt handlers cannot sleep# Fault handlers sleep in the conte7t of the process that caused the !e!ory fault# The fault refers to the running process and no arbitrary processes are put to sleep# 3-. What is validity fault? If a process referring a page in the !ain !e!ory whose valid bit is not set" it results in validity fault# The valid bit is not set for those pages: that are outside the virtual address space of a process" that are the part of the virtual address space of the process but no physical address is assigned to it# 30. What does the swapping system do if it identifies the illegal page for swapping?
2C> Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

If the dis$ bloc$ descriptor does not contain any record of the faulted page" then this causes the atte!pted !e!ory reference is invalid and the $ernel sends a \$egmentation violation] signal to the offending process# This happens when the swapping syste! identifies any invalid !e!ory reference# 35. What are states that the page can .e in% after causing a page fault? %n a swap device and not in !e!ory" %n the free page list in the !ain !e!ory" In an e7ecutable file" 'ar$ed [de!and ero\" 'ar$ed [de!and fill\# 37. +n what way the validity fault handler concludes? It sets the valid bit of the page by clearing the !odify bit# It recalculates the process priority# 3?. 6t what mode the fault handler executes? At the _ernel 'ode# *@. What do you mean .y the protection fault? 8rotection fault refers to the process accessing the pages" which do not have the access per!ission#
2CC Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

A process also incur the protection fault when it atte!pts to write a page whose copy on write bit was set during the for$-. syste! call# *1. )ow the [ernel handles the copy on write .it of a page% when the .it is set? In situations li$e" where the copy on write bit of a page is set and that page is shared by !ore than one process" the _ernel allocates new page and copies the content to the new page and the other processes retain their references to the old page# After copying the _ernel updates the page table entry with the new page nu!ber# Then _ernel decre!ents the reference count of the old pfdata table entry# In cases li$e" where the copy on write bit is set and no processes are sharing the page" the _ernel allows the physical page to be reused by the processes# +y doing so" it clears the copy on write bit and disassociates the page fro! its dis$ copy -if one e7ists." because other process !ay share the dis$ copy# Then it re!oves the pfdata table entry fro! the page;2ueue as the new copy of the virtual page is not on the swap device# It decre!ents the swap;use count for the page and if count drops to D" frees the swap space# *2. <or which 'ind of fault the page is chec'ed first?
2CE Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

The page is first chec$ed for the validity fault" as soon as it is found that the page is invalid -valid bit is clear." the validity fault handler returns i!!ediately" and the process incur the validity page fault# _ernel handles the validity fault and the process will incur the protection fault if any one is present# *3. +n what way the protection fault handler concludes? After finishing the e7ecution of the fault handler" it sets the modify and protection bits and clears the copy on write bit# It recalculates the process;priority and chec$s for signals# **. )ow the [ernel handles .oth the page stealer and the fault handler? The page stealer and the fault handler thrash because of the shortage of the !e!ory# If the su! of the wor$ing sets of all processes is greater that the physical !e!ory then the fault handler will usually sleep because it cannot allocate pages for a process# This results in the reduction of the syste! throughput because _ernel spends too !uch ti!e in overhead" rearranging the !e!ory in the frantic pace#

2CF Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

RDBMS Concepts

*D+'S Concepts 1. What is data.ase? A database is a logically coherent collection of data with so!e inherent !eaning" representing so!e aspect of real world and which is designed" built and populated with data for a specific purpose# 2. What is !"#$? It is a collection of progra!s that enables user to create and !aintain a database# In other words it is general;purpose software that provides the users with the processes of defining" constructing and manipulating the database for various applications# 3. What is a !ata.ase system? The database and D+'S software together is called as Database syste!# *. 6dvantages of !"#$? 2CG
Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

*edundancy is controlled# ?nauthorised access is restricted# 8roviding !ultiple user interfaces# 6nforcing integrity constraints# 8roviding bac$up and recovery# -. !isadvantage in <ile >rocessing $ystem? Data redundancy U inconsistency# Difficult in accessing data# Data isolation# Data integrity# Concurrent access is not possible# Security 8roble!s# 0. !escri.e the three levels of data a.straction? The are three levels of abstraction: >hysical level: The lowest level of abstraction describes how data are stored# Logical level: The ne7t higher level of abstraction" describes what data are stored in database and what relationship a!ong those data# Biew level: The highest level of abstraction describes only part of entire database# 5. !efine the Kintegrity rulesK There are two Integrity rules#
2ED Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

1ntity +ntegrity: States that [8ri!ary $ey cannot have (?33 value\ eferential +ntegrity: States that [Foreign _ey can be either a (?33 value or should be 8ri!ary _ey value of other relation# 7. What is extension and intension? 1xtension ; It is the nu!ber of tuples present in a table at any instance# This is ti!e dependent# +ntension ; It is a constant value that gives the na!e" structure of table and the constraints laid on it# ?. What is $ystem ? What are its two major su.systems? Syste! * was designed and developed over a period of AGE1;EG at I+' San Hose *esearch Center# It is a prototype and its purpose was to de!onstrate that it is possible to build a *elational Syste! that can be used in a real life environ!ent to solve real life proble!s" with perfor!ance at least co!parable to that of e7isting syste!# Its two subsyste!s are *esearch Storage Syste! *elational Data Syste!#
2EA Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

1@. )ow is the data structure of $ystem different from the relational structure? ?nli$e *elational syste!s in Syste! * Do!ains are not supported 6nforce!ent of candidate $ey uni2ueness is optional 6nforce!ent of entity integrity is optional *eferential integrity is not enforced 11. What is !ata +ndependence? Data independence !eans that [the application is independent of the storage structure and access strategy of data\# In other words" The ability to !odify the sche!a definition in one level should not affect the sche!a definition in the ne7t higher level# Two types of Data Independence: 8hysical Data Independence: 'odification in physical level should not affect the logical level# 3ogical Data Independence: 'odification in logical level should affect the view level# &ED1: Logical !ata +ndependence is more difficult to achieve 12. What is a view? )ow it is related to data independence?
2E2 Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

A view !ay be thought of as a virtual table" that is" a table that does not really e7ist in its own right but is instead derived fro! one or !ore underlying base table# In other words" there is no stored file that direct represents the view instead a definition of view is stored in data dictionary# )rowth and restructuring of base tables is not reflected in views# Thus the view can insulate users fro! the effects of restructuring and growth in the database# /ence accounts for logical data independence# 13. What is !ata #odel? A collection of conceptual tools for describing data" data relationships data se!antics and constraints# 1*. What is 13 model? This data !odel is based on real world that consists of basic ob@ects called entities and of relationship a!ong these ob@ects# 6ntities are described in a database by a set of attributes# 1-. What is E.ject Eriented model? This !odel is based on collection of ob@ects# An ob@ect contains values stored in instance variables with in the ob@ect# An ob@ect also contains bodies of code that operate on the ob@ect# These bodies of 2E&
Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

code are called !ethods# %b@ects that contain sa!e types of values and the sa!e !ethods are grouped together into classes# 10. What is an 1ntity? It is a TthingT in the real world with an independent e7istence# 15. What is an 1ntity type? It is a collection -set. of entities that have sa!e attributes# 17. What is an 1ntity set? It is a collection of all entities of particular entity type in the database# 1?. What is an 1xtension of entity type? The collections of entities of a particular entity type are grouped together into an entity set# 2@. What is Wea' 1ntity set? An entity set !ay not have sufficient attributes to for! a pri!ary $ey" and its pri!ary $ey co!pro!ises of its partial $ey and pri!ary $ey of its parent entity" then it is said to be Iea$ 6ntity set# 21. What is an attri.ute?
2E1 Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

It is a particular property" which describes the entity# 22. What is a elation $chema and a elation? A relation Sche!a denoted by *-AA" A2" L" An. is !ade up of the relation na!e * and the list of attributes Ai that it contains# A relation is defined as a set of tuples# 3et r be the relation which contains set tuples -tA" t2" t&" ###" tn.# 6ach tuple is an ordered list of n;values tB-vA"v2" ###" vn.# 23. What is degree of a elation? It is the nu!ber of attribute of its relation sche!a# 2*. What is elationship? It is an association a!ong two or !ore entities# 2-. What is elationship set? The collection -or set. of si!ilar relationships# 20. What is elationship type? *elationship type defines a set of associations or a relationship set a!ong a given set of entity types# 25. What is degree of elationship type? It is the nu!ber of entity type participating#
2E> Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

2-. What is !!L 2!ata !efinition Language4? A data base sche!a is specifies by a set of definitions e7pressed by a special language called DD3# 20. What is B!L 2Biew !efinition Language4? It specifies user views and their !appings to the conceptual sche!a# 25. What is $!L 2$torage !efinition Language4? This language is to specify the internal sche!a# This language !ay specify the !apping between two sche!as# 27. What is !ata $torage 3 !efinition Language? The storage structures and access !ethods used by database syste! are specified by a set of definition in a special type of DD3 called data storage; definition language# 2?. What is !#L 2!ata #anipulation Language4? This language that enable user to access or !anipulate data as organised by appropriate data !odel# >rocedural !#L or Low level: D'3 re2uires a user to specify what data are needed and how to get those data#
2EC Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

&on3>rocedural !#L or )igh level: D'3 re2uires a user to specify what data are needed without specifying how to get those data# 31. What is !#L ,ompiler? It translates D'3 state!ents in a 2uery language into low;level instruction that the 2uery evaluation engine can understand# 32. What is Auery evaluation engine? It e7ecutes low;level instruction generated by co!piler# 33. What is !!L +nterpreter? It interprets DD3 state!ents and record the! in tables containing !etadata# 3*. What is ecord3at3a3time? The 3ow level or 8rocedural D'3 can specify and retrieve each record fro! a set of records# This retrieve of a record is said to be *ecord;at;a;ti!e# 3-. What is $et3at3a3time or $et3oriented? The /igh level or (on;procedural D'3 can specify and retrieve !any records in a single D'3 state!ent# This retrieve of a record is said to be Set; at;a;ti!e or Set;oriented#
2EE Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

30. What is elational 6lge.ra? It is procedural 2uery language# It consists of a set of operations that ta$e one or two relations as input and produce a new relation# 35. What is elational ,alculus? It is an applied predicate calculus specifically tailored for relational databases proposed by 6#F# Codd# 6#g# of languages based on it are DS3 A38/A" Q?63# 37. )ow does Duple3oriented relational calculus differ from domain3oriented relational calculus The tuple;oriented calculus uses a tuple variables i#e#" variable whose only per!itted values are tuples of that relation# 6#g# Q?63 The do!ain;oriented calculus has do!ain variables i#e#" variables that range over the underlying do!ains instead of over relation# 6#g# I33" D6D?C6# 3?. What is normaliCation? It is a process of analysing the given relation sche!as based on their Functional Dependencies -FDs. and pri!ary $ey to achieve the properties 'ini!i ing redundancy 'ini!i ing insertion" deletion and update ano!alies#
2EF Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

*@. What is <unctional !ependency? A Functional dependency is denoted by J K between two sets of attributes J and K that are subsets of * specifies a constraint on the possible tuple that can for! a relation state r of *# The constraint is for any two tuples tA and t2 in r if tAPJQ B t2PJQ then they have tAPKQ B t2PKQ# This !eans the value of J co!ponent of a tuple uni2uely deter!ines the value of co!ponent K# *1. When is a functional dependency < said to .e minimal? 6very dependency in F has a single attribute for its right hand side# Ie cannot replace any dependency J A in F with a dependency K A where K is a proper subset of J and still have a set of dependency that is e2uivalent to F# Ie cannot re!ove any dependency fro! F and still have set of dependency that is e2uivalent to F# *2. What is #ultivalued dependency? 'ultivalued dependency denoted by J K specified on relation sche!a *" where J and K are both subsets of *" specifies the following constraint on any relation r of *: if two tuples tA and t2 e7ist in
2EG Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

r such that tAPJQ B t2PJQ then t& and t1 should also e7ist in r with the following properties t&P7Q B t1PJQ B tAPJQ B t2PJQ t&PKQ B tAPKQ and t1PKQ B t2PKQ t&PfQ B t2PfQ and t1PfQ B tAPfQ where Pf B -*;-J ? K.. Q *3. What is Lossless join property? It guarantees that the spurious tuple generation does not occur with respect to relation sche!as after deco!position# **. What is 1 &< 2&ormal <orm4? The do!ain of attribute !ust include only ato!ic -si!ple" indivisible. values# *-. What is <ully <unctional dependency? It is based on concept of full functional dependency# A functional dependency J K is full functional dependency if re!oval of any attribute A fro! J !eans that the dependency does not hold any !ore# *0. What is 2&<? A relation sche!a * is in 2(F if it is in A(F and every non;pri!e attribute A in * is fully functionally dependent on pri!ary $ey#
2FD Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

*5. What is 3&<? A relation sche!a * is in &(F if it is in 2(F and for every FD J A either of the following is true J is a Super;$ey of *# A is a pri!e attribute of *# In other words" if every non pri!e attribute is non;transitively dependent on pri!ary $ey# *7. What is ",&< 2"oyce3,odd &ormal <orm4? A relation sche!a * is in +C(F if it is in &(F and satisfies an additional constraint that for every FD J A" J !ust be a candidate $ey# *?. What is *&<? A relation sche!a * is said to be in 1(F if for every 'ultivalued dependency J K that holds over *" one of following is true J is subset or e2ual to -or. JK B *# J is a super $ey# -@. What is -&<? A *elation sche!a * is said to be >(F if for every @oin dependency ]*A" *2" ###" *n^ that holds *" one the following is true *i B * for so!e i#
2FA Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

The @oin dependency is i!plied by the set of FD" over * in which the left side is $ey of *# -1. What is !omain3[ey &ormal <orm? A relation is said to be in D_(F if all constraints and dependencies that should hold on the the constraint can be enforced by si!ply enforcing the do!ain constraint and $ey constraint on the relation# -2. What are partial% alternate%% artificial% compound and natural 'ey? >artial [ey: It is a set of attributes that can uni2uely identify wea$ entities and that are related to sa!e owner entity# It is so!eti!e called as Discri!inator# 6lternate [ey: All Candidate _eys e7cluding the 8ri!ary _ey are $nown as Alternate _eys# 6rtificial [ey: If no obvious $ey" either stand alone or co!pound is available" then the last resort is to si!ply create a $ey" by assigning a uni2ue nu!ber to each record or occurrence# Then this is $nown as developing an artificial $ey# ,ompound [ey0 If no single data ele!ent uni2uely identifies occurrences within a construct" then co!bining
2F2 Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

!ultiple ele!ents to create a uni2ue identifier for the construct is $nown as creating a co!pound $ey# &atural [ey0 Ihen one of the data ele!ents stored within a construct is utili ed as the pri!ary $ey" then it is called the natural $ey# -3. What is indexing and what are the different 'inds of indexing? Inde7ing is a techni2ue for deter!ining how 2uic$ly specific data can be found# Types: +inary search style inde7ing +;Tree inde7ing Inverted list inde7ing 'e!ory resident table Table inde7ing -*. What is system catalog or catalog relation? )ow is .etter 'nown as? A *D+'S !aintains a description of all the data that it contains" infor!ation about every relation and inde7 that it contains# This infor!ation is stored in a collection of relations !aintained by the syste! called !etadata# It is also called data dictionary# --. What is meant .y /uery optimiCation?
2F& Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

The phase that identifies an efficient e7ecution plan for evaluating a 2uery that has the least esti!ated cost is referred to as 2uery opti!i ation# -0. What is join dependency and inclusion dependency? Yoin !ependency: A Hoin dependency is generali ation of 'ultivalued dependency#A HD ]*A" *2" ###" *n^ is said to hold over a relation * if *A" *2" *&" ###" *n is a lossless;@oin deco!position of * # There is no set of sound and co!plete inference rules for HD# +nclusion !ependency: An Inclusion Dependency is a state!ent of the for! that so!e colu!ns of a relation are contained in other colu!ns# A foreign $ey constraint is an e7a!ple of inclusion dependency# -5. What is dura.ility in !"#$? %nce the D+'S infor!s the user that a transaction has successfully co!pleted" its effects should persist even if the syste! crashes before all its changes are reflected on dis$# This property is called durability# -7. What do you aggregation? 6tomicity: 2F1 mean .y atomicity and

Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

6ither all actions are carried out or none are# ?sers should not have to worry about the effect of inco!plete transactions# D+'S ensures this by undoing the actions of inco!plete transactions# 6ggregation: A concept which is used to !odel a relationship between a collection of entities and relationships# It is used when we need to e7press a relationship a!ong relationships# -?. What is a >hantom !eadloc'? In distributed deadloc$ detection" the delay in propagating local infor!ation !ight cause the deadloc$ detection algorith!s to identify deadloc$s that do not really e7ist# Such situations are called phanto! deadloc$s and they lead to unnecessary aborts# 0@. What is a chec'point and When does it occur? A Chec$point is li$e a snapshot of the D+'S state# +y ta$ing chec$points" the D+'S can reduce the a!ount of wor$ to be done during restart in the event of subse2uent crashes# 01. What are the different phases of transaction? Different phases are Analysis phase *edo 8hase 2F>
Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

?ndo phase 02. What do you mean .y flat file data.ase? It is a database in which there are no progra!s or user access languages# It has no cross;file capabilities but is user;friendly and provides user;interface !anage!ent# 03. What is Ktransparent !"#$K? It is one" which $eeps its 8hysical Structure hidden fro! user# 0*. "rief theory of &etwor'% )ierarchical schemas and their properties (etwor$ sche!a uses a graph data structure to organi e records e7a!ple for such a database !anage!ent syste! is CTC) while a hierarchical sche!a uses a tree data structure e7a!ple for such a syste! is I'S# 0-. What is a /uery? A 2uery with respect to D+'S relates to user co!!ands that are used to interact with a data base# The 2uery language can be classified into data definition language and data !anipulation language# 00. What do you mean .y ,orrelated su./uery?
2FC Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

Sub2ueries" or nested 2ueries" are used to bring bac$ a set of rows to be used by the parent 2uery# Depending on how the sub2uery is written" it can be e7ecuted once for the parent 2uery or it can be e7ecuted once for each row returned by the parent 2uery# If the sub2uery is e7ecuted for each row of the parent" this is called a correlated su./uery# A correlated sub2uery can be easily identified if it contains any references to the parent sub2uery colu!ns in its I/6*6 clause# Colu!ns fro! the sub2uery cannot be referenced anywhere else in the parent 2uery# The following e7a!ple de!onstrates a non;correlated sub2uery# 6#g# Select < Fro! C?ST Ihere TADMD&MAGGDT I( -Select %DAT6 Fro! %*D6* Ihere C?ST#C(?' B %*D6*#C(?'. 05. What are the primitive operations common to all record management systems? Addition" deletion and !odification# 07. &ame the .uffer in which all the commands that are typed in are stored GH#it" +uffer 0?. What are the unary operations in 6lge.ra? 8*%H6CTI%( and S636CTI%(# 2FE
Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

elational

Technical Aptitude Questions

5@. 6re the resulting relations of > E!Q,D and YE+& operation the same? (o# > E!Q,D: Concatenation of every row in one relation with every row in another# YE+&: Concatenation of rows fro! one relation and related rows fro! another# 51. What is !"#$ [1 &1L? Two i!portant pieces of *D+'S architecture are the $ernel" which is the software" and the data dictionary" which consists of the syste!;level data structures used by the $ernel to !anage the database Kou !ight thin$ of an *D+'S as an operating syste! -or set of subsyste!s." designed specifically for controlling data accessX its pri!ary functions are storing" retrieving" and securing data# An *D+'S !aintains its own list of authori ed users and their associated privilegesX !anages !e!ory caches and pagingX controls loc$ing for concurrent resource usageX dispatches and schedules user re2uestsX and !anages space usage within its table;space structures # 52. &ame the su.3systems of a !"#$ IM%" Security" 3anguage 8rocessing" 8rocess Control" Storage 'anage!ent" 3ogging and
2FF Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

*ecovery" Distribution Control" Transaction Control" 'e!ory 'anage!ent" 3oc$ 'anage!ent 53. Which part of the !"#$ ta'es care of the data dictionary? )ow Data dictionary is a set of tables and database ob@ects that is stored in a special area of the database and !aintained e7clusively by the $ernel# 5*. What is the jo. of the information stored in data3 dictionary? The infor!ation in the data dictionary validates the e7istence of the ob@ects" provides access to the!" and !aps the actual physical storage location# 5-. &ot only !"#$ ta'es care of locating data it also deter!ines an opti!al access path to store or retrieve the data 50. )ow do you communicate with an !"#$? Kou co!!unicate with an *D+'S using Structured Query 3anguage -SQ3. 55. !efine $AL and state the differences .etween $AL and other conventional programming Languages
2FG Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

SQ3 is a nonprocedural language that is designed specifically for data access operations on nor!ali ed relational database structures# The pri!ary difference between SQ3 and other conventional progra!!ing languages is that SQ3 state!ents specify what data operations should be perfor!ed rather than how to perfor! the!# 57. &ame the three major set of files on dis' that compose a data.ase in Eracle There are three !a@or sets of files on dis$ that co!pose a database# All the files are binary# These are Database files Control files *edo logs The !ost i!portant of these are the database files where the actual data resides# The control files and the redo logs support the functioning of the architecture itself# All three sets of files !ust be present" open" and available to %racle for any data on the database to be useable# Iithout these files" you cannot access the database" and the database ad!inistrator !ight have to recover so!e or all of the database using a bac$up" if there is one#
2GD Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

5?. What is an Eracle +nstance? The %racle syste! processes" also $nown as %racle bac$ground processes" provide functions for the user processesgfunctions that would otherwise be done by the user processes the!selves %racle database;wide syste! !e!ory is $nown as the S)A" the system glo.al area or shared glo.al area# The data and control structures in the S)A are shareable" and all the %racle bac$ground processes and user processes can use the!# The co!bination of the S)A and the %racle bac$ground processes is $nown as an Eracle instance 7@. What are the four Eracle system processes that must always .e up and running for the data.ase to .e usea.le The four %racle syste! processes that !ust always be up and running for the database to be useable include !"W -Database Iriter." L=W -3og Iriter." $#E& -Syste! 'onitor." and >#E& -8rocess 'onitor.# 71. What are data.ase files% control files and log files. )ow many of these files should a data.ase have at least? Why? !ata.ase <iles
2GA Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

The database files hold the actual data and are typically the largest in si e# Depending on their si es" the tables -and other ob@ects. for all the user accounts can go in one database filegbut thatTs not an ideal situation because it does not !a$e the database structure very fle7ible for controlling access to storage for different users" putting the database on different dis$ drives" or bac$ing up and restoring @ust part of the database# Kou !ust have at least one database file but usually" !ore than one files are used# In ter!s of accessing and using the data in the tables and other ob@ects" the nu!ber -or location. of the files is i!!aterial# The database files are fi7ed in si e and never grow bigger than the si e at which they were created ,ontrol <iles The control files and redo logs support the rest of the architecture# Any database !ust have at least one control file" although you typically have !ore than one to guard against loss# The control file records the na!e of the database" the date and ti!e it was created" the location of the database and redo logs" and the synchroni ation infor!ation to ensure that all three sets of files are always in step# 6very ti!e you add a new database or redo log file to the database" the infor!ation is recorded in the control files# 2G2
Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

edo Logs Any database !ust have at least two redo logs# These are the @ournals for the databaseX the redo logs record all changes to the user ob@ects or syste! ob@ects# If any type of failure occurs" the changes recorded in the redo logs can be used to bring the database to a consistent state without losing any co!!itted transactions# In the case of non;data loss failure" %racle can apply the infor!ation in the redo logs auto!atically without intervention fro! the D+A# The redo log files are fi7ed in si e and never grow dyna!ically fro! the si e at which they were created# 72. What is EW+!? The *%IID is a uni2ue database;wide physical address for every row on every table# %nce assigned -when the row is first inserted into the database." it never changes until the row is deleted or the table is dropped# The *%IID consists of the following three co!ponents" the co!bination of which uni2uely identifies the physical storage location of the row# %racle database file nu!ber" which contains the bloc$ with the rows %racle bloc$ address" which contains the row
2G& Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

The row within the bloc$ -because each bloc$ can hold !any rows. The *%IID is used internally in inde7es as a 2uic$ !eans of retrieving rows with a particular $ey value# Application developers also use it in SQ3 state!ents as a 2uic$ way to access a row once they $now the *%IID 73. What is Eracle "loc'? ,an two Eracle "loc's have the same address? %racle Ofor!atsO the database files into a nu!ber of %racle bloc$s when they are first createdg!a$ing it easier for the *D+'S software to !anage the files and easier to read data into the !e!ory areas# The bloc$ si e should be a !ultiple of the operating syste! bloc$ si e# *egardless of the bloc$ si e" the entire bloc$ is not available for holding dataX %racle ta$es up so!e space to !anage the contents of the bloc$# This bloc$ header has a !ini!u! si e" but it can grow# These %racle bloc$s are the s!allest unit of storage# Increasing the %racle bloc$ si e can i!prove perfor!ance" but it should be done only when the database is first created# 6ach %racle bloc$ is nu!bered se2uentially for each database file starting at A# Two bloc$s can have the sa!e bloc$ address if they are in different database files# 2G1
Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

7*. What is data.ase Drigger? A database trigger is a 83MSQ3 bloc$ that can defined to auto!atically e7ecute for insert" update" and delete state!ents against a table# The trigger can e defined to e7ecute once for the entire state!ent or once for every row that is inserted" updated" or deleted# For any one table" there are twelve events for which you can define database triggers# A database trigger can call database procedures that are also written in 83MSQ3# 7-. &ame two utilities that Eracle provides% which are use for .ac'up and recovery. Along with the *D+'S software" %racle provides two utilities that you can use to bac$ up and restore the database# These utilities are 1xport and +mport# The 1xport utility du!ps the definitions and data for the specified part of the database to an operating syste! binary file# The +mport utility reads the file produced by an e7port" recreates the definitions of ob@ects" and inserts the data If 67port and I!port are used as a !eans of bac$ing up and recovering the database" all the changes !ade to the database cannot be recovered since the e7port was perfor!ed# The best you can do
2G> Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

is recover the database to the ti!e when the e7port was last perfor!ed# 70. What are stored3procedures? 6nd what are the advantages of using them. Stored procedures are database ob@ects that perfor! a user defined operation# A stored procedure can have a set of co!pound SQ3 state!ents# A stored procedure e7ecutes the SQ3 co!!ands and returns the result to the client# Stored procedures are used to reduce networ$ traffic# 75. )ow are exceptions handled in >LG$AL? =ive some of the internal exceptionsW name 83MSQ3 e7ception handling is a !echanis! for dealing with run;ti!e errors encountered during procedure e7ecution# ?se of this !echanis! enables e7ecution to continue if the error is not severe enough to cause procedure ter!ination# The e7ception handler !ust be defined within a subprogra! specification# 6rrors cause the progra! to raise an e7ception with a transfer of control to the e7ception;handler bloc$# After the e7ception handler e7ecutes" control returns to the bloc$ in which the handler was defined# If there are no !ore e7ecutable state!ents in the bloc$" control returns to the caller# Qser3!efined 1xceptions
2GC Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

83MSQ3 enables the user to define e7ception handlers in the declarations area of subprogra! specifications# ?ser acco!plishes this by na!ing an e7ception as in the following e7a!ple: otNfailure 6JC68TI%(X In this case" the e7ception na!e is otNfailure . Code associated with this handler is written in the 6JC68TI%( specification area as follows: 6JC68TI%( when %TNFAI3?*6 then outNstatusNcode :B gNoutNstatusNcodeX outN!sg :B gNoutN!sgX The following is an e7a!ple of a subprogra! e7ception: 6JC68TI%( when (%NDATANF%?(D then gNoutNstatusNcode :B TFAI3TX *AIS6 otNfailureX Iithin this e7ception is the *AIS6 state!ent that transfers control bac$ to the otNfailure e7ception handler# This techni2ue of raising the e7ception is used to invo$e all user;defined e7ceptions# $ystem3!efined 1xceptions 67ceptions internal to 83MSQ3 are raised auto!atically upon error# (%NDATANF%?(D is a syste!;defined e7ception# Table below gives a co!plete list of internal e7ceptions# 2GE
Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

>LG$AL internal exceptions. 12cepti n Na(e Orac3e 1rr r

C?*S%*NA3*6ADKN% %*A;DC>AA 86( D?8N0A3N%(NI(D6J %*A;DDDDA I(0A3IDNC?*S%* %*A;DADDA I(0A3IDN(?'+6* %*A;DAE22 3%)I(ND6(I6D %*A;DADAE (%NDATANF%?(D %*A;DA1D& (%TN3%))6DN%( %*A;DADA2 8*%)*A'N6**%* %*A;DC>DA ST%*A)6N6**%* %*A;DC>DD TI'6%?TN%(N*6S%? %*A;DDD>A *C6 T%%N'A(KN*%IS %*A;DA122 T*A(SACTI%(N+AC_ %*A;DDDCA 6DN%?T 0A3?6N6**%* %*A;DC>D2 f6*%NDI0ID6 %*A;DA1EC In addition to this list of e7ceptions" there is a catch;all e7ception na!ed ED)1 $ that traps all errors for which specific error handling has not been established#
2GF Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

77. !oes >LG$AL support KoverloadingK? 1xplain The concept of overloading in 83MSQ3 relates to the idea that you can define procedures and functions with the sa!e na!e# 83MSQ3 does not loo$ only at the referenced na!e" however" to resolve a procedure or function call# The count and data types of for!al para!eters are also considered# 83MSQ3 also atte!pts to resolve any procedure or function calls in locally defined pac$ages before loo$ing at globally defined pac$ages or internal functions# To further ensure calling the proper procedure" you can use the dot notation# 8refacing a procedure or function na!e with the pac$age na!e fully 2ualifies any procedure or function reference# 7?. Da.les derived from the 1 ! a. Are totally unnor!alised b. Are always in A(F c. Can be further denor!alised d. 'ay have !ulti;valued attributes -b. Are always in A(F ?@. $purious tuples may occur due to i. "ad normaliCation ii. Dheta joins iii. Qpdating ta.les from join a. i U ii b. ii U iii 2GG
Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

c. i U iii

d. ii U iii

-a. i U iii because theta @oins are @oins !ade on $eys that are not pri!ary $eys# ?1. 6 " , is a set of attri.utes. Dhe functional dependency is as follows 6" 3V " 6, 3V , , 3V " a. is in A(F b. is in 2(F c. is in &(F d. is in +C(F -a. is in A(F since -AC.= B ] A" +" C^ hence AC is the pri!ary $ey# Since C + is a FD given" where neither C is a _ey nor + is a pri!e attribute" this it is not in &(F# Further + is not functionally dependent on $ey AC thus it is not in 2(F# Thus the given FDs is in A(F# ?2. +n mapping of 1 ! to !<! a. entities in 6*D should correspond to an e7isting entityMstore in DFD b. entity in DFD is converted to attributes of an entity in 6*D
&DD Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

c. relations in 6*D has A to A correspondence to processes in DFD d. relationships in 6*D has A to A correspondence to flows in DFD -a. entities in 6*D should correspond to an e7isting entityMstore in DFD ?3. 6 dominant entity is the entity a. on the ( side in a A : ( relationship b. on the A side in a A : ( relationship c. on either side in a A : A relationship d. nothing to do with A : A or A : ( relationship -b. on the A side in a A : ( relationship ?*. $elect W&E D)W% ,Q$DE#1 <rom ,Q$D^!DL$ Where 1=+E& I W&W Erder "y ,Q$DE#1 Qnion $elect W16$DW% ,Q$DE#1 <rom ,Q$D^!DL$ Where 1=+E& I W1W Erder "y ,Q$DE#1 The above is a. (ot an error b. 6rror ; the string in single 2uotes T(%*T/T and TS%?T/T c. 6rror ; the string should be in double 2uotes d. 6rror ; %*D6* +K clause
&DA Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

-d. 6rror ; the %*D6* +K clause# Since %*D6* +K clause cannot be used in ?(I%(S ?-. What is $torage #anager? It is a progra! !odule that provides the interface between the low;level data stored in database" application progra!s and 2ueries sub!itted to the syste!# ?0. What is "uffer #anager? It is a progra! !odule" which is responsible for fetching data fro! dis$ storage into !ain !e!ory and deciding what data to be cache in !e!ory# ?5. What is Dransaction #anager? It is a progra! !odule" which ensures that database" re!ains in a consistent state despite syste! failures and concurrent transaction e7ecution proceeds without conflicting# ?7. What is <ile #anager? It is a progra! !odule" which !anages the allocation of space on dis$ storage and data structure used to represent infor!ation stored on a dis$# ??. What is 6uthoriCation and +ntegrity manager?
&D2 Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

It is the progra! !odule" which tests for the satisfaction of integrity constraint and chec$s the authority of user to access data# 1@@.What are stand3alone procedures? 8rocedures that are not part of a pac$age are $nown as stand;alone because they independently defined# A good e7a!ple of a stand;alone procedure is one written in a SQ3<For!s application# These types of procedures are not available for reference fro! other %racle tools# Another li!itation of stand; alone procedures is that they are co!piled at run ti!e" which slows e7ecution# 1@1.What are cursors give different types of cursors. 83MSQ3 uses cursors for all database infor!ation accesses state!ents# The language supports the use two types of cursors +mplicit 1xplicit 1@2.What is cold .ac'up and hot .ac'up 2in case of Eracle4? ,old "ac'up: It is copying the three sets of files -database files" redo logs" and control file. when the instance is shut down# This is a straight file copy"
&D& Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

usually fro! the dis$ directly to tape# Kou !ust shut down the instance to guarantee a consistent copy# If a cold bac$up is perfor!ed" the only option available in the event of data file loss is restoring all the files fro! the latest bac$up# All wor$ perfor!ed on the database since the last bac$up is lost# )ot "ac'up: So!e sites -such as worldwide airline reservations syste!s. cannot shut down the database while !a$ing a bac$up copy of the files# The cold bac$up is not an available option# So different !eans of bac$ing up database !ust be used g the hot bac$up# Issue a SQ3 co!!and to indicate to %racle" on a tablespace;by; tablespace basis" that the files of the tablespace are to bac$ed up# The users can continue to !a$e full use of the files" including !a$ing changes to the data# %nce the user has indicated that heMshe wants to bac$ up the tablespace files" heMshe can use the operating syste! to copy those files to the desired bac$up destination# The database !ust be running in A*C/I063%) !ode for the hot bac$up option# If a data loss failure does occur" the lost database files can be restored using the hot bac$up and the online and offline redo logs created since the bac$up was done# The database is restored to the &D1
Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

!ost consistent state without any loss of co!!itted transactions# 1@3.What are 6rmstrong rules? )ow do we say that they are complete andGor sound The well;$nown inference rules for FDs *efle7ive rule : If K is subset or e2ual to J then J K# Aug!entation rule: If J K then Jf Kf# Transitive rule: If ]J K" K f^ then J f# Deco!position rule : If J Kf then J K# ?nion or Additive rule: If ]J K" J f^ then J Kf# 8seudo Transitive rule : If ]J K" IK f^ then IJ f# %f these the first three are $nown as A!strong *ules# They are sound because it is enough if a set of FDs satisfy these three# They are called co!plete because using these three rules we can generate the rest all inference rules#
&D> Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

1@*.)ow can you find the minimal 'ey of relational schema? 'ini!al $ey is one which can identify each tuple of the given relation sche!a uni2uely# For finding the !ini!al $ey it is re2uired to find the closure that is the set of all attributes that are dependent on any given set of attributes under the given set of functional dependency# -l0o. 6 Deter!ining J=" closure for J" given set of FDs F A# Set J= B J 2# Set %ld J= B J= &# For each FD K f in F and if K belongs to J= then add f to J= 1# *epeat steps 2 and & until %ld J= B J= -l0o.66 Deter!ining !ini!al _ for relation sche!a *" given set of FDs F A# Set _ to * that is !a$e _ a set of all attributes in * 2# For each attribute A in _ a# Co!pute -_ , A.= with respect to F b# If -_ , A.= B * then set _ B -_ , A.=
&DC Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

1@-.What do you understand .y dependency preservation? )iven a relation * and a set of FDs F" dependency preservation states that the closure of the union of the pro@ection of F on each deco!posed relation *i is e2ual to the closure of F# i#e#" --*A-F.. ? L ? -*n-F...= B F= if deco!position is not dependency preserving" then so!e dependency is lost in the deco!position# 1@0.What is meant .y >roactive% etroactive and $imultaneous Qpdate. >roactive Qpdate: The updates that are applied to database before it beco!es effective in real world # etroactive Qpdate: The updates that are applied to database after it beco!es effective in real world # $imulatneous Qpdate: The updates that are applied to database at the sa!e ti!e when it beco!es effective in real world # 1@5.What are the different types of YE+& operations? 1/ui Yoin: This is the !ost co!!on type of @oin which involves only e2uality co!parisions# The disadvantage in this type of @oin is that there
&DE Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

&DF Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

SQL

SQ3 1. Which is the su.set of $AL commands used to manipulate Eracle !ata.ase structures% including ta.les? Data Definition 3anguage -DD3. 2. What operator performs pattern matching? 3I_6 operator 3. What operator tests column for the a.sence of data? IS (?33 operator 4. Which command executes the contents of a specified file? STA*T Sfilena!eR or bSfilena!eR -. What is the parameter su.stitution sym.ol used with +&$1 D +&DE command? &DG
Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

U %. Which command displays the $AL command in the $AL .uffer% and then executes it? *?( !. What are the wildcards used for pattern matching? N for single character substitution and W for !ulti;character substitution /. $tate true or false. 1Z+$D$% $E#1% 6&_ are operators in $AL. True &. $tate true or false. UI% RV% ;I all denote the same operation. True 10. What are the privileges that can .e granted on a ta.le .y a user to others? Insert" update" delete" select" references" inde7" e7ecute" alter" all 11. What command is used to get .ac' the privileges offered .y the = 6&D command? *60%_6
&AD Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

12. Which system ta.les contain information on privileges granted and privileges o.tained? ?S6*NTA+N8*I0SN'AD6" ?S6*NTA+N8*I0SN*6CD 13. Which system ta.le contains information on constraints on all the ta.les created? ?S6*NC%(ST*AI(TS 14. D Q&,6D1 D6"L1 1#>J !1L1D1 < E# 1#>J Will the outputs of the a.ove two commands differ? +oth will result in deleting all the rows in the table 6'8# 1-. What is the difference .etween D Q&,6D1 and !1L1D1 commands? T*?(CAT6 is a DD3 co!!and whereas D636T6 is a D'3 co!!and# /ence D636T6 operation can be rolled bac$" but T*?(CAT6 operation cannot be rolled bac$# I/6*6 clause can be used with D636T6 and not with T*?(CAT6# 1%. What command is used to create a ta.le .y copying the structure of another ta.le? Ans)er 0 C*6AT6 TA+36 ## AS S636CT co!!and 12p3anati n0 &AA
Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

To copy only the structure" the I/6*6 clause of the S636CT co!!and should contain a FA3S6 state!ent as in the following# C*6AT6 TA+36 (6ITA+36 AS S636CT < F*%' 6JISTI()TA+36 I/6*6 AB2X If the I/6*6 condition is true" then all the rows or rows satisfying the condition will be copied to the new table# 1!. What will .e the output of the following /uery? $1L1,D 1>L6,12D 6&$L6D12LD +#2 D +#2WUU 6D)1& UUW%WUW4% WUW4% W6&W% W99W4%W9W%WD EQ"L1W4 < E# !Q6LJ T*%?+36T/6T*%?+36 1/. What will .e the output of the following /uery? $1L1,D !1,E!12D 6&$L6D12W6W%W123*-057?@W%W11111111 11W4% W1W%W_1$W% W&EW 4 from dualJ Ans)er 0 (% 12p3anati n 0 The 2uery chec$s whether a given string is a nu!erical digit# 1&. What does the following /uery do? $1L1,D $6L 8 &BL2,E##%@4 < E# 1#>J
&A2 Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

This displays the total salary of all e!ployees# The null values in the co!!ission colu!n will be replaced by D and added to salary# 20. Which date function is used to find the difference .etween two dates? '%(T/SN+6TI66( 21. Why does the following command give a compilation error? ! E> D6"L1 (D6"L1^&6#1J 0ariable na!es should start with an alphabet# /ere the table na!e starts with an TUT sy!bol# 22. What is the advantage of specifying W+D) = 6&D E>D+E& in the = 6&D command? The privilege receiver can further grant the privileges heMshe has obtained fro! the owner to any other user# 23. What is the use of the ! E> option in the 6LD1 D6"L1 command? It is used to drop constraints specified on the table#

&A& Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

24. What is the value of XcommF and XsalF after executing the following /uery if the initial value of XsalF is 1@@@@? Q>!6D1 1#> $1D $6L I $6L 8 1@@@% ,E## I $6L9@.1J sal B AADDD" co!! B ADDD 2-. What is the use of !1$, in $AL? Ans)er 0 D6SC has two purposes# It is used to describe a sche!a as well as to retrieve rows fro! table in descending order# 12p3anati n 0 The 2uery S636CT < F*%' 6'8 %*D6* +K 6(A'6 D6SC will display the output sorted on 6(A'6 in descending order# 2%. What is the use of ,6$,6!1 ,E&$D 6+&D$? Ihen this clause is used with the D*%8 co!!and" a parent table can be dropped even when a child table e7ists# 2!. Which function is used to find the largest integer less than or e/ual to a specific value? F3%%* 2/. What is the output of the following /uery? $1L1,D D Q&,2123*.-057%324 < E# !Q6LJ &A1
Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

A2DD

/IB J IAHR6H/ I. SC=1$AS Da.le 1 : S5UDI1S 8(A'6 -0A*C/A*." S83AC6 -0A*C/A*." C%?*S6 -0A*C/A*." CC%ST -(?'+6*. Da.le 2 : SO>5<A"1 8(A'6 -0A*C/A*." TIT36 -0A*C/A*." D60I( -0A*C/A*." SC%ST -(?'+6*." DC%ST -(?'+6*." S%3D -(?'+6*. Da.le 3 : P"O?"A$$1" 8(A'6 -0A*C/A*." D%+ -DAT6." D%H -DAT6." S6J -C/A*." 8*%FA -0A*C/A*." 8*%F2 -0A*C/A*." SA3 -(?'+6*.
&A> Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

BHKH'8 : 8(A'6 , 8rogra!!er (a!e" S83AC6 , Study 8lace" CC%ST , Course Cost" D60I( , Developed in" SC%ST , Software Cost" DC%ST , Develop!ent Cost" 8*%FA , 8roficiency A QU1"I1S 0 1. <ind out the selling cost average for pac'ages developed in Eracle. 2. !isplay the names% ages and experience of all programmers. 3. !isplay the names of those who have done the >=!,6 course. *. What is the highest num.er of copies sold .y a pac'age? -. !isplay the names and date of .irth of all programmers .orn in 6pril. 0. !isplay the lowest course fee. 5. )ow many programmers have done the !,6 course. 7. )ow much revenue has .een earned through the sale of pac'ages developed in ,. ?. !isplay the details of software developed .y a'esh. 1@. )ow many programmers studied at >entafour. &AC
Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

11. !isplay the details of pac'ages whose sales crossed the -@@@ mar'. 12. <ind out the num.er of copies which should .e sold in order to recover the development cost of each pac'age. 13. !isplay the details of pac'ages for which the development cost has .een recovered. 1*. What is the price of costliest software developed in B"? 1-. )ow many pac'ages were developed in Eracle ? 10. )ow many programmers studied at > 6=6D)+? 15. )ow many programmers paid 1@@@@ to 1-@@@ for the course? 17. What is the average course fee? 1?. !isplay the details of programmers 'nowing ,. 2@. )ow many programmers 'now either , or >ascal? 21. )ow many programmers donFt 'now , and ,88? 22. )ow old is the oldest male programmer? 23. What is the average age of female programmers? 2*. ,alculate the experience in years for each programmer and display along with their names in descending order. &AE
Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

2-. Who are the programmers who cele.rate their .irthdays during the current month? 20. )ow many female programmers are there? 25. What are the languages 'nown .y the male programmers? 27. What is the average salary? 2?. )ow many people draw -@@@ to 5-@@? 3@. !isplay the details of those who donFt 'now ,% ,88 or >ascal. 31. !isplay the costliest pac'age developed .y each programmer. 32. >roduce the following output for all the male programmers >rogrammer #r. 6rvind : has 1- years of experience LHM/: A# S636CT A0)-SC%ST. F*%' S%FTIA*6 I/6*6 D60I( B T%*AC36TX 2# S636CT 8(A'6"T*?(C-'%(T/SN+6TI66(-SKS DAT6"D%+.MA2. OA)6O" T*?(C-'%(T/SN+6TI66(-SKSDAT6"D% H.MA2. O6J86*I6(C6O F*%' 8*%)*A''6*X &# S636CT 8(A'6 F*%' ST?DI6S I/6*6 C%?*S6 B T8)DCATX &AF
Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

1# S636CT 'AJ-S%3D. F*%' S%FTIA*6X ># S636CT 8(A'6" D%+ F*%' 8*%)*A''6* I/6*6 D%+ 3I_6 TWA8* WTX C# S636CT 'I(-CC%ST. F*%' ST?DI6SX E# S636CT C%?(T-<. F*%' ST?DI6S I/6*6 C%?*S6 B TDCATX F# S636CT S?'-SC%ST<S%3D;DC%ST. F*%' S%FTIA*6 )*%?8 +K D60I( /A0I() D60I( B TCTX G# S636CT < F*%' S%FTIA*6 I/6*6 8(A'6 B T*A_6S/TX AD# S636CT < F*%' ST?DI6S I/6*6 S83AC6 B T86(TAF%?*TX AA# S636CT < F*%' S%FTIA*6 I/6*6 SC%ST<S%3D;DC%ST R >DDDX A2# S636CT C6I3-DC%STMSC%ST. F*%' S%FTIA*6X A&# S636CT < F*%' S%FTIA*6 I/6*6 SC%ST<S%3D RB DC%STX A1# S636CT 'AJ-SC%ST. F*%' S%FTIA*6 )*%?8 +K D60I( /A0I() D60I( B T0+TX A># S636CT C%?(T-<. F*%' S%FTIA*6 I/6*6 D60I( B T%*AC36TX AC# S636CT C%?(T-<. F*%' ST?DI6S I/6*6 S83AC6 B T8*A)AT/ITX
&AG Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

AE# S636CT C%?(T-<. F*%' ST?DI6S I/6*6 CC%ST +6TI66( ADDDD A(D A>DDDX AF# S636CT A0)-CC%ST. F*%' ST?DI6SX AG# S636CT < F*%' 8*%)*A''6* I/6*6 8*%FA B TCT %* 8*%F2 B TCTX 2D# S636CT < F*%' 8*%)*A''6* I/6*6 8*%FA I( -TCT"T8ASCA3T. %* 8*%F2 I( -TCT"T8ASCA3T.X 2A# S636CT < F*%' 8*%)*A''6* I/6*6 8*%FA (%T I( -TCT"TC==T. A(D 8*%F2 (%T I( -TCT"TC==T.X 22# S636CT T*?(C-'AJ-'%(T/SN+6TI66(-SKSDA T6"D%+.MA2.. F*%' 8*%)*A''6* I/6*6 S6J B T'TX 2&# S636CT T*?(C-A0)-'%(T/SN+6TI66(-SKSDA T6"D%+.MA2.. F*%' 8*%)*A''6* I/6*6 S6J B TFTX 21# S636CT 8(A'6" T*?(C-'%(T/SN+6TI66(-SKSDAT6"D% H.MA2. F*%' 8*%)*A''6* %*D6* +K 8(A'6 D6SCX 2># S636CT 8(A'6 F*%' 8*%)*A''6* I/6*6 T%NC/A*-D%+"T'%(T. B T%NC/A*-SKSDAT6"T'%(T.X
&2D Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

2C# S636CT C%?(T-<. F*%' 8*%)*A''6* I/6*6 S6J B TFTX 2E# S636CT DISTI(CT-8*%FA. F*%' 8*%)*A''6* I/6*6 S6J B T'TX 2F# S636CT A0)-SA3. F*%' 8*%)*A''6*X 2G# S636CT C%?(T-<. F*%' 8*%)*A''6* I/6*6 SA3 +6TI66( >DDD A(D E>DDX &D# S636CT < F*%' 8*%)*A''6* I/6*6 8*%FA (%T I( -TCT"TC==T"T8ASCA3T. A(D 8*%F2 (%T I( -TCT"TC==T"T8ASCA3T.X &A# S636CT 8(A'6"TIT36"SC%ST F*%' S%FTIA*6 I/6*6 SC%ST I( -S636CT 'AJ-SC%ST. F*%' S%FTIA*6 )*%?8 +K 8(A'6.X &2#S636CT T'r#T VV 8(A'6 VV T ; has T VV T*?(C-'%(T/SN+6TI66(-SKSDAT6"D% H.MA2. VV T years of e7perienceT [8rogra!!er\ F*%' 8*%)*A''6* I/6*6 S6J B T'T ?(I%( S636CT T's#T VV 8(A'6 VV T ; has T VV T*?(C -'%(T/SN+6TI66( -SKSDAT6"D%H.MA2. VV T years of e7perienceT [8rogra!!er\ F*%' 8*%)*A''6* I/6*6 S6J B TFTX

&2A Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

II . SC=1$A 0 Da.le 1 : 8HNT D68T(% -(%T (?33 " (?'+6*-2.." D(A'6 -0A*C/A*2-A1.." 3%C -0A*C/A*2-A&. Da.le 2 : H@N 6'8(% -(%T (?33 " (?'+6*-1.." 6(A'6 -0A*C/A*2-AD.." H%+ -0A*C/A*2-G.." ')* -(?'+6*-1.." /I*6DAT6 -DAT6." SA3 -(?'+6*-E"2.." C%'' -(?'+6*-E"2.." D68T(% -(?'+6*-2.. ')* is the e!pno of the e!ployee who! the e!ployee reports to# D68T(% is a foreign $ey# QU1"I1S 1. List all the employees who have at least one person reporting to them. 2. List the employee details if and only if more than 1@ employees are present in department no 1@. 3. List the name of the employees with their immediate higher authority. *. List all the employees who do not manage any one. &22
Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

-. List the employee details whose salary is greater than the lowest salary of an employee .elonging to deptno 2@. 0. List the details of the employee earning more than the highest paid manager. 5. List the highest salary paid for each jo.. 7. <ind the most recently hired employee in each department. ?. +n which year did most people join the company? !isplay the year and the num.er of employees. 1@. Which department has the highest annual remuneration .ill? 11. Write a /uery to display a X9F against the row of the most recently hired employee. 12. <rite a c rre3ated su7.@uer, t 3ist ut t6e e(p3 ,ees )6 earn ( re t6an t6e avera+e sa3ar, 9 t6eir depart(ent. 13. <ind the nth maximum salary. 1*. $elect the duplicate records 2 ecords% which are inserted% that already exist4 in the 1#> ta.le. 1-. Write a /uery to list the length of service of the employees 2of the form n years and m months4. LHM/: A# S636CT DISTI(CT-A#6(A'6. F*%' 6'8 A" 6'8 + I/6*6 A#6'8(% B +#')*X or
&2& Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

S636CT 6(A'6 F*%' 6'8 I/6*6 6'8(% I( -S636CT ')* F*%' 6'8.X 2# S636CT < F*%' 6'8 I/6*6 D68T(% I( -S636CT D68T(% F*%' 6'8 )*%?8 +K D68T(% /A0I() C%?(T-6'8(%.RAD A(D D68T(%BAD.X &# S636CT A#6(A'6 O6'83%K66O" +#6(A'6 O*68%*TS T%O F*%' 6'8 A" 6'8 + I/6*6 A#')*B+#6'8(%X 1# S636CT < F*%' 6'8 I/6*6 6'8(% I( - S636CT 6'8(% F*%' 6'8 'I(?S S636CT ')* F*%' 6'8.X ># S636CT < F*%' 6'8 I/6*6 SA3 R - S636CT 'I(-SA3. F*%' 6'8 )*%?8 +K D68T(% /A0I() D68T(%B2D.X C# S636CT < F*%' 6'8 I/6*6 SA3 R - S636CT 'AJ-SA3. F*%' 6'8 )*%?8 +K H%+ /A0I() H%+ B T'A(A)6*T .X E# S636CT H%+" 'AJ-SA3. F*%' 6'8 )*%?8 +K H%+X F# S636CT < F*%' 6'8 I/6*6 -D68T(%" /I*6DAT6. I( -S636CT D68T(%" 'AJ-/I*6DAT6. F*%' 6'8 )*%?8 +K D68T(%.X G# S636CT T%NC/A*-/I*6DAT6"TKKKKT. OK6A*O" C%?(T-6'8(%. O(%# %F 6'83%K66SO F*%' 6'8 )*%?8 +K T%NC/A*-/I*6DAT6"TKKKKT. /A0I() &21
Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

C%?(T-6'8(%. B -S636CT 'AJ-C%?(T-6'8(%.. F*%' 6'8 )*%?8 +K T%NC/A*-/I*6DAT6"TKKKKT..X AD# S636CT D68T(%" 38AD-S?'-A2<-SA3=(03-C%''"D..."A>. OC%'86(SATI%(O F*%' 6'8 )*%?8 +K D68T(% /A0I() S?'- A2<-SA3=(03-C%''"D... B -S636CT 'AJ-S?'-A2<-SA3=(03-C%''"D.... F*%' 6'8 )*%?8 +K D68T(%.X AA# S636CT 6(A'6" /I*6DAT6" 38AD-T<T"F. O*6C6(T3K /I*6DO F*%' 6'8 I/6*6 /I*6DAT6 B -S636CT 'AJ-/I*6DAT6. F*%' 6'8. ?(I%( S636CT 6(A'6 (A'6" /I*6DAT6" 38AD-T T"A>. O*6C6(T3K /I*6DO F*%' 6'8 I/6*6 /I*6DAT6 !B -S636CT 'AJ-/I*6DAT6. F*%' 6'8.X A2# S636CT 6(A'6"SA3 F*%' 6'8 6 I/6*6 SA3 R -S636CT A0)-SA3. F*%' 6'8 F I/6*6 6#D68T(% B F#D68T(%.X A&# S636CT 6(A'6" SA3 F*%' 6'8 A I/6*6 U( B -S636CT C%?(T -DISTI(CT-SA3.. F*%' 6'8 + I/6*6 A#SA3SB+#SA3.X A1# S636CT < F*%' 6'8 A I/6*6 A#6'8(% I( -S636CT 6'8(% F*%' 6'8 )*%?8 +K 6'8(% /A0I() C%?(T-6'8(%.RA. A(D A#*%IID!B'I( -*%IID..X &2>
Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

A># S636CT 6(A'6 O6'83%K66O"T%NC/A*-T*?(C-'%(T/SN+6 TI66(-SKSDAT6"/I*6DAT6.MA2..VVT K6A*S TVV T%NC/A*-T*?(C-'%D-'%(T/SN+6TI66( -SKSDAT6" /I*6DAT6."A2...VVT '%(T/S T O36()T/ %F S6*0IC6O F*%' 6'8X

&2C Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

Computer Networks

Co!puter (etwor$s 1. What are the two types of transmission technology availa.le? -i. +roadcast and -ii. point;to;point 2. What is su.net? A generic ter! for section of a large networ$s usually separated by a bridge or router# 3. !ifference .etween the communication and transmission. Trans!ission is a physical !ove!ent of infor!ation and concern issues li$e bit polarity" synchronisation" cloc$ etc# Co!!unication !eans the !eaning full e7change of infor!ation between two co!!unication !edia# *. What are the possi.le ways of data exchange? &2E
Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

-i. Si!ple7 -ii. /alf;duple7 -iii. Full;duple7# -. <6at is SAP? Series of interface points that allow other co!puters to co!!unicate with the other layers of networ$ protocol stac$# 0. What do you meant .y Ktriple ZK in &etwor's? The function of 8AD -8ac$et Asse!bler Disasse!bler. is described in a docu!ent $nown as J#&# The standard protocol has been defined between the ter!inal and the 8AD" called J#2FX another standard protocol e7ists between hte 8AD and the networ$" called J#2G# Together" these three reco!!endations are often called Otriple JO 5. What is frame relay% in which layer it comes? Fra!e relay is a pac$et switching technology# It will operate in the data lin$ layer# 7. What is terminal emulation% in which layer it comes? Telnet is also called as ter!inal e!ulation# It belongs to application layer# ?. What is "eaconing? The process that allows a networ$ to self;repair networ$s proble!s# The stations on the networ$ &2F
Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

notify the other stations on the ring when they are not receiving the trans!issions# +eaconing is used in To$en ring and FDDI networ$s# 1@. What is redirector? *edirector is software that intercepts file or prints IM% re2uests and translates the! into networ$ re2uests# This co!es under presentation layer# 11. What is &1D"+E$ and &1D"1Q+? (6T+I%S is a progra!!ing interface that allows IM% re2uests to be sent to and received fro! a re!ote co!puter and it hides the networ$ing hardware fro! applications# (6T+6?I is (et+I%S e7tended user interface# A transport protocol designed by !icrosoft and I+' for the use on s!all subnets# 12. What is 6+!? A !ethod for providing fault tolerance by using !ultiple hard dis$ drives# 13. What is passive topology? Ihen the co!puters on the networ$ si!ply listen and receive the signal" they are referred to as passive because they don5t a!plify the signal in any way# 67a!ple for passive topology ; linear bus#
&2G Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

1*. What is "router? /ybrid devices that co!bine the features of both bridges and routers# 1-. What is cladding? A layer of a glass surrounding the center fiber of glass inside a fiber;optic cable# 10. What is point3to3point protocol A co!!unications protocol used to connect co!puters to re!ote networ$ing services including Internet service providers# 15. )ow =ateway is different from outers? A gateway operates at the upper levels of the %SI !odel and translates infor!ation between two co!pletely different networ$ architectures or data for!ats 17. What is attenuation? The degeneration of a signal over distance on a networ$ cable is called attenuation# 1?. What is #6, address? The address for a device as it is identified at the 'edia Access Control -'AC. layer in the networ$ architecture# 'AC address is usually stored in *%' on the networ$ adapter card and is uni2ue# &&D
Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

2@. !ifference .etween .it rate and .aud rate. +it rate is the nu!ber of bits trans!itted during one second whereas baud rate refers to the nu!ber of signal units per second that are re2uired to represent those bits# .aud rate I .it rate G & where ( is no;of;bits represented by each signal shift# 21. What is "andwidth? 6very line has an upper li!it and a lower li!it on the fre2uency of signals it can carry# This li!ited range is called the bandwidth# 22. What are the types of Dransmission media? Signals are usually trans!itted over so!e trans!ission !edia that are broadly classified in to two categories# a4=uided #edia: These are those that provide a conduit fro! one device to another that include twisted;pair" coa7ial cable and fiber;optic cable# A signal traveling along any of these !edia is directed and is contained by the physical li!its of the !ediu!# Twisted;pair and coa7ial cable use !etallic that accept and transport signals in the for! of electrical current#
&&A Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

%ptical fiber is a glass or plastic cable that accepts and transports signals in the for! of light# .4 Qnguided #edia: This is the wireless !edia that transport electro!agnetic waves without using a physical conductor# Signals are broadcast either through air# This is done through radio co!!unication" satellite co!!unication and cellular telephony# 23. What is >roject 7@2? It is a pro@ect started by I666 to set standards to enable interco!!unication between e2uip!ent fro! a variety of !anufacturers# It is a way for specifying functions of the physical layer" the data lin$ layer and to so!e e7tent the networ$ layer to allow for interconnectivity of !a@or 3A( protocols# It consists of the following: FD2#A is an internetwor$ing standard for co!patibility of different 3A(s and 'A(s across protocols# FD2#2 3ogical lin$ control -33C. is the upper sublayer of the data lin$ layer which is non; architecture;specific" that is re!ains the sa!e for all I666;defined 3A(s# 'edia access control -'AC. is the lower sublayer of the data lin$ layer that contains so!e distinct
&&2 Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

!odules each carrying proprietary infor!ation specific to the 3A( product being used# The !odules are 6thernet 3A( -FD2#&." To$en ring 3A( -FD2#1." To$en bus 3A( -FD2#>.# FD2#C is distributed 2ueue dual bus -DQD+. designed to be used in 'A(s# 2*. What is >rotocol !ata Qnit? The data unit in the 33C level is called the protocol data unit -8D?.# The 8D? contains of four fields a destination service access point -DSA8." a source service access point -SSA8." a control field and an infor!ation field# DSA8" SSA8 are addresses used by the 33C to identify the protocol stac$s on the receiving and sending !achines that are generating and using the data# The control field specifies whether the 8D? fra!e is a infor!ation fra!e -I ; fra!e. or a supervisory fra!e -S ; fra!e. or a unnu!bered fra!e -? ; fra!e.# 2-. What are the different type of networ'ing G internetwor'ing devices? epeater: Also called a regenerator" it is an electronic device that operates only at physical layer# It receives the signal in the networ$ before it beco!es wea$" regenerates the original bit pattern and puts the refreshed copy bac$ in to the lin$# &&&
Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

"ridges: These operate both in the physical and data lin$ layers of 3A(s of sa!e type# They divide a larger networ$ in to s!aller seg!ents# They contain logic that allow the! to $eep the traffic for each seg!ent separate and thus are repeaters that relay a fra!e only the side of the seg!ent containing the intended recipent and control congestion# outers: They relay pac$ets a!ong !ultiple interconnected networ$s -i#e# 3A(s of different type.# They operate in the physical" data lin$ and networ$ layers# They contain software that enable the! to deter!ine which of the several possible paths is the best for a particular trans!ission# =ateways: They relay pac$ets a!ong networ$s that have different protocols -e#g# between a 3A( and a IA(.# They accept a pac$et for!atted for one protocol and convert it to a pac$et for!atted for another protocol before forwarding it# They operate in all seven layers of the %SI !odel# 20. What is +,#>? IC'8 is Internet Control 'essage 8rotocol" a networ$ layer protocol of the TC8MI8 suite used by hosts and gateways to send notification of datagra! proble!s bac$ to the sender# It uses the echo test M &&1
Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

reply to test whether a destination is reachable and responding# It also handles both control and error !essages# 25. What are the data units at different layers of the D,> G +> protocol suite? The data unit created at the application layer is called a !essage" at the transport layer the data unit created is called either a seg!ent or an user datagra!" at the networ$ layer the data unit created is called the datagra!" at the data lin$ layer the datagra! is encapsulated in to a fra!e and finally trans!itted as signals along the trans!ission !edia# 27. What is difference .etween 6 > and 6 >? The address resolution protocol -A*8. is used to associate the &2 bit I8 address with the 1F bit physical address" used by a host or a router to find the physical address of another host on its networ$ by sending a A*8 2uery pac$et that includes the I8 address of the receiver# The reverse address resolution protocol -*A*8. allows a host to discover its Internet address when it $nows only its physical address# 2?. What is the minimum and maximum length of the header in the D,> segment and +> datagram?
&&> Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

The header should have a !ini!u! length of 2D bytes and can have a !a7i!u! length of CD bytes# 3@. What is the range of addresses in the classes of internet addresses? Class A D#D#D#D ; A2E#2>>#2>>#2>> Class + A2F#D#D#D ; AGA#2>>#2>>#2>> Class C AG2#D#D#D ; 22&#2>>#2>>#2>> Class D 221#D#D#D ; 2&G#2>>#2>>#2>> Class 6 21D#D#D#D ; 21E#2>>#2>>#2>> 31. What is the difference .etween D<D> and <D> application layer protocols? The Trivial File Transfer 8rotocol -TFT8. allows a local host to obtain files fro! a re!ote host but does not provide reliability or security# It uses the funda!ental pac$et delivery services offered by ?D8# The File Transfer 8rotocol -FT8. is the standard !echanis! provided by TC8 M I8 for copying a file fro! one host to another# It uses the services offer by TC8 and so is reliable and secure# It establishes two connections -virtual circuits. between the hosts" one for data transfer and another for control infor!ation# 32. What are major types of networ's and explain? &&CServer;based networ$
Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

8eer;to;peer networ$ 8eer;to;peer networ$" co!puters can act as both servers sharing resources and as clients using the resources# Server;based networ$s provide centrali ed control of networ$ resources and rely on server co!puters to provide security and networ$ ad!inistration 33. What are the important topologies for networ's? "Q$ topology: In this each co!puter is directly connected to pri!ary networ$ cable in a single line# 6dvantages: Ine7pensive" easy to install" si!ple to understand" easy to e7tend# $D6 topology: In this all co!puters are connected using a central hub# 6dvantages: Can be ine7pensive" easy to install and reconfigure and easy to trouble shoot physical proble!s# +&= topology: In this all co!puters are connected in
&&E Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

loop# 6dvantages: All co!puters have e2ual access to networ$ !edia" installation can be si!ple" and signal does not degrade as !uch as in other topologies because each co!puter regenerates it# 3*. What is mesh networ'? A networ$ in which there are !ultiple networ$ lin$s between co!puters to provide !ultiple paths for data to travel# 3-. What is difference .etween .ase.and and .road.and transmission? In a baseband trans!ission" the entire bandwidth of the cable is consu!ed by a single signal# In broadband trans!ission" signals are sent on !ultiple fre2uencies" allowing !ultiple signals to be sent si!ultaneously# 30. 1xplain -3*33 rule? In a 6thernet networ$" between any two points on the networ$ "there can be no !ore than five networ$ seg!ents or four repeaters" and of those five seg!ents only three of seg!ents can be populated# 35. What #6Q? In to$en *ing " hub is called 'ultistation Access &&F
Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

?nit-'A?.# 37. What is the difference .etween routa.le and non3 routa.le protocols? *outable protocols can wor$ with a router and can be used to build large networ$s# (on;*outable protocols are designed to wor$ on s!all" local networ$s and cannot be used with a router 3?. Why should you care a.out the E$+ eference #odel? It provides a fra!ewor$ for discussing networ$ operations and design# *@. What is logical lin' control? %ne of two sublayers of the data lin$ layer of %SI reference !odel" as defined by the I666 FD2 standard# This sublayer is responsible for !aintaining the lin$ between co!puters when they are sending data across the physical networ$ connection# *1. What is virtual channel? 0irtual channel is nor!ally a connection fro! one source to one destination" although !ulticast connections are also per!itted# The other na!e for virtual channel is virtual circuit# *2. What is virtual path? &&G
Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

Along any trans!ission path fro! a given source to a given destination" a group of virtual circuits can be grouped together into what is called path# *3. What is pac'et filter? 8ac$et filter is a standard router e2uipped with so!e e7tra functionality# The e7tra functionality allows every inco!ing or outgoing pac$et to be inspected# 8ac$ets !eeting so!e criterion are forwarded nor!ally# Those that fail the test are dropped# **. What is traffic shaping? %ne of the !ain causes of congestion is that traffic is often busy# If hosts could be !ade to trans!it at a unifor! rate" congestion would be less co!!on# Another open loop !ethod to help !anage congestion is forcing the pac$et to be trans!itted at a !ore predictable rate# This is called traffic shaping# *-. What is multicast routing? Sending a !essage to a group is called !ulticasting" and its routing algorith! is called !ulticast routing# *0. What is region? Ihen hierarchical routing is used" the routers are divided into what we will call regions" with each &1D
Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

router $nowing all the details about how to route pac$ets to destinations within its own region" but $nowing nothing about the internal structure of other regions# *5. What is silly window syndrome? It is a proble! that can ruin TC8 perfor!ance# This proble! occurs when data are passed to the sending TC8 entity in large bloc$s" but an interactive application on the receiving side reads A byte at a ti!e# What are !igrams and Drigrams? The !ost co!!on two letter co!binations are called as digra!s# e#g# th" in" er" re and an# The !ost co!!on three letter co!binations are called as trigra!s# e#g# the" ing" and" and ion#
*7.

1xpand +!16. ID6A stands for International Data 6ncryption Algorith!#


*?.

What is wide3mouth frog? Iide;!outh frog is the si!plest $nown $ey distribution center -_DC. authentication protocol#
-@.

-1. What is #ail =ateway? It is a syste! that perfor!s a protocol translation &1A
Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

between different electronic !ail delivery protocols# -2. What is +=> 2+nterior =ateway >rotocol4? It is any routing protocol used within an autono!ous syste!# -3. What is 1=> 21xterior =ateway >rotocol4? It is the protocol the routers in neighboring autono!ous syste!s use to identify the set of networ$s that can be reached within or via each autono!ous syste!# -*. What is autonomous system? It is a collection of routers under the control of a single ad!inistrative authority and that uses a co!!on Interior )ateway 8rotocol# --. What is "=> 2"order =ateway >rotocol4? It is a protocol used to advertise the set of networ$s that can be reached with in an autono!ous syste!# +)8 enables this infor!ation to be shared with the autono!ous syste!# This is newer than 6)8 -67terior )ateway 8rotocol.# -0. What is =ateway3to3=ateway protocol? It is a protocol for!erly used to e7change routing infor!ation between Internet core routers#
&12 Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

-5. What is &BD 2&etwor' Birtual Derminal4? It is a set of rules defining a very si!ple virtual ter!inal interaction# The (0T is used in the start of a Telnet session# -7. What is a #ulti3homed )ost? It is a host that has a !ultiple networ$ interfaces and that re2uires !ultiple I8 addresses is called as a 'ulti;ho!ed /ost# -?. What is [er.eros? It is an authentication service developed at the 'assachusetts Institute of Technology# _erberos uses encryption to prevent intruders fro! discovering passwords and gaining unauthori ed access to files# 0@. What is E$><? It is an Internet routing protocol that scales well" can route traffic along !ultiple paths" and uses $nowledge of an InternetTs topology to !a$e accurate routing decisions# 01. What is >roxy 6 >? It is using a router to answer A*8 re2uests# This will be done when the originating host believes that a destination is local" when in fact is lies beyond router#
&1& Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

02. What is $L+> 2$erial Line +nterface >rotocol4? It is a very si!ple protocol used for trans!ission of I8 datagra!s across a serial line# 03. What is +> 2 outing +nformation >rotocol4? It is a si!ple protocol used to e7change infor!ation between the routers# 0*. What is source route? It is a se2uence of I8 addresses identifying the route a datagra! !ust follow# A source route !ay optionally be included in an I8 datagra! header#

&11 Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

Operating Systems

%perating Syste!s Following are a few basic 2uestions that cover the essentials of %S: 1. 1xplain the concept of eentrancy. It is a useful" !e!ory;saving techni2ue for !ultiprogra!!ed ti!esharing syste!s# A eentrant >rocedure is one in which !ultiple users can share a single copy of a progra! during the sa!e period# *eentrancy has 2 $ey aspects: The progra! code cannot !odify itself" and the local data for each user process !ust be stored separately# Thus" the per!anent part is the code" and the te!porary part is the pointer bac$ to the calling progra! and local variables used by that progra!# 6ach e7ecution instance is called activation# It e7ecutes the code in the per!anent part" but has its own copy of local variablesMpara!eters# The te!porary part associated with each activation is the activation record# )enerally" the activation record is $ept on the stac$# &1>
Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

'ote: A reentrant procedure can be interrupted and called by an interrupting progra!" and still e7ecute correctly on returning to the procedure# 2. 1xplain "eladyWs 6nomaly. Also called FIF% ano!aly# ?sually" on increasing the nu!ber of fra!es allocated to a processT virtual !e!ory" the process e7ecution is faster" because fewer page faults occur# So!eti!es" the reverse happens" i#e#" the e7ecution ti!e increases even when !ore fra!es are allocated to the process# This is +eladyTs Ano!aly# This is true for certain page reference patterns# 3. What is a .inary semaphore? What is its use? A binary se!aphore is one" which ta$es only D and A as values# They are used to i!ple!ent !utual e7clusion and synchroni e concurrent processes# *. What is thrashing? It is a pheno!enon in virtual !e!ory sche!es when the processor spends !ost of its ti!e swapping pages" rather than e7ecuting instructions# This is due to an inordinate nu!ber of page faults# -. List the ,offmanWs conditions that lead to a deadloc'.
&1C Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

'utual 67clusion: %nly one process !ay use a critical resource at a ti!e# /old U Iait: A process !ay be allocated so!e resources while waiting for others# (o 8re;e!ption: (o resource can be forcible re!oved fro! a process holding it# Circular Iait: A closed chain of processes e7ist such that each process holds at least one resource needed by another process in the chain# 0. What are short3% long3 and medium3term scheduling? 3ong ter! scheduler deter!ines which progra!s are ad!itted to the syste! for processing# It controls the degree of multiprogramming# %nce ad!itted" a @ob beco!es a process# 'ediu! ter! scheduling is part of the swapping function# This relates to processes that are in a bloc$ed or suspended state# They are swapped out of real;!e!ory until they are ready to e7ecute# The swapping;in decision is based on !e!ory; !anage!ent criteria# Short ter! scheduler" also $now as a dispatcher e7ecutes !ost fre2uently" and !a$es the finest; grained decision of which process should e7ecute ne7t# This scheduler is invo$ed whenever an event
&1E Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

occurs# It !ay lead to interruption of one process by pree!ption# 5. What are turnaround time and response time? Turnaround ti!e is the interval between the sub!ission of a @ob and its co!pletion# *esponse ti!e is the interval between sub!ission of a re2uest" and the first response to that re2uest# 7. What are the typical elements of a process image? ?ser data: 'odifiable part of user space# 'ay include progra! data" user stac$ area" and progra!s that !ay be !odified# ?ser progra!: The instructions to be e7ecuted# Syste! Stac$: 6ach process has one or !ore 3IF% stac$s associated with it# ?sed to store para!eters and calling addresses for procedure and syste! calls# 8rocess control +loc$ -8C+.: Info needed by the %S to control processes# ?. What is the Dranslation Loo'aside "uffer 2DL"4? In a cached syste!" the base addresses of the last few referenced pages is !aintained in registers called the T3+ that aids in faster loo$up# T3+ contains those page;table entries that have been !ost recently used# (or!ally" each virtual !e!ory reference
&1F Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

causes 2 physical !e!ory accesses;; one to fetch appropriate page;table entry" and one to fetch the desired data# ?sing T3+ in;between" this is reduced to @ust one physical !e!ory access in cases of T3+; hit# 1@. What is the resident set and wor'ing set of a process? *esident set is that portion of the process i!age that is actually in real;!e!ory at a particular instant# Ior$ing set is that subset of resident set that is actually needed for e7ecution# -*elate this to the variable;window si e !ethod for swapping techni2ues#. 11. When is a system in safe state? The set of dispatchable processes is in a safe state if there e7ists at least one te!poral order in which all processes can be run to co!pletion without resulting in a deadloc$# 12. What is cycle stealing? Ie encounter cycle stealing in the conte7t of Direct 'e!ory Access -D'A.# 6ither the D'A controller can use the data bus when the C8? does not need it" or it !ay force the C8? to te!porarily suspend operation# The latter techni2ue is called
&1G Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

cycle stealing# (ote that cycle stealing can be done only at specific brea$ points in an instruction cycle# 13. What is meant .y arm3stic'iness? If one or a few processes have a high access rate to data on one trac$ of a storage dis$" then they !ay !onopoli e the device by repeated re2uests to that trac$# This generally happens with !ost co!!on device scheduling algorith!s -3IF%" SSTF" C; SCA(" etc.# /igh;density !ultisurface dis$s are !ore li$ely to be affected by this than low density ones# 1*. What are the stipulations of ,2 level security? C2 level security provides for: Discretionary Access Control Identification and Authentication Auditing *esource reuse 1-. What is .usy waiting? The repeated e7ecution of a loop of code while waiting for an event to occur is called busy;waiting# The C8? is not engaged in any real productive activity during this period" and the process does not progress toward co!pletion#
&>D Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

10. 1xplain the popular multiprocessor thread3 scheduling strategies. Load $haring: 8rocesses are not assigned to a particular processor# A global 2ueue of threads is !aintained# 6ach processor" when idle" selects a thread fro! this 2ueue# (ote that load .alancing refers to a sche!e where wor$ is allocated to processors on a !ore per!anent basis# =ang $cheduling: A set of related threads is scheduled to run on a set of processors at the sa!e ti!e" on a A;to;A basis# Closely related threads M processes !ay be scheduled this way to reduce synchroni ation bloc$ing" and !ini!i e process switching# )roup scheduling predated this strategy# !edicated processor assignment: 8rovides i!plicit scheduling defined by assign!ent of threads to processors# For the duration of progra! e7ecution" each progra! is allocated a set of processors e2ual in nu!ber to the nu!ber of threads in the progra!# 8rocessors are chosen fro! the available pool# !ynamic scheduling: The nu!ber of thread in a progra! can be altered during the course of e7ecution# 15. When does the condition WrendeCvousW arise?

&>A Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

In !essage passing" it is the condition in which" both" the sender and receiver are bloc$ed until the !essage is delivered# 17. What is a trap and trapdoor? Trapdoor is a secret undocu!ented entry point into a progra! used to grant access without nor!al !ethods of access authentication# A trap is a software interrupt" usually the result of an error condition# 1?. What are local and glo.al page replacements? 3ocal replace!ent !eans that an inco!ing page is brought in only to the relevant processT address space# )lobal replace!ent policy allows any page fra!e fro! any process to be replaced# The latter is applicable to variable partitions !odel only# 2@. !efine latency% transfer and see' time with respect to dis' +GE. See$ ti!e is the ti!e re2uired to !ove the dis$ ar! to the re2uired trac$# *otational delay or latency is the ti!e it ta$es for the beginning of the re2uired sector to reach the head# Su! of see$ ti!e -if any. and latency is the access ti!e# Ti!e ta$en to actually transfer a span of data is transfer ti!e# 21. !escri.e allocation. &>2 the "uddy system of memory

Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

Free !e!ory is !aintained in lin$ed lists" each of e2ual si ed bloc$s# Any such bloc$ is of si e 29$# Ihen so!e !e!ory is re2uired by a process" the bloc$ si e of ne7t higher order is chosen" and bro$en into two# (ote that the two such pieces differ in address only in their $th bit# Such pieces are called buddies# Ihen any used bloc$ is freed" the %S chec$s to see if its buddy is also free# If so" it is re@oined" and put into the original free;bloc$ lin$ed; list# 22. What is time3stamping? It is a techni2ue proposed by 3a!port" used to order events in a distributed syste! without the use of cloc$s# This sche!e is intended to order events consisting of the trans!ission of !essages# 6ach syste! TiT in the networ$ !aintains a counter Ci# 6very ti!e a syste! trans!its a !essage" it incre!ents its counter by A and attaches the ti!e; sta!p Ti to the !essage# Ihen a !essage is received" the receiving syste! T@T sets its counter C@ to A !ore than the !a7i!u! of its current value and the inco!ing ti!e;sta!p Ti# At each site" the ordering of !essages is deter!ined by the following rules: For !essages 7 fro! site i and y fro! site @" 7 precedes y if one of the following conditions holds####-a. if TiST@ or -b. if TiBT@ and iS@#
&>& Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

23. )ow are the waitGsignal operations for monitor different from those for semaphores? If a process in a !onitor signal and no tas$ is waiting on the condition variable" the signal is lost# So this allows easier progra! design# Ihereas in se!aphores" every operation affects the value of the se!aphore" so the wait and signal operations should be perfectly balanced in the progra!# 2*. +n the context of memory management% what are placement and replacement algorithms? 8lace!ent algorith!s deter!ine where in available real;!e!ory to load a progra!# Co!!on !ethods are first;fit" ne7t;fit" best;fit# *eplace!ent algorith!s are used when !e!ory is full" and one process -or part of a process. needs to be swapped out to acco!!odate a new progra!# The replace!ent algorith! deter!ines which are the partitions to be swapped out# 2-. +n loading programs into memory% what is the difference .etween load3time dynamic lin'ing and run3time dynamic lin'ing? For load;ti!e dyna!ic lin$ing: 3oad !odule to be loaded is read into !e!ory# Any reference to a target e7ternal !odule causes that !odule to be loaded and the references are updated to a relative &>1
Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

address fro! the start base address of the application !odule# Iith run;ti!e dyna!ic loading: So!e of the lin$ing is postponed until actual reference during e7ecution# Then the correct !odule is loaded and lin$ed# 20. What are demand3 and pre3paging? Iith de!and paging" a page is brought into !e!ory only when a location on that page is actually referenced during e7ecution# Iith pre;paging" pages other than the one de!anded by a page fault are brought in# The selection of such pages is done based on co!!on access patterns" especially for secondary !e!ory devices# 25. >aging a memory management function% while multiprogramming a processor management function% are the two interdependent? Kes# 27. What is page canni.aliCing? 8age swapping or page replace!ents are called page cannibali ing# 2?. What has triggered the need for multitas'ing in >,s? speed and !e!ory capacity of &>>Increased
Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

!icroprocessors together with the support fir virtual !e!ory and )rowth of client server co!puting 3@. What are the four layers that Windows &D have in order to achieve independence? /ardware abstraction layer _ernel Subsyste!s Syste! Services# 31. What is $#>? To achieve !a7i!u! efficiency and reliability a !ode of operation $nown as sy!!etric !ultiprocessing is used# In essence" with S'8 any process or threads can be assigned to any processor# 32. What are the 'ey o.ject oriented concepts used .y Windows &D? 6ncapsulation %b@ect class and instance 33. +s Windows &D a full .lown o.ject oriented operating system? =ive reasons. (o Iindows (T is not so" because its not i!ple!ented in ob@ect oriented language and the data structures reside within one e7ecutive co!ponent and
&>C Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

are not represented as ob@ects and it does not support ob@ect oriented capabilities # 3*. What is a draw.ac' of #BD? It does not have the features li$e ability to support !ultiple processors virtual storage source level debugging 3-. What is process spawning? Ihen the %S at the e7plicit re2uest of another process creates a process" this action is called process spawning# 30. )ow many jo.s can .e run concurrently on #BD? A> @obs 35. List out some reasons for process termination. (or!al co!pletion Ti!e li!it e7ceeded 'e!ory unavailable +ounds violation 8rotection error Arith!etic error Ti!e overrun IM% failure &>E
Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

Invalid instruction 8rivileged instruction Data !isuse %perator or %S intervention 8arent ter!ination# 37. What are the reasons for process suspension? swapping interactive user re2uest ti!ing parent process re2uest 3?. What is process migration? It is the transfer of sufficient a!ount of the state of process fro! one !achine to the target !achine *@. What is mutant? In Iindows (T a !utant provides $ernel !ode or user !ode !utual e7clusion with the notion of ownership# *1. What is an idle thread? The special thread a dispatcher will e7ecute when no ready thread is found# *2. What is <t!is'? It is a fault tolerance dis$ driver for Iindows
&>F Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

(T# *3. Ihat are the possible threads a thread can have` *eady Standby *unning Iaiting Transition Ter!inated# **. What are rings in Windows &D? Iindows (T uses protection !echanis! called rings provides by the process to i!ple!ent separation between the user !ode and $ernel !ode# *-. What is 1xecutive in Windows &D? In Iindows (T" e7ecutive refers to the operating syste! code that runs in $ernel !ode# *0. What are the su.3components of +GE manager in Windows &D? (etwor$ redirectorM Server Cache !anager# File syste!s (etwor$ driver Device driver
&>G Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Technical Aptitude Questions

*5. What are !!'s? &ame an operating system that includes this feature. DD$s are device driver $its" which are e2uivalent to SD_s for writing device drivers# Iindows (T includes DD$s# *7. What level of security does Windows &D meets? C2 level security#

&CD Copyright: Vyom Network (http://www.vyomworld.com) - All Rights Reserved

Vous aimerez peut-être aussi