You are on page 1of 150

DS

ata Structures Aptitude


1. What is data structure?
A data structure is a way of organizing data that considers not only the items stored, but also their
relationship to each other. Advance knowledge about the relationship between data items allows designing of
efficient algorithms for the manipulation of data.
2. List out the areas in which data structures are applied extensively?
Compiler Design, Operating System, Database anagement System,
Statistical analysis package, !umerical Analysis,
"raphics, Artificial #ntelligence, Simulation
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(
!etwork data model & "raph
)ierarchical data model & *rees
*. +f you are using , language to implement the heterogeneous lin'ed list% what pointer type will you use?
*he heterogeneous linked list contains different data types in its nodes and we need a link, pointer to
connect them. #t is not possible to use ordinary pointers for this. So we go for void pointer. +oid 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?
*wo. One ,ueue is used for actual storing of data and another for storing priorities.
0. What is the data structures used to perform recursion?
Stack. %ecause of its -#.O '-ast #n .irst Out( property it remembers its /caller0 so knows whom to
return when the function has to return. $ecursion makes use of system stack for storing the return addresses of
the function calls. 1very recursive function has its e/uivalent iterative 2non3recursive4 function. 1ven when
such e,uivalent iterative procedures are written, e2plicit stack is to be used.
5. What are the notations used in 1valuation of 6rithmetic 1xpressions using prefix and postfix forms?
3olish and $everse 3olish notations.
7. ,onvert the expression 226 8 "4 9 , : 2! : 14 ; 2< 8 =44 to e/uivalent >refix and >ostfix notations.
3refi2 !otation4 5 6 7 8A%C 6 D1 8 ."
3ostfi2 !otation4 A% 8 C 7 D1 6 6 ." 8 5
?. $orting is not possi.le .y using which of the following methods?
2a4 +nsertion 2.4 $election 2c4 1xchange 2d4 !eletion
'd( Deletion.
9sing insertion we can perform insertion sort, using selection we can perform selection sort, using
e2change we can perform the bubble sort 'and other similar sorting methods(. %ut no sorting method can be
done :ust using deletion.
1@. 6 .inary tree with 2@ nodes has null .ranches?
;<
-et us take a tree with = nodes 'n>=(
#t will have only ? 'ie,=8<( null branches. #n 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 merging, !atural merging,
3olyphase sort, Distribution of #nitial runs.
12. )ow many different trees are possi.le with 1@ nodes ?
<@<A
.or e2ample, consider a tree with B nodes'n>B(, it will have the ma2imum combination of = different
'ie, ;
B
6 B > =( trees.
i ii iii iv v
#n general4
+f there are n nodes% there exist 2
n
-n different trees.
13. List out few of the 6pplication of tree data3structure?
*he manipulation of Arithmetic e2pression,
Symbol *able construction,
Synta2 analysis.
1*. List out few of the applications that ma'e use of #ultilin'ed $tructures?
Sparse matri2, #nde2 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( -inked list
;
!ull %ranches
10. What is the type of the algorithm used in solving the 7 Aueens pro.lem?
%acktracking
15. +n an 6BL tree% at what condition the .alancing is to .e done?
#f the /pivotal value0 'or the /)eight factor0( is greater than < or less than &<.
17. What is the .uc'et siCe% when the overlapping and collision occur at same time?
One. #f there is only one entry possible in the bucket, when the collision occurs, there is no way to
accommodate the colliding value. *his results in the overlapping of values.
1?. Draverse the given tree using +norder% >reorder and >ostorder traversals.
#norder 4 D ) % 1 A . C # " C
3reorder4 A % D ) 1 C . " # C
3ostorder4 ) D 1 % . # C " 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?
<=.
#n general4
Dhere are 2
n
-1 nodes in a full .inary tree.
"y the method of elimination:
.ull binary trees contain odd number of nodes. So there cannot be full binary trees with D or <A
nodes, so re:ected. Eith <B nodes you can form a complete binary tree but not a full binary tree. So the correct
answer is <=.
Note:
.ull and Complete 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?
B
A
% C
D
1 . "
) #
C
"iven tree4
<
; B
A
=
At location ?
< ; B 6 6 A 6 6 =
$oot -C< $C< -C; $C; -CB $CB -CA $CA
where -Cn means -eft Child of node n and $Cn means $ight Child of node n
22. $ort the given values using Auic' $ort?
?= F@ F= D@ D= ?@ == =@ A=
Sorting takes place from the pivot value, which is the first value of the given elements, this is marked
bold. *he values at the left pointer and right pointer are indicated using
-
and
$
respectively.
65 F@
-
F= D@ D= ?@ == =@ A=
$
Since pivot is not yet changed the same process is continued after interchanging the values at
-
and
$
positions
65 A= F=
-
D@ D= ?@ == =@
$
F@
65 A= =@ D@
-
D= ?@ ==
$
F= F@
65 A= =@ == D=
-
?@
$
D@ F= F@
65 A= =@ == ?@
$
D=
-
D@ F= F@
Ehen the - and $ pointers cross each other the pivot value is interchanged with the value at right pointer. #f the
pivot is changed it means that the pivot has occupied its original position in the sorted order 'shown in bold
italics( and hence two different arrays are formed, one from start of the original array to the pivot position6< and
the other from pivot position8< to end.
60
-
A= =@ ==
$
65 85
-
D@ F= F@
$
55
-
A= =@
$
60 65 70
$
D@
-
F= 85
50
-
A=
$
55 60 65 70 D@
-
F=
$
85
#n the ne2t pass we get the sorted form of the array.
45 50 55 60 65 70 75 80 85
23. <or the given graph% draw the !<$ and "<$?
A
A
) G
" 3
1
H
C
*he given graph4
"<$: A G " ) 3 1 H C
!<$: A G ) 3 1 H C "
2*. ,lassify the )ashing <unctions .ased on the various methods .y which the 'ey value is found.
Direct method,
Subtraction method,
odulo6Division method,
Digit612traction method,
id6S,uare method,
.olding method,
3seudo6random method.
2-. What are the types of ,ollision esolution Dechni/ues and the methods used in each of the type?
Open addressing 'closed hashing(,
*he methods used include4
Overflow block,
Closed addressing 'open hashing(
*he methods used include4
-inked list,
%inary treeI
20. +n !"#$% what is the efficient data structure used in the internal storage representation?
%8 tree. %ecause in %8 tree, all the data is stored only in leaf nodes, that makes searching easier. *his
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
27.Ef the following tree structure% which is% efficient considering space and time complexities?
=
<<
6
= F <J ;A
A
6
?
6
D
6
<?
6
;@ ;;
FD
J;
2a4 +ncomplete "inary Dree
2.4 ,omplete "inary Dree
2c4 <ull "inary Dree
'b( Complete %inary *ree.
"y the method of elimination:
.ull binary tree loses its nature when operations of insertions and deletions are done. .or
incomplete binary trees, e2tra storage is re,uired and overhead of !9-- node checking takes place. So
complete binary tree is the better one since the property of complete binary tree is maintained even after
operations like additions and deletions are done on it.
2?. What is a spanning Dree?
A spanning tree is a tree associated with a network. All the nodes of the graph appear on the tree once. A
minimum spanning tree is a spanning tree organized so that the total edge weight between nodes is minimized.
3@. !oes the minimum spanning tree of a graph give the shortest distance .etween any 2 specified nodes?
!o.
inimal spanning tree assures that the total weight of the tree is kept at its minimum. %ut it doesnFt
mean that the distance between any two nodes involved in the minimum6spanning tree is minimum.
31. ,onvert the given graph with weighted edges to minimal spanning tree.
the e,uivalent minimal spanning tree is4
32. Which is the simplest file structure?
2a4 $e/uential
2.4 +ndexed
2c4 andom
'a( Se,uential
33. Whether Lin'ed List is linear or &on3linear data structure?
?
< B
;
A
=
A<@
?@@
;@@
A@@
B<@
<A;<
;JD=
?<;
<
;
B
A
=
A<@
?<;
;@@
B<@
According to Access strategies -inked list is a linear one.
According to Storage -inked -ist is a !on6linear one.
3*. !raw a .inary Dree for the expression :
6 9 " 3 2, 8 !4 9 2> G A4
3-. <or the following ,E"EL code% draw the "inary tree?
@< S*9D1!*K$1C.
@; !A1.
@B .#$S*K!A1 3#C G'<@(.
@B -AS*K!A1 3#C G'<@(.
@; H1A$KO.KS*9DH.
@B .#$S*KS1 3#C GG.
@B S1CO!DKS1 3#C GG.
F
S*9D1!*K$1C
!A1 H1A$KO.KS*9DH
.#$S*K!A1 -AS*K!A1 .#$S*KS1 S1CO!DKS1
@<
@; @;
@B @B @B @B
6
7
7
A
%
8
L
C
3 D
M
C Aptitude
Note : All the programs are tested under *urbo CLC88 compilers.
#t is assumed that,
3rograms run under DOS environment,
*he underlying machine is an 2D? system,
3rogram is compiled using *urbo CLC88 compiler.
*he program output may depend on the information based on this assumptions 'for e2ample sizeof'int(
>> ; may be assumed(.
3redict the output or error's( for the following4
1. void main24
H
int const 9 pI-J
printf2KLdK%8829p44J
M
Answer:
Compiler error4 Cannot modify a constant value.
Explanation4
p is a pointer to a Nconstant integerN. %ut we tried to change the value of the Nconstant integerN.
2. main24
H
char sN OIKmanKJ
int iJ
for2iI@JsN i OJi884
printf2KPnLcLcLcLcK%sN i O%92s8i4%92i8s4%iNsO4J
M
Answer:
mmmm
aaaa
nnnn
Explanation4
sOiP, 7'i8s(, 7's8i(, iOsP are all different ways of e2pressing the same idea. "enerally array name
is the base address for that array. )ere s is the base address. i is the inde2 numberLdisplacement from the base
address. So, indirecting it with 7 is same as sOiP. iOsP may be surprising. %ut in the case of C it is same as sOiP.
3. main24
H
float me I 1.1J
dou.le you I 1.1J
D
C Aptitude

if2meIIyou4
printf2K+ love QK4J
else
printf2K+ hate QK4J
M
Answer:
# hate 9
Explanation4
.or floating point numbers (float, double, long double) the values cannot be predicted e2actly.
Depending on the number of bytes, the precession with of the value represented varies. .loat takes A bytes and
long double takes <@ bytes. So float stores @.J with less precision than long double.
Rule of Thumb:
!ever compare or at6least be cautious when using floating point numbers with relational
operators (>> , Q, R, R>, Q>,S> ) .
*. main24
H
static int var I -J
printf2KLd K%var334J
if2var4
main24J
M
Answer:
= A B ; <
Explanation:
Ehen static storage class is given, it is initialized once. *he change in the value of a static
variable is retained even between the function calls. ain is also treated like 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
Answer:
; ; ; ; ; ; B A ? =
Explanation:
#nitially pointer c is assigned to both p and q. #n the first loop, since only q is incremented and
not c , the value ; will be printed = times. #n second loop p itself is incremented. So the values ; B A ? = will be
printed.
0. main24
H
extern int iJ
J
iI2@J
printf2KLdK%i4J
M
Answer:
Lin'er 1rror 4 9ndefined symbol TKiT
Explanation:
e2tern storage class in the following declaration,
extern int i;
specifies to the compiler that the memory for i is allocated in some other program and that address will be given
to the current program at the time of linking. %ut linker finds that no other variable of name i is available in any
other program with memory space allocated for it. )ence a linker error has occurred .
5. main24
H
int iI31%jI31%'I@%lI2%mJ
mIi88((j88(('88SSl88J
printf2KLd Ld Ld Ld LdK%i%j%'%l%m4J
M
Answer:
@ @ < B <
Explanation :
-ogical operations always give a result of 1 or 0 . And also the logical A!D 'UU( operator has
higher priority over the logical O$ 'VV( operator. So the e2pression /i !! " !! #$ is e2ecuted first.
*he result of this e2pression is @ '6< UU 6< UU @ > @(. !ow the e2pression is @ VV ; which evaluates to <
'because O$ operator always gives < e2cept for /@ VV @0 combination6 for which it gives @(. So the value of m is
<. *he values of other variables are also incremented by <.
7. main24
H
char 9pJ
printf2KLd Ld K%siCeof29p4%siCeof2p44J
M
Answer:
< ;
Explanation:
*he sizeof'( operator gives the number of bytes taken by its operand. 3 is a character pointer,
which needs one byte for storing its value 'a character(. )ence sizeof'7p( gives a value of <. Since it needs two
bytes to store the address of the character pointer sizeof'p( gives ;.
?. 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
Answer :
three
Explanation :
*he default case can be placed anywhere inside the loop. #t is e2ecuted only when all other cases
doesnTt match.
1@. main24
H
printf2KLxK%31RR*4J
M
Answer:
fff@
Explanation :
6< is internally represented as all <Ts. Ehen left shifted four times the least significant A bits are
filled with @Ts.*he W2 format specifier specifies that the integer value be printed as a he2adecimal value.
11. main24
H
char stringNOIK)ello WorldKJ
display2string4J
M
void display2char 9string4
H
printf2KLsK%string4J
M
Answer:
,ompiler 1rror : *ype mismatch in redeclaration of function display
Explanation :
#n third line, when the function %ispl&' is encountered, the compiler doesnTt know anything
about the function display. #t assumes the arguments and return types to be integers, 'which is the default type(.
Ehen it sees the actual function %ispl&'( the arguments and type contradicts with what it has assumed
previously. )ence a compile time error occurs.
12. main24
H
int cI3 32J
printf2KcILdK%c4J
M
Answer:
c>;X
Explanation:
<<
)ere unary minus 'or negation( operator is used twice. Same maths rules applies, ie. minus 7
minus> plus.
)ote:
)owever you cannot give like 66;. %ecause 66 operator can only be applied to variables as a
%e*rement operator 'eg., i66(. ; is a constant and not a variable.
13. Tdefine int char
main24
H
int iI0-J
printf2KsiCeof2i4ILdK%siCeof2i44J
M
Answer:
sizeof'i(><
Explanation:
Since the Ydefine replaces the string int by the macro *h&r
1*. main24
H
int iI1@J
iIU iV1*J
>rintf 2KiILdK%i4J
M
Answer:
i>@
Explanation:
#n the e2pression +i,1- , !O* 'S( operator has more precedence than / Q0 symbol. + is a unary
logical operator. Si 'S<@( is @ 'not of true is false(. @Q<A is false 'zero(.
1-. TincludeRstdio.hV
main24
H
char sNOIHWaW%W.W%WcW%WPnW%WcW%WP@WMJ
char 9p%9str%9str1J
pI(sN3OJ
strIpJ
str1IsJ
printf2KLdK%889p 8 889str13324J
M
Answer:
FF
Explanation:
p is pointing to character TZnT. str< is pointing to character TaT 887p. Np is pointing to TZnT and that is
incremented by one.N the ASC## value of TZnT is <@, which is then incremented to <<. *he value of 887p is <<. 8
87str<, str< is pointing to TaT that is incremented by < and it becomes TbT. ASC## value of TbT is JD.
!ow performing '<< 8 JD & B;(, we get FF'NN(X
<;
So we get the output FF 44 NN 'Ascii is FF(.
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
Answer:
Some"arbage+alue666<
Explanation:
p>UaO;PO;PO;P you declare only two ;D arrays, but you are trying to access the third ;D'which
you are not declared( it will print garbage values. 7,>777a starting address of a is assigned integer pointer. !ow
, is pointing to starting address of a. #f you print 7,, it will print first element of BD array.
15. TincludeRstdio.hV
main24
H
struct xx
H
int xI3J
char nameNOIKhelloKJ
MJ
struct xx 9sJ
printf2KLdK%s3Vx4J
printf2KLsK%s3Vname4J
M
Answer:
Compiler 1rror
Explanation:
Hou should not initialize variables in declaration
17. TincludeRstdio.hV
main24
H
struct xx
H
int xJ
struct yy
H
char sJ
struct xx 9pJ
MJ
struct yy 9/J
MJ
M
Answer:
Compiler 1rror
<B
Explanation:
*he structure yy is nested within structure 22. )ence, the elements are of yy are to be accessed
through the instance of structure 22, which needs an instance of yy to be known. #f the instance is created after
defining the structure the compiler will not know about the instance relative to 22. )ence for nested structure yy
you have to declare member.
1?. main24
H
printf2KPna.K4J
printf2KP.siK4J
printf2KPrhaK4J
M
Answer:
hai
Explanation:
Zn 6 newline
Zb 6 backspace
Zr 6 linefeed
2@. main24
H
int iI-J
printf2KLdLdLdLdLdLdK%i88%i33%88i%33i%i4J
M
Answer:
A==A=
Explanation:
*he arguments in a function call are pushed into the stack from left to right. *he evaluation is by
popping out from the stack. and the evaluation is from right to left, hence the result.
21. Tdefine s/uare2x4 x9x
main24
H
int iJ
i I 0*Gs/uare2*4J
printf2KLdK%i4J
M
Answer:
?A
Explanation:
the macro call s,uare'A( will substituted by A7A so the e2pression becomes i > ?ALA7A . Since L
and 7 has e,ual priority the e2pression will be evaluated as '?ALA(7A i.e. <?7A > ?A

22. main24
H
char 9pIKhai friendsK%9p1J
p1IpJ
while29pUIWP@W4 889p88J
printf2KLs LsK%p%p14J
M
Answer:
<A
ib:Sgs:foet
Explanation:
887p88 will be parse in the given order
7p that is value at the location currently pointed by p will be taken
887p the retrieved value will be incremented
when X is encountered the location will be incremented that is p88 will be e2ecuted
)ence, in the while loop initial value pointed by p is /h0, which is changed to /i0 by e2ecuting 887p and pointer
moves to point, /a0 which is similarly changed to /b0 and so on. Similarly blank space is converted to /S0. *hus,
we obtain value in p becomes [ib:Sgs:foet\ and since p reaches /Z@0 and p< points to p thus p<doesnot print
anything.
23. Tinclude Rstdio.hV
Tdefine a 1@
main24
H
Tdefine a -@
printf2KLdK%a4J
M
Answer:
=@
Explanation:
*he preprocessor directives can be redefined anywhere in the program. So the most recently
assigned value will be taken.
2*. Tdefine clrscr24 1@@
main24
H
clrscr24J
printf2KLdPnK%clrscr244J
M
Answer:
<@@
Explanation:
3reprocessor e2ecutes as a seperate pass before the e2ecution of the compiler. So te2tual
replacement of clrscr'( to <@@ occurs.*he input program to compiler looks like this 4
main'(
]
<@@X
printf'NWdZnN,<@@(X
^
)ote:
<@@X is an e2ecutable statement but with no action. So it doesnTt give any problem
2-. main24
H
printf2KLpK%main4J
M
Answer:
Some address will be printed.
Explanation:
.unction names are :ust addresses ':ust like array names are addresses(.
<=
main'( is also a function. So the address of function main will be printed. Wp in printf specifies that the
argument is an address. *hey are printed as he2adecimal numbers.
;F( main'(
]
clrscr'(X
^
clrscr'(X
Answer:
!o outputLerror
Explanation:
*he first clrscr'( occurs inside a function. So it becomes a function call. #n the second clrscr'(X is
a function declaration 'because it is not inside any function(.
;D( enum colors ]%-AC_,%-91,"$11!^
main'(
]

printf'NWd..Wd..WdN,%-AC_,%-91,"$11!(X

return'<(X
^
Answer:
@..<..;
Explanation:
enum assigns numbers starting from @, if not e2plicitly defined.
;J( void main'(
]
char far 7farther,7farthestX

printf'NWd..WdN,sizeof'farther(,sizeof'farthest((X

^
Answer:
A..;
Explanation:
the second pointer is of char type and not a far pointer
B@( main'(
]
int i>A@@,:>B@@X
printf'NWd..WdN(X
^
Answer:
A@@..B@@
Explanation:
printf takes the values of the first two assignments of the program. Any number of printfTs may
be given. All of them take only the first two values. #f more number of assignments given in the
program,then printf will take garbage values.
<?
B<( main'(
]
char 7pX
p>N)elloNX
printf'NWcZnN,7U7p(X
^
Answer:
)
Explanation:
7 is a dereference operator U is a reference operator. *hey can be applied any number of times
provided it is meaningful. )ere p points to the first character in the string N)elloN. 7p
dereferences it and so its value is ). Again U references it to an address and 7 dereferences it to
the value ).
B;( main'(
]
int i><X
while 'iR>=(
]
printf'NWdN,i(X
if 'iQ;(
goto hereX
i88X
^
^
fun'(
]
here4
printf'N33N(X
^
Answer:
Compiler error4 9ndefined label ThereT in function main
Explanation:
-abels have functions scope, in other words *he scope of the labels is limited to functions . *he
label ThereT is available in function fun'( )ence it is not visible in function main.
BB( main'(
]
static char namesO=PO;@P>]NpascalN,NadaN,NcobolN,NfortranN,NperlN^X
int iX
char 7tX
t>namesOBPX
namesOBP>namesOAPX
namesOAP>tX
for 'i>@XiR>AXi88(
printf'NWsN,namesOiP(X
^
Answer:
Compiler error4 -value re,uired in function main
Explanation:
<F
Array names are pointer constants. So it cannot be modified.
BA( void main'(
]
int i>=X
printf'NWdN,i88 8 88i(X
^
Answer:
Output Cannot be predicted e2actly.
Explanation:
Side effects are involved in the evaluation of i
B=( void main'(
]
int i>=X
printf'NWdN,i88888i(X
^
Answer:
Compiler 1rror
Explanation:
*he e2pression i88888i is parsed as i 88 88 8 i which is an illegal combination of operators.


B?( YincludeRstdio.hQ
main'(
]
int i><,:>;X
switch'i(
]
case <4 printf'N"OODN(X
breakX
case :4 printf'N%ADN(X
breakX
^
^
Answer:
Compiler 1rror4 Constant e2pression re,uired in function main.
Explanation:
*he case statement can have only constant e2pressions 'this implies that we cannot use variable
names directly so an error(.
)ote:
1numerated types can be used in case statements.
BF( main'(
]
int iX
printf'NWdN,scanf'NWdN,Ui((X LL value <@ is given as input here
^
Answer:
<
Explanation:
<D
Scanf returns number of items successfully read and not <L@. )ere <@ is given as input which
should have been scanned successfully. So number of items read is <.
BD( Ydefine f'g,g;( gYYg;
main'(
]
int var<;><@@X
printf'NWdN,f'var,<;((X
^
Answer:
<@@
BJ( main'(
]
int i>@X

for'Xi88Xprintf'NWdN,i(( X
printf'NWdN,i(X
^
Answer:
<
Explanation:
before entering into the for loop the checking condition is NevaluatedN. )ere it evaluates to @
'false( and comes out of the loop, and i is incremented 'note the semicolon after the for loop(.
A@( YincludeRstdio.hQ
main'(
]
char sOP>]TaT,TbT,TcT,TZnT,TcT,TZ@T^X
char 7p,7str,7str<X
p>UsOBPX
str>pX
str<>sX
printf'NWdN,887p 8 887str<6B;(X
^
Answer:

Explanation:
p is pointing to character TZnT.str< is pointing to character TaT 887p meAnswer4Np is pointing to TZnT
and that is incremented by one.N the ASC## value of TZnT is <@. then it is incremented to <<. the
value of 887p is <<. 887str< meAnswer4Nstr< is pointing to TaT that is incremented by < and it
becomes TbT. ASC## value of TbT is JD. both << and JD is added and result is subtracted from B;.
i.e. '<<8JD6B;(>FF'NN(X
A<( YincludeRstdio.hQ
main'(
]
struct 22
]
<J
int 2>BX
char nameOP>NhelloNX
^X
struct 22 7s>malloc'sizeof'struct 22((X
printf'NWdN,s6Q2(X
printf'NWsN,s6Qname(X
^
Answer:
Compiler 1rror
Explanation:
#nitialization should not be done for structure members inside the structure declaration
A;( YincludeRstdio.hQ
main'(
]
struct 22
]
int 2X
struct yy
]
char sX
struct 22 7pX
^X
struct yy 7,X
^X
^
Answer:
Compiler 1rror
Explanation:
in the end of nested structure yy a member have to be declared.
AB( main'(
]
e2tern int iX
i>;@X
printf'NWdN,sizeof'i((X
^
Answer:
-inker error4 undefined symbol TKiT.
Explanation:
e2tern declaration specifies that the variable i is defined somewhere else. *he compiler passes
the e2ternal variable to be resolved by the linker. So compiler doesnTt find an error. During
linking the linker searches for the definition of i. Since it is not found the linker flags an error.
AA( main'(
]
printf'NWdN, out(X
^
int out><@@X
Answer:
Compiler error4 undefined symbol out in function main.
;@
Explanation:
*he rule is that a variable is available for use from the point of declaration. 1ven though a is a
global variable, it is not available for main. )ence an error.
A=( main'(
]
e2tern outX
printf'NWdN, out(X
^
int out><@@X
Answer:
<@@
Explanation:
*his is the correct way of writing the previous program.

A?( main'(
]
show'(X
^
void show'(
]
printf'N#Tm the greatestN(X
^
Answer:
Compier error4 *ype mismatch in redeclaration of show.
Explanation:
Ehen the compiler sees the function show it doesnTt know anything about it. So the default
return type 'ie, int( is assumed. %ut when compiler sees the actual definition of show mismatch
occurs since it is declared as void. )ence the error.
*he solutions are as follows4
<. declare void show'( in main'( .
;. define show'( before main'(.
B. declare e2tern void show'( before the use of show'(.

AF( main' (
]
int aO;POBPO;P > ]]];,A^,]F,D^,]B,A^^,]];,;^,];,B^,]B,A^^^X
printf'[Wu Wu Wu Wd Zn\,a,7a,77a,777a(X
printf'[Wu Wu Wu Wd Zn\,a8<,7a8<,77a8<,777a8<(X
^
Answer:
<@@, <@@, <@@, ;
<<A, <@A, <@;, B
Explanation:
*he given array is a B6D one. #t can also be viewed as a <6D array.
; A F D B A ; ; ; B B A
<@@ <@; <@A <@? <@D <<@ <<; <<A <<? <<D <;@ <;;
thus, for the first printf statement a, 7a, 77a give address of first element . since the indirection
777a gives the value. )ence, the first line of the output.
;<
for the second printf a8< increases in the third dimension thus points to value at <<A, 7a8<
increments in second dimension thus points to <@A, 77a 8< increments the first dimension thus
points to <@; and 777a8< first gets the value at first location and then increments it by <. )ence,
the output.
AD( main' (
]
int aO P > ]<@,;@,B@,A@,=@^,:,7pX
for':>@X :R=X :88(
]
printf'[Wd\ ,7a(X
a88X
^
p > aX
for':>@X :R=X :88(
]
printf'[Wd \ ,7p(X
p88X
^
^
Answer:
Compiler error4 lvalue re,uired.
Explanation:
1rror is in line with statement a88. *he operand must be an lvalue and may be of any of scalar
type for the any operator, array name only when subscripted is an lvalue. Simply array name is a
non6modifiable lvalue.
AJ( main' (
]
static int aO P > ]@,<,;,B,A^X
int 7pO P > ]a,a8<,a8;,a8B,a8A^X
int 77ptr > pX
ptr88X
printf'[Zn Wd Wd Wd\, ptr6p, 7ptr6a, 77ptr(X
7ptr88X
printf'[Zn Wd Wd Wd\, ptr6p, 7ptr6a, 77ptr(X
788ptrX
printf'[Zn Wd Wd Wd\, ptr6p, 7ptr6a, 77ptr(X
887ptrX
printf'[Zn Wd Wd Wd\, ptr6p, 7ptr6a, 77ptr(X
^
Answer:
111
222
333
3**
Explanation:
-et us consider the array and the two pointers with some address
&
@ < ; B A
;;
<@@ <@; <@A <@? <@D
p
<@@ <@; <@A <@? <@D
<@@@ <@@; <@@A <@@? <@@D
ptr
<@@@
;@@@
After e2ecution of the instruction ptr88 value in ptr becomes <@@;, if scaling factor for integer is
; bytes. !ow ptr & p is value in ptr & starting location of array p, '<@@; & <@@@( L 'scaling factor(
> <, 7ptr & a > value at address pointed by ptr & starting value of array a, <@@; has a value <@;
so the value is '<@; & <@@(L'scaling factor( > <, 77ptr is the value stored in the location pointed
by the pointer of ptr > value pointed by value pointed by <@@; > value pointed by <@; > <.
)ence the output of the firs printf is <, <, <.
After e2ecution of 7ptr88 increments value of the value in ptr by scaling factor, so it
becomes<@@A. )ence, the outputs for the second printf are ptr & p > ;, 7ptr & a > ;, 77ptr > ;.
After e2ecution of 788ptr increments value of the value in ptr by scaling factor, so it
becomes<@@A. )ence, the outputs for the third printf are ptr & p > B, 7ptr & a > B, 77ptr > B.
After e2ecution of 887ptr value in ptr remains the same, the value pointed by the value is
incremented by the scaling factor. So the value in array p at location <@@? changes from <@? <@
<@D,. )ence, the outputs for the fourth printf are ptr & p > <@@? & <@@@ > B, 7ptr & a > <@D & <@@
> A, 77ptr > A.
=@( main' (
]
char 7,X
int :X
for ':>@X :RBX :88( scanf'[Ws\ ,',8:((X
for ':>@X :RBX :88( printf'[Wc\ ,7',8:((X
for ':>@X :RBX :88( printf'[Ws\ ,',8:((X
^
Explanation:
)ere we have only one pointer to type char and since we take input in the same pointer thus we
keep writing over in the same location, each time shifting the pointer value by <. Suppose the
inputs are O9S1, *$AC_ and +#$*9A-. *hen for the first input suppose the pointer starts at
location <@@ then the input one is stored as
O 9 S 1 Z@
Ehen the second input is given the pointer is incremented as : value becomes <, so the input is
filled in memory starting from <@<.
* $ A C _ Z@
*he third input starts filling from the location <@;
* + # $ * 9 A - Z@
*his is the final value stored .
*he first printf prints the values at the position ,, ,8< and ,8; > * +
*he second printf prints three strings starting from locations ,, ,8<, ,8;
i.e *+#$*9A-, *+#$*9A- and +#$*9A-.

=<( main' (
]
void 7vpX
char ch > /g0, 7cp > [goofy\X
;B
int : > ;@X
vp > UchX
printf'[Wc\, 7'char 7(vp(X
vp > U:X
printf'[Wd\,7'int 7(vp(X
vp > cpX
printf'[Ws\,'char 7(vp 8 B(X
^
Answer:
g;@fy
Explanation:
Since a void pointer is used it can be type casted to any other type pointer. vp > Uch stores
address of char ch and the ne2t statement prints the value stored in vp after type casting it to the
proper data type pointer. the output is /g0. Similarly the output from second printf is /;@0. *he
third printf statement type casts it to print the string from the A
th
value hence the output is /fy0.
=;( main ' (
]
static char 7sO P > ][black\, [white\, [yellow\, [violet\^X
char 77ptrO P > ]s8B, s8;, s8<, s^, 777pX
p > ptrX
7788pX
printf'[Ws\,766788p 8 B(X
^
Answer:
ck
Explanation:
#n this problem we have an array of char pointers pointing to start of A strings. *hen 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 > s8B. *he ne2t statement increment
value in p by < , thus now value of p > s8;. #n the printf statement the e2pression is evaluated
788p causes gets value s8< then the pre decrement is e2ecuted and we get s8< & < > s . the
indirection operator now gets the value from the array of s and adds B to the starting address. *he
string is printed starting from this position. *hus, the output is /ck0.
=B( main'(
]
int i, nX
char 72 > [girl\X
n > strlen'2(X
72 > 2OnPX
for'i>@X iRnX 88i(
]
printf'[WsZn\,2(X
288X
^
^
Answer:
'blank space(
irl
rl
;A
l
Explanation:
)ere a string 'a pointer to char( is initialized with a value [girl\. *he strlen function returns the
length of the string, thus n has a value A. *he ne2t statement assigns value at the nth location
'/Z@0( to the first location. !ow the string becomes [Z@irl\ . !ow the printf statement prints the
string after each iteration it increments it starting position. -oop starts from @ to A. *he first time
2O@P > /Z@0 hence it prints nothing and pointer value is incremented. *he second time it prints
from 2O<P i.e [irl\ and the third time it prints [rl\ and the last time it prints [l\ and the loop
terminates.
=A( int i,:X
for'i>@XiR><@Xi88(
]
:8>=X
assert'iR=(X
^
Answer:
$untime error4 Abnormal program termination.
assert failed 'iR=(, Rfile nameQ,Rline numberQ
Explanation:
asserts are used during debugging to make sure that certain conditions are satisfied. #f assertion
fails, the program will terminate reporting the same. After debugging use,
Yundef !D1%9"
and this will disable all the assertions from the source code. Assertion
is a good debugging tool to make use of.

==( main'(
]
int i>6<X
8iX
printf'Ni > Wd, 8i > Wd ZnN,i,8i(X
^
Answer:
i > 6<, 8i > 6<
Explanation:
9nary 8 is the only dummy operator in C. Ehere6ever it comes you can :ust ignore it :ust
because it has no effect in the e2pressions 'hence the name dummy operator(.
=?( Ehat are the files which are automatically opened when a C file is e2ecuted`
Answer:
stdin, stdout, stderr 'standard input,standard output,standard error(.
=F( what will be the position of the file marker`
a4 fseek'ptr,@,S11_KS1*(X
b4 fseek'ptr,@,S11_KC9$(X
Answer :
a4 *he S11_KS1* sets the file position marker to the starting of the file.
b4 *he S11_KC9$ sets the file position marker to the current position
of the file.
;=
=D( main'(
]
char nameO<@P,sO<;PX
scanf'N ZNWO5ZNPZNN,s(X
^
)ow scanf will e2ecute`
Answer:
.irst it checks for the leading white space and discards it.*hen it matches with a ,uotation mark
and then it reads all character upto another ,uotation mark.
=J( Ehat is the problem with the following code segment`
while ''fgets'receiving array,=@,fileKptr(( S> 1O.(
X
Answer & Explanation:
fgets returns a pointer. So the correct end of file check is checking for S> !9--.
?@( main'(
]
main'(X
^
Answer:
$untime error 4 Stack overflow.
Explanation:
main function calls itself again and again. 1ach time the function is called its return address is
stored in the call stack. Since there is no condition to terminate the function call, the call stack
overflows at runtime. So it terminates the program and results in an error.
?<( main'(
]
char 7cptr,cX
void 7vptr,vX
c><@X v>@X
cptr>UcX vptr>UvX
printf'NWcWvN,c,v(X
^
Answer:
Compiler error 'at line number A(4 size of v is 9nknown.
Explanation:
Hou can create a variable of type void 7 but not of type void, since void is an empty type. #n the
second line you are creating variable vptr of type void 7 and v of type void hence an error.
?;( main'(
]
char 7str<>NabcdNX
char str;OP>NabcdNX
printf'NWd Wd WdN,sizeof'str<(,sizeof'str;(,sizeof'NabcdN((X
^
Answer:
; = =
Explanation:
;?
#n first sizeof, str< is a character pointer so it gives you the size of the pointer variable. #n second
sizeof the name str; indicates the name of the array whose size is = 'including the TZ@T termination
character(. *he third sizeof is similar to the second one.
?B( main'(
]
char notX
not>S;X
printf'NWdN,not(X
^
Answer:
@
Explanation:
S is a logical operator. #n C the value @ is considered to be the boolean value .A-S1, and any
non6zero value is considered to be the boolean value *$91. )ere ; is a non6zero value so
*$91. S*$91 is .A-S1 '@( so it prints @.
?A( Ydefine .A-S1 6<
Ydefine *$91 <
Ydefine !9-- @
main'( ]
if'!9--(
puts'N!9--N(X
else if'.A-S1(
puts'N*$91N(X
else
puts'N.A-S1N(X
^
Answer:
*$91
Explanation4
*he input program to the compiler after processing by the preprocessor is,
main'(]
if'@(
puts'N!9--N(X
else if'6<(
puts'N*$91N(X
else
puts'N.A-S1N(X
^
3reprocessor doesnTt replace the values given inside the double ,uotes. *he check by if condition
is boolean value false so it goes to else. #n second if 6< is boolean value true hence N*$91N is
printed.
?=( main'(
]
int k><X
printf'NWd>>< is NNWsN,k,k>><`N*$91N4N.A-S1N(X
^
Answer:
<>>< is *$91
;F
Explanation:
Ehen two strings are placed together 'or separated by white6space( they are concatenated 'this is
called as NstringizationN operation(. So the string is as if it is given as NWd>>< is WsN. *he
conditional operator' `4 ( evaluates to N*$91N.
??( main'(
]
int yX
scanf'NWdN,Uy(X LL input given is ;@@@
if' 'yWA>>@ UU yW<@@ S> @( VV yW<@@ >> @ (
printf'NWd is a leap yearN(X
else
printf'NWd is not a leap yearN(X
^
Answer:
;@@@ is a leap year
Explanation:
An ordinary program to check if leap year or not.
?F( Ydefine ma2 =
Ydefine int arr<Oma2P
main'(
]
typedef char arr;Oma2PX
arr< list>]@,<,;,B,A^X
arr; name>NnameNX
printf'NWd WsN,listO@P,name(X
^
Answer:
Compiler error 'in the line arr< list > ]@,<,;,B,A^(
Explanation:
arr; is declared of type array of size = of characters. So it can be used to declare the variable
name of the type arr;. %ut it is not the case of arr<. )ence an error.
Rule of Thumb:
Ydefines are used for te2tual replacement whereas typedefs are used for declaring new types.
?D( int i><@X
main'(
]
e2tern int iX
]
int i>;@X
]
const volatile unsigned i>B@X
printf'NWdN,i(X
^
printf'NWdN,i(X
^
printf'NWdN,i(X
^
Answer:
;D
B@,;@,<@
Explanation:
T]T introduces new block and thus new scope. #n the innermost block i is declared as,
const volatile unsigned
which is a valid declaration. i is assumed of type int. So printf prints B@. #n the ne2t block, i has
value ;@ and so printf prints ;@. #n the outermost block, i is declared as e2tern, so no storage
space is allocated for it. After compilation is over the linker resolves it to global variable i 'since
it is the only variable visible there(. So it prints iTs value as <@.
?J( main'(
]
int 7:X
]
int i><@X
:>UiX
^
printf'NWdN,7:(X
^
Answer:
<@
Explanation4
*he variable i is a block level variable and the visibility is inside that block only. %ut the lifetime
of i is lifetime of the function so it lives upto the e2it of main function. Since the i is still
allocated space, 7: prints the value stored in i since : points i.
F@( main'(
]
int i>6<X
6iX
printf'Ni > Wd, 6i > Wd ZnN,i,6i(X
^
Answer:
i > 6<, 6i > <
Explanation:
6i is e2ecuted and this e2ecution doesnTt affect the value of i. #n printf first you :ust print the
value of i. After that the value of the e2pression 6i > 6'6<( is printed.
F<( YincludeRstdio.hQ
main'(
]
const int i>AX
float :X
: > 88iX
printf'NWd WfN, i,88:(X
^
Answer4
Compiler error
Explanation4
i is a constant. you cannot change the value of constant
F;( YincludeRstdio.hQ
;J
main'(
]
int aO;PO;PO;P > ] ]<@,;,B,A^, ]=,?,F,D^ ^X
int 7p,7,X
p>UaO;PO;PO;PX
7,>777aX
printf'NWd..WdN,7p,7,(X
^
Answer:
garbagevalue..<
Explanation:
p>UaO;PO;PO;P you declare only two ;D arrays. but you are trying to access the third ;D'which
you are not declared( it will print garbage values. 7,>777a starting address of a is assigned
integer pointer. now , is pointing to starting address of a.if you print 7, meAnswer4it will print
first element of BD array.
FB( YincludeRstdio.hQ
main'(
]
register i>=X
char :OP> NhelloNX
printf'NWs WdN,:,i(X
^
Answer:
hello =
Explanation4
if you declare i as register compiler will treat it as ordinary integer and it will take integer value.
i value may be stored either in register or in memory.
FA( main'(
]
int i>=,:>?,zX
printf'NWdN,i888:(X
^
Answer:
<<
Explanation:
the e2pression i888: is treated as 'i88 8 :(

F?( struct aaa]
struct aaa 7prevX
int iX
struct aaa 7ne2tX
^X
main'(
]
struct aaa abc,def,ghi,:klX
int 2><@@X
abc.i>@Xabc.prev>U:klX
abc.ne2t>UdefX
def.i><Xdef.prev>UabcXdef.ne2t>UghiX
B@
ghi.i>;Xghi.prev>UdefX
ghi.ne2t>U:klX
:kl.i>BX:kl.prev>UghiX:kl.ne2t>UabcX
2>abc.ne2t6Qne2t6Qprev6Qne2t6QiX
printf'NWdN,2(X
^
Answer:
;
Explanation:
above all statements form a double circular linked listX
abc.ne2t6Qne2t6Qprev6Qne2t6Qi
this one points to NghiN node the value of at particular node is ;.
FF( struct point
]
int 2X
int yX
^X
struct point origin,7ppX
main'(
]
pp>UoriginX
printf'Norigin is'WdWd(ZnN,'7pp(.2,'7pp(.y(X
printf'Norigin is 'WdWd(ZnN,pp6Q2,pp6Qy(X
^
Answer:
origin is'@,@(
origin is'@,@(
Explanation4
pp is a pointer to structure. we can access the elements of the structure either with arrow mark or
with indirection operator.
)ote:
Since structure point is globally declared 2 U y are initialized as zeroes
FD( main'(
]
int i>KlKabc'<@(X
printf'NWdZnN,66i(X
^
int KlKabc'int i(
]
return'i88(X
^
Answer:
J
Explanation:
return'i88( it will first return i and then increments. i.e. <@ will be returned.
FJ( main'(
]
B<
char 7pX
int 7,X
long 7rX
p>,>r>@X
p88X
,88X
r88X
printf'NWp...Wp...WpN,p,,,r(X
^
Answer:
@@@<...@@@;...@@@A
Explanation:
88 operator when applied to pointers increments address according to their corresponding data6
types.
D@( main'(
]
char c>T T,2,convert'z(X
getc'c(X
if''cQ>TaT( UU 'cR>TzT((
2>convert'c(X
printf'NWcN,2(X
^
convert'z(
]
return z6B;X
^
Answer:
Compiler error
Explanation:
declaration of convert and format of getc'( are wrong.
D<( main'int argc, char 77argv(
]
printf'Nenter the characterN(X
getchar'(X
sum'argvO<P,argvO;P(X
^
sum'num<,num;(
int num<,num;X
]
return num<8num;X
^
Answer:
Compiler error.
Explanation:
argvO<P U argvO;P are strings. *hey are passed to the function sum without converting it to
integer values.
D;( Y include Rstdio.hQ
int oneKdOP>]<,;,B^X
B;
main'(
]
int 7ptrX
ptr>oneKdX
ptr8>BX
printf'NWdN,7ptr(X
^
Answer4
garbage value
Explanation:
ptr pointer is pointing to out of the array range of oneKd.
DB( Y includeRstdio.hQ
aaa'( ]
printf'NhiN(X
^
bbb'(]
printf'NhelloN(X
^
ccc'(]
printf'NbyeN(X
^
main'(
]
int '7ptrOBP('(X
ptrO@P>aaaX
ptrO<P>bbbX
ptrO;P>cccX
ptrO;P'(X
^
Answer4
bye
Explanation:
ptr is array of pointers to functions of return type int.ptrO@P is assigned to address of the function
aaa. Similarly ptrO<P and ptrO;P for bbb and ccc respectively. ptrO;P'( is in effect of writing ccc'(,
since ptrO;P points to ccc.
D=( YincludeRstdio.hQ
main'(
]
.#-1 7ptrX
char iX
ptr>fopen'Nzzz.cN,NrN(X
while''i>fgetch'ptr((S>1O.(
printf'NWcN,i(X
^
Answer:
contents of zzz.c followed by an infinite loop
Explanation:
*he condition is checked against 1O., it should be checked against !9--.
BB
D?( main'(
]
int i >@X:>@X
if'i UU :88(
printf'NWd..WdN,i88,:(X
printf'NWd..Wd,i,:(X
^
Answer:
@..@
Explanation:
*he value of i is @. Since this information is enough to determine the truth value of the boolean
e2pression. So the statement following the if statement is not e2ecuted. *he values of i and :
remain unchanged and get printed.

DF( main'(
]
int iX
i > abc'(X
printf'NWdN,i(X
^
abc'(
]
KAG > <@@@X
^
Answer:
<@@@
Explanation:
!ormally the return value from the function is through the information from the accumulator.
)ere KA) is the pseudo global variable denoting the accumulator. )ence, the value of the
accumulator is set <@@@ so the function returns value <@@@.
DD( int iX
main'(]
int tX
for ' t>AXscanf'NWdN,Ui(6tXprintf'NWdZnN,i((
printf'NWd66N,t66(X
^
LL #f the inputs are @,<,;,B find the oLp
Answer:
A66@
B66<
;66;
Explanation:
-et us assume some 2> scanf'NWdN,Ui(6t the values during e2ecution
will be,
t i 2
A @ 6A
B < 6;
; ; @

DJ( main'(]
BA
int a> @Xint b > ;@Xchar 2 ><Xchar y ><@X
if'a,b,2,y(
printf'NhelloN(X
^
Answer:
hello
Explanation:
*he comma operator has associativity from left to right. Only the rightmost value is returned and
the other values are evaluated and ignored. *hus the value of last variable y is returned to check
in if. Since it is a non zero value if becomes true so, NhelloN will be printed.
J@( main'(]
unsigned int iX
for'i><XiQ6;Xi66(
printf'Nc aptitudeN(X
^
Explanation:
i is an unsigned integer. #t is compared with a signed value. Since the both types doesnTt match,
signed is promoted to unsigned value. *he unsigned e,uivalent of 6; is a huge value so condition
becomes false and control comes out of the loop.
J<( #n the following pgm add a stmt in the function fun such that the address of
TaT gets stored in T:T.
main'(]
int 7 :X
void fun'int 77(X
fun'U:(X
^
void fun'int 77k( ]
int a >@X
L7 add a stmt here7L
^
Answer:
7k > Ua
Explanation:
*he argument of the function is a pointer to a pointer.

J;( Ehat are the following notations of defining functions known as`
i. int abc'int a,float b(
]
L7 some code 7L
^
ii. int abc'a,b(
int aX float bX
]
L7 some code7L
^
Answer:
i. A!S# C notation
ii. _ernighan U $itche notation
B=
JB( main'(
]
char 7pX
p>NWdZnNX
p88X
p88X
printf'p6;,B@@(X
^
Answer:
B@@
Explanation:
*he pointer points to W since it is incremented twice and again decremented by ;, it points to
TWdZnT and B@@ is printed.
JA( main'(]
char aO<@@PX
aO@P>TaTXaO<PP>TbTXaO;P>TcTXaOAP>TdTX
abc'a(X
^
abc'char aOP(]
a88X
printf'NWcN,7a(X
a88X
printf'NWcN,7a(X
^
Explanation:
*he base address is modified only in function and as a result a points to TbT then after
incrementing to TcT so bc will be printed.

J=( func'a,b(
int a,bX
]
return' a> 'a>>b( (X
^
main'(
]
int process'(,func'(X
printf'N*he value of process is Wd SZn N,process'func,B,?((X
^
process'pf,val<,val;(
int '7pf( '(X
int val<,val;X
]
return''7pf( 'val<,val;((X
^
Answer:
*he value if process is @ S
Explanation:
*he function TprocessT has B parameters 6 <, a pointer to another function ; and B, integers. Ehen
this function is invoked from main, the following substitutions for formal parameters take place4
func for pf, B for val< and ? for val;. *his function returns the result of the operation performed
B?
by the function TfuncT. *he function func has two integer parameters. *he formal parameters are
substituted as B for a and ? for b. since B is not e,ual to ?, a>>b returns @. therefore the function
returns @ which in turn is returned by the function TprocessT.
J?( void main'(
]
static int i>=X
if'66i(]
main'(X
printf'NWd N,i(X
^
^
Answer:
@ @ @ @
Explanation:
*he variable N#N is declared as static, hence memory for # will be allocated for only once, as it
encounters the statement. *he function main'( will be called recursively unless # becomes e,ual to @, and
since main'( is recursively called, so the value of static # ie., @ will be printed every time the control is
returned.
JF( void main'(
]
int k>ret'sizeof'float((X
printf'NZn here value is WdN,88k(X
^
int ret'int ret(
]
ret 8> ;.=X
return'ret(X
^
Answer:
)ere value is F
Explanation:
*he int ret'int ret(, ie., the function name and the argument name can be the same.
.irstly, the function ret'( is called in which the sizeof'float( ie., A is passed, after the first
e2pression the value in ret will be ?, as ret is integer hence the value stored in ret will have implicit type
conversion from float to int. *he ret is returned in main'( it is printed after and preincrement.

JD( void main'(
]
char aOP>N<;BA=Z@NX
int i>strlen'a(X
printf'Nhere in B WdZnN,88i(X
^
Answer:
here in B ?
Explanation:
*he char array TaT will hold the initialized string, whose length will be counted from @ till the null
character. )ence the T#T will hold the value e,ual to =, after the pre6increment in the printf statement, the
? will be printed.
BF
JJ( void main'(
]
unsigned giveit>6<X
int gotitX
printf'NWu N,88giveit(X
printf'NWu ZnN,gotit>66giveit(X
^
Answer:
@ ?==B=
Explanation:
<@@( void main'(
]
int iX
char aOP>NZ@NX
if'printf'NWsZnN,a((
printf'NOk here ZnN(X
else
printf'N.orget itZnN(X
^
Answer:
Ok here
Explanation:
3rintf will return how many characters does it print. )ence printing a null character
returns < which makes the if statement true, thus NOk hereN is printed.

<@<( void main'(
]
void 7vX
int integer>;X
int 7i>UintegerX
v>iX
printf'NWdN,'int7(7v(X
^
Answer:
Compiler 1rror. Ee cannot apply indirection on type void7.
Explanation:
+oid pointer is a generic pointer type. !o pointer arithmetic can be done on it. +oid pointers
are normally used for,
<. 3assing generic pointers to functions and returning such pointers.
;. As a intermediate pointer type.
B. 9sed when the e2act pointer type will be known at a later point of time.
<@;( void main'(
]
int i>i88,:>:88,k>k88X
printf'[WdWdWd\,i,:,k(X
^
Answer:
"arbage values.
Explanation:
BD
6n identifier is availa.le to use in program code from the point of its declaration.
So e2pressions such as i > i88 are valid statements. *he i, : and k are automatic variables and so
they contain some garbage value. =ar.age in is gar.age out 2=+=E4.
<@B( void main'(
]
static int i>i88, :>:88, k>k88X
printf'[i > Wd : > Wd k > Wd\, i, :, k(X
^
Answer:
i > < : > < k > <
Explanation:
Since static variables are initialized to zero by default.
<@A( void main'(
]
while'<(]
if'printf'NWdN,printf'NWdN(((
breakX
else
continueX
^
^
Answer:
"arbage values
Explanation:
*he inner printf e2ecutes first to print some garbage value. *he printf returns no of characters
printed and this value also cannot be predicted. Still the outer printf prints something and so
returns a non6zero value. So it encounters the break statement and comes out of the while
statement.
<@A( main'(
]
unsigned int i><@X
while'i66Q>@(
printf'NWu N,i(X
^
Answer:
<@ J D F ? = A B ; < @ ?==B= ?==BAI..
Explanation:
Since i is an unsigned integer it can never become negative. So the e2pression i66 Q>@ will
always be true, leading to an infinite loop.
<@=( YincludeRconio.hQ
main'(
]
int 2,y>;,z,aX
if'2>yW;( z>;X
a>;X
BJ
printf'NWd Wd N,z,2(X
^
Answer:
"arbage6value @
Explanation:
*he value of yW; is @. *his value is assigned to 2. *he condition reduces to if '2( or in other
words if'@( and so z goes uninitialized.
Thu! "ule: .heck all control paths to write bug free code.
<@?( main'(
]
int aO<@PX
printf'NWdN,7a8<67a8B(X
^
Answer:
A
Explanation:
7a and 67a cancels out. *he result is as simple as < 8 B > A S
<@F( Ydefine prod'a,b( a7b
main'(
]
int 2>B,y>AX
printf'NWdN,prod'28;,y6<((X
^
Answer:
<@
Explanation:
*he macro e2pands and evaluates to as4
28;7y6< >Q 28';7y(6< >Q <@
<@D( main'(
]
unsigned int i>?=@@@X
while'i88S>@(X
printf'NWdN,i(X
^
Answer:
<
Explanation:
!ote the semicolon after the while statement. Ehen the value of i becomes @ it comes out of
while loop. Due to post6increment on i the value of i while printing is <.

<@J( main'(
]
int i>@X
while'8'8i66(S>@(
i6>i88X
printf'NWdN,i(X
^
Answer:
A@
6<
Explanation:
Qnary 8 is the only dummy operator in ,. So it has no effect on the e2pression and now the
while loop is, while'i66S>@( which is false and so breaks out of while loop. *he value &< is
printed due to the post6decrement operator.

<<B( main'(
]
float f>=,g><@X
enum]i><@,:>;@,k>=@^X
printf'NWdZnN,88k(X
printf'NWfZnN,fRR;(X
printf'NWlfZnN,fWg(X
printf'NWlfZnN,fmod'f,g((X
^
Answer:
-ine no =4 1rror4 -value re,uired
-ine no ?4 Cannot apply leftshift to float
-ine no F4 Cannot apply mod to float
Explanation:
1numeration constants cannot be modified, so you cannot apply 88.
%it6wise operators and W operators cannot be applied on float values.
fmod'( is to find the modulus values for floats as W operator is for ints.
<<@( main'(
]
int i><@X
void pascal f'int,int,int(X
f'i88,i88,i88(X
printf'N WdN,i(X
^
void pascal f'integer 4i,integer4:,integer 4k(
]
write'i,:,k(X
^
Answer:
Compiler error4 unknown type integer
Compiler error4 undeclared function write
Explanation:
3ascal keyword doesn0t mean that pascal code can be used. #t means that the function follows
3ascal argument passing mechanism in calling the functions.
<<<( void pascal f'int i,int :,int k(
]
printf'[Wd Wd Wd\,i, :, k(X
^
void cdecl f'int i,int :,int k(
]
printf'[Wd Wd Wd\,i, :, k(X
^
main'(
A<
]
int i><@X
f'i88,i88,i88(X
printf'N WdZnN,i(X
i><@X
f'i88,i88,i88(X
printf'N WdN,i(X
^
Answer:
<@ << <; <B
<; << <@ <B
Explanation:
3ascal argument passing mechanism forces the arguments to be called from left to right. cdecl is
the normal C argument passing mechanism where the arguments are passed from right to left.

<<;(. Ehat is the output of the program given below
main'(
]
signed char i>@X
for'XiQ>@Xi88( X
printf'NWdZnN,i(X
^
Answer
6<;D
Explanation
!otice the semicolon at the end of the for loop. *)e initial value of the i is set to @. *he
inner loop e2ecutes to increment the value from @ to <;F 'the positive range of char( and
then it rotates to the negative value of 6<;D. *he condition in the for loop fails and so
comes out of the for loop. #t prints the current value of i that is 6<;D.

<<B( main'(
]
unsigned char i>@X
for'XiQ>@Xi88( X
printf'NWdZnN,i(X
^
Answer
infinite loop
Explanation
*he difference between the previous ,uestion and this one is that the char is declared to be
unsigned. So the i88 can never yield negative value and iQ>@ never becomes false so that it can come
out of the for loop.
<<A( main'(
]
char i>@X
for'XiQ>@Xi88( X
printf'NWdZnN,i(X

^
A;
Answer:
%ehavior is implementation dependent.
Explanation:
*he detail if the char is signedLunsigned by default is implementation dependent. #f the
implementation treats the char to be signed by default the program will print &<;D and terminate.
On the other hand if it considers char to be unsigned by default, it goes to infinite loop.
Rule:
Hou can write programs that have implementation dependent behavior. %ut dont write
programs that depend on such behavior.
<<=( #s the following statement a declarationLdefinition. .ind what does it mean`
int '72(O<@PX
Answer
Definition.
2 is a pointer to array of'size <@( integers.
Apply clock6wise rule to find the meaning of this definition.
<<?(. Ehat is the output for the program given below
typedef enum error*ype]warning, error, e2ception,^errorX
main'(
]
error g<X
g<><X
printf'NWdN,g<(X
^
Answer
Compiler error4 ultiple declaration for error
Explanation
*he name error is used in the two meanings. One means that it is a enumerator constant
with value <. *he another use is that it is a type name 'due to typedef( for enum error*ype. "iven
a situation the compiler cannot distinguish the meaning of error to know in what sense the error
is used4
error g<X
g<>errorX
LL which error it refers in each case`
Ehen the compiler can distinguish between usages then it will not issue error 'in pure
technical terms, names can only be overloaded in different namespaces(.
Note4 the e2tra comma in the declaration,
enum error*ype]warning, error, e2ception,^
is not an error. An e2tra comma is valid and is provided :ust for programmer0s convenience.


<<F( typedef struct error]int warning, error, e2ceptionX^errorX
main'(
]
error g<X
g<.error ><X
printf'NWdN,g<.error(X
AB
^
Answer
<
Explanation
*he three usages of name errors can be distinguishable by the compiler at any instance, so valid
'they are in different namespaces(.
*ypedef struct error]int warning, error, e2ceptionX^errorX
*his error can be used only by preceding the error by struct kayword as in4
struct error some1rrorX
typedef struct error]int warning, error, e2ceptionX^errorX
*his can be used only after . 'dot( or 6Q 'arrow( operator preceded by the variable name as in 4
g<.error ><X
printf'NWdN,g<.error(X
typedef struct error]int warning, error, e2ceptionX^errorX
*his can be used to define variables without using the preceding struct keyword as in4
error g<X
Since the compiler can perfectly distinguish between these three usages, it is perfectly legal and valid.
)ote
*his code is given here to :ust e2plain the concept behind. #n real programming don0t use such
overloading of names. #t reduces the readability of the code. 3ossible doesn0t mean that we should use itS

<<D( Yifdef something
int some>@X
Yendif
main'(
]
int thing > @X
printf'NWd WdZnN, some ,thing(X
^
Answer:
Compiler error 4 undefined symbol some
Explanation:
*his is a very simple e2ample for conditional compilation. *he name something is not
already known to the compiler making the declaration
int some > @X
effectively removed from the source code.
<<J( Yif something >> @
int some>@X
Yendif
main'(
]
int thing > @X
printf'NWd WdZnN, some ,thing(X
^
AA
Answer
@ @
Explanation
*his code is to show that preprocessor e2pressions are not the same as the ordinary
e2pressions. #f a name is not known the preprocessor treats it to be e,ual to zero.
<;@(. Ehat is the output for the following program
main'(
]
int arr;DOBPOBPX
printf'NWdZnN, ''arr;D>>7 arr;D(UU'7 arr;D >> arr;DO@P(( (X
^
Answer
<
Explanation
*his is due to the close relation between the arrays and pointers. ! dimensional arrays are
made up of '!6<( dimensional arrays.
arr;D is made up of a B single arrays that contains B integers each .
*he name arr;D refers to the beginning of all the B arrays. 7arr;D refers to the start of the
first <D array 'of B integers( that is the same address as arr;D. So the e2pression 'arr;D
>> 7arr;D( is true '<(.
Similarly, 7arr;D is nothing but 7'arr;D 8 @(, adding a zero doesn0t change the
valueLmeaning. Again arr;DO@P is the another way of telling 7'arr;D 8 @(. So the
e2pression '7'arr;D 8 @( >> arr;DO@P( is true '<(.
Since both parts of the e2pression evaluates to true the result is true'<( and the same is
printed.
<;<( void main'(
]
if'a@ >> 'unsigned int(6<(
printf'[Hou can answer this if you know how values are represented in memory\(X
^
Answer
Hou can answer this if you know how values are represented in memory
12planation
a 'tilde operator or bit6wise negation operator( operates on @ to produce all ones to fill the
space for an integer. &< is represented in unsigned value as all <0s and so both are e,ual.
<;;( int swap'int 7a,int 7b(
]
7a>7a87bX7b>7a67bX7a>7a67bX
^
A=
arr;D
arr;DO<P
arr;DO;P
arr;DOBP
main'(
]
int 2><@,y>;@X
swap'U2,Uy(X
printf'N2> Wd y > WdZnN,2,y(X
^
Answer
2 > ;@ y > <@
12planation
*his is one way of swapping two values. Simple checking will help understand this.
<;B( main'(
]
char 7p > [ay,m\X
printf'[Wc\,887'p88((X
^
Answer4
b
<;A( main'(
]
int i>=X
printf'NWdN,88i88(X
^
Answer:
Compiler error4 -value re,uired in function main
Explanation:
88i yields an rvalue. .or postfi2 88 to operate an lvalue is re,uired.
<;=( main'(
]
char 7p > [ay,m\X
char cX
c > 887p88X
printf'[Wc\,c(X
^
Answer:
b
Explanation:
*here is no difference between the e2pression 887'p88( and 887p88. 3arenthesis :ust
works as a visual clue for the reader to see which e2pression is first evaluated.
<;?(
int aaa'( ]printf'[)i\(X^
int bbb'(]printf'[hello\(X^
iny ccc'(]printf'[bye\(X^
main'(
]
int ' 7 ptrOBP( '(X
ptrO@P > aaaX
A?
ptrO<P > bbbX
ptrO;P >cccX
ptrO;P'(X
^
Answer4
b'e
12planation4
int '7 ptrOBP('( says that ptr is an array of pointers to functions that takes no arguments and
returns the type int. %y the assignment ptrO@P > aaaX it means that the first function pointer in the
array is initialized with the address of the function aaa. Similarly, the other two array elements
also get initialized with the addresses of the functions bbb and ccc. Since ptrO;P contains the
address of the function ccc, the call to the function ptrO;P'( is same as calling ccc'(. So it results
in printing NbyeN.
<;F(
main'(
]
int i>=X
printf'[Wd\,i>88i >>?(X
^
Answer:
1
Explanation:
*he e2pression can be treated as i > '88i>>?(, because >> is of higher precedence than >
operator. #n the inner e2pression, 88i is e,ual to ? yielding true'<(. )ence the result.
<;D( main'(
]
char pO P>NWdZnNX
pO<P > TcTX
printf'p,?=(X
^
Answer:
A
Explanation:
Due to the assignment pO<P > /c0 the string becomes, [WcZn\. Since this string becomes the
format string for printf and ASC## value of ?= is /A0, the same gets printed.

<;J( void ' 7 abc' int, void ' 7def( '( ( ( '(X
Answer44
abc is a ptr to a function which takes ; parameters .'a(. an integer variable.'b(. a ptrto a
funtion which returns void. the return type of the function is void.
Explanation:
Apply the clock6wise rule to find the result.
<B@( main'(
]
while 'strcmp'[some\,\someZ@\((
AF
printf'[Strings are not e,ualZn\(X
^
Answer:
!o output
Explanation:
1nding the string constant with Z@ e2plicitly makes no difference. So [some\ and [someZ@\ are
e,uivalent. So, strcmp returns @ 'false( hence breaking out of the while loop.
<B<( main'(
]
char str<OP > ]/s0,0o0,0m0,0e0^X
char str;OP > ]/s0,0o0,0m0,0e0,0Z@0^X
while 'strcmp'str<,str;((
printf'[Strings are not e,ualZn\(X
^
Answer:
[Strings are not e,ual\
[Strings are not e,ual\
I.
Explanation:
#f a string constant is initialized e2plicitly with characters, /Z@0 is not appended automatically to
the string. Since str< doesn0t have null termination, it treats whatever the values that are in the
following positions as part of the string until it randomly reaches a /Z@0. So str< and str; are not
the same, hence the result.

<B;( main'(
]
int i > BX
for 'Xi88>@X( printf'[Wd\,i(X
^
Answer:
Compiler 1rror4 -value re,uired.
Explanation:
As we know that increment operators return rvalues and hence it cannot appear on the
left hand side of an assignment operation.

<BB( void main'(
]
int 7mptr, 7cptrX
mptr > 'int7(malloc'sizeof'int((X
printf'[Wd\,7mptr(X
int 7cptr > 'int7(calloc'sizeof'int(,<(X
printf'[Wd\,7cptr(X
^
Answer:
garbage6value @
Explanation:
*he memory space allocated by malloc is uninitialized, whereas calloc returns the allocated
memory space initialized to zeros.
AD
<BA( void main'(
]
static int iX
while'iR><@(
'iQ;(`i884i66X
printf'[Wd\, i(X
^
Answer:
B;F?F
Explanation:
Since i is static it is initialized to @. #nside the while loop the conditional operator evaluates to
false, e2ecuting i66. *his continues till the integer value rotates to positive value 'B;F?F(. *he
while condition becomes false and hence, comes out of the while loop, printing the i value.
<B=( main'(
]
int i><@,:>;@X
: > i, :`'i,:(`i4:4:X
printf'NWd WdN,i,:(X
^
Answer:
<@ <@
Explanation:
*he *ernary operator ' ` 4 ( is e,uivalent for if6then6else statement. So the ,uestion can be
written as4
if'i,:(
]
if'i,:(
: > iX
else
: > :X
^
else
: > :X
<B?( <. const char 7aX
;. char7 const aX
B. char const 7aX
6Differentiate the above declarations.
Answer:
<. TconstT applies to char 7 rather than TaT ' pointer to a constant char (
7a>T.T 4 illegal
a>N)iN 4 legal
;. TconstT applies to TaT rather than to the value of a 'constant pointer to char (
7a>T.T 4 legal
a>N)iN 4 illegal
AJ
B. Same as <.
<BF( main'(
]
int i>=,:><@X
i>iU>:UU<@X
printf'NWd WdN,i,:(X
^
Answer:
< <@
Explanation:
*he e2pression can be written as i>'iU>':UU<@((X *he inner e2pression ':UU<@( evaluates to <
because :>><@. i is =. i > =U< is <. )ence the result.
<BD( main'(
]
int i>A,:>FX
: > : VV i88 UU printf'NHO9 CA!N(X
printf'NWd WdN, i, :(X
^
Answer:
A <
Explanation:
Dhe .oolean expression needs to .e evaluated only till the truth value of the expression is not
'nown. : is not e,ual to zero itself means that the e2pression0s truth value is <. %ecause it is
followed by VV and true SS 2anything4 IV true where 2anything4 will not .e evaluated. So the
remaining e2pression is not evaluated and so the value of i remains the same.
Similarly when UU operator is involved in an e2pression, when any of the operands become
false, the whole e2pression0s truth value becomes false and hence the remaining e2pression will
not be evaluated.
false (( 2anything4 IV false where 2anything4 will not .e evaluated.
<BJ( main'(
]
register int a>;X
printf'NAddress of a > WdN,Ua(X
printf'N+alue of a > WdN,a(X
^
Answer:
Compier 1rror4 TUT on register variable
"ule to "ee!er:
& #a$$ress o% & operator 'annot !e applie$ on re(ister )aria!les*
<A@( main'(
]
float i><.=X
switch'i(
]
case <4 printf'N<N(X
=@
case ;4 printf'N;N(X
default 4 printf'N@N(X
^
^
Answer:
Compiler 1rror4 switch e2pression not integral
Explanation:
$witch statements can .e applied only to integral types.
<A<( main'(
]
e2tern iX
printf'NWdZnN,i(X
]
int i>;@X
printf'NWdZnN,i(X
^
^
Answer:
-inker 1rror 4 9nresolved e2ternal symbol i
Explanation:
*he identifier i is available in the inner block and so using e2tern has no use in resolving it.
<A;( main'(
]
int a>;,7f<,7f;X
f<>f;>UaX
7f;8>7f;8>a8>;.=X
printf'NZnWd Wd WdN,a,7f<,7f;(X
^
Answer:
<? <? <?
Explanation:
f< and f; both refer to the same memory location a. So changes through f< and f; ultimately
affects only the value of a.
<AB( main'(
]
char 7p>N"OODNX
char aO P>N"OODNX
printf'NZn sizeof'p( > Wd, sizeof'7p( > Wd, strlen'p( > WdN, sizeof'p(, sizeof'7p(, strlen'p((X
printf'NZn sizeof'a( > Wd, strlen'a( > WdN, sizeof'a(, strlen'a((X
^
Answer:
sizeof'p( > ;, sizeof'7p( > <, strlen'p( > A
sizeof'a( > =, strlen'a( > A
Explanation:
sizeof'p( >Q sizeof'char7( >Q ;
sizeof'7p( >Q sizeof'char( >Q <
Similarly,
sizeof'a( >Q size of the character array >Q =
=<
When siCeof operator is applied to an array it returns the siCeof the array and it is not the same
as the sizeof the pointer variable. )ere the sizeof'a( where a is the character array and the size of
the array is = because the space necessary for the terminating !9-- character should also be
taken into account.
<AA( Ydefine D#' array, type( sizeof'array(Lsizeof'type(
main'(
]
int arrO<@PX
printf'[*he dimension of the array is Wd\, D#'arr, int((X
^
Answer:
<@
Explanation:
*he size of integer array of <@ elements is <@ 7 sizeof'int(. *he macro e2pands to
sizeof'arr(Lsizeof'int( >Q <@ 7 sizeof'int( L sizeof'int( >Q <@.
<A=( int D#'int arrayOP(
]
return sizeof'array(Lsizeof'int (X
^
main'(
]
int arrO<@PX
printf'[*he dimension of the array is Wd\, D#'arr((X
^
Answer:
<
Explanation:
6rrays cannot .e passed to functions as arguments and only the pointers can .e passed. So the
argument is e,uivalent to int 7 array 'this is one of the very few places where OP and 7 usage are
e,uivalent(. *he return statement becomes, sizeof'int 7(L sizeof'int( that happens to be e,ual in
this case.
<A?( main'(
]
static int aOBPOBP>]<,;,B,A,=,?,F,D,J^X
int i,:X
static 7pOP>]a,a8<,a8;^X
for'i>@XiRBXi88(
]
for':>@X:RBX:88(
printf'NWdZtWdZtWdZtWdZnN,7'7'p8i(8:(,
7'7':8p(8i(,7'7'i8p(8:(,7'7'p8:(8i((X
^
^
Answer:
< < < <
; A ; A
B F B F
A ; A ;
=;
= = = =
? D ? D
F B F B
D ? D ?
J J J J
Explanation:
7'7'p8i(8:( is e,uivalent to pOiPO:P.
<AF( main'(
]
void swap'(X
int 2><@,y>DX
swap'U2,Uy(X
printf'N2>Wd y>WdN,2,y(X
^
void swap'int 7a, int 7b(
]
7a 5> 7b, 7b 5> 7a, 7a 5> 7bX
^
Answer:
2><@ y>D
Explanation:
9sing 5 like this is a way to swap two variables without using a temporary variable and that too
in a single statement.
#nside main'(, void swap'(X means that swap is a function that may take any number of
arguments 'not no arguments( and returns nothing. So this doesn0t issue a compiler error by the
call swap'U2,Uy(X that has two arguments.
*his convention is historically due to pre6A!S# style 'referred to as _ernighan and $itchie style(
style of function declaration. #n that style, the swap function will be defined as follows,
void swap'(
int 7a, int 7b
]
7a 5> 7b, 7b 5> 7a, 7a 5> 7bX
^
where the arguments follow the '(. So naturally the declaration for swap will look like, void
swap'( which means the swap can take any number of arguments.
<AD( main'(
]
int i > ;=FX
int 7i3tr > UiX
printf'NWd WdN, 7''char7(i3tr(, 7''char7(i3tr8<( (X
^
Answer:
< <
Explanation:
*he integer value ;=F is stored in the memory as, @@@@@@@< @@@@@@@<, so the individual bytes
are taken by casting it to char 7 and get printed.
<AJ( main'(
]
=B
int i > ;=DX
int 7i3tr > UiX
printf'NWd WdN, 7''char7(i3tr(, 7''char7(i3tr8<( (X
^
Answer:
; <
Explanation:
*he integer value ;=F can be represented in binary as, @@@@@@@< @@@@@@@<. $emember that the
#!*1- machines are /small6endian0 machines. $mall3endian means that the lower order .ytes
are stored in the higher memory addresses and the higher order .ytes are stored in lower
addresses. *he integer value ;=D is stored in memory as4 @@@@@@@< @@@@@@<@.
<=@( main'(
]
int i>B@@X
char 7ptr > UiX
788ptr>;X
printf'NWdN,i(X
^
Answer:
==?
Explanation:
*he integer value B@@ in binary notation is4 @@@@@@@< @@<@<<@@. #t is stored in memory 'small6
endian( as4 @@<@<<@@ @@@@@@@<. $esult of the e2pression 788ptr > ; makes the memory
representation as4 @@<@<<@@ @@@@@@<@. So the integer corresponding to it is @@@@@@<@
@@<@<<@@ >Q ==?.
<=<( Yinclude Rstdio.hQ
main'(
]
char 7 str > NhelloNX
char 7 ptr > strX
char least > <;FX
while '7ptr88(
least > '7ptrRleast ( `7ptr 4leastX
printf'NWdN,least(X
^
Answer:
@
Explanation:
After /ptr0 reaches the end of the string the value pointed by /str0 is /Z@0. So the value of /str0 is
less than that of /least0. So the value of /least0 finally is @.
<=;( Declare an array of ! pointers to functions returning pointers to functions returning pointers to
characters`
Answer:
'char7'7(' (( '7ptrO!P(' (X
<=B( main'(
]
struct student
=A
]
char nameOB@PX
struct date dobX
^studX
struct date
]
int day,month,yearX
^X
scanf'NWsWdWdWdN, stud.rollno, Ustudent.dob.day, Ustudent.dob.month,
Ustudent.dob.year(X
^
Answer:
Compiler 1rror4 9ndefined structure date
Explanation:
#nside the struct definition of /student0 the member of type struct date is given. *he compiler
doesn0t have the definition of date structure 'forward reference is not allowed in C in this case(
so it issues an error.
<=A( main'(
]
struct dateX
struct student
]
char nameOB@PX
struct date dobX
^studX
struct date
]
int day,month,yearX
^X
scanf'NWsWdWdWdN, stud.rollno, Ustudent.dob.day, Ustudent.dob.month, Ustudent.dob.year(X
^
Answer:
Compiler 1rror4 9ndefined structure date
Explanation:
Only declaration of struct date is available inside the structure definition of /student0 but to have
a variable of type struct date the definition of the structure is re,uired.
<==( *here were <@ records stored in [somefile.dat\ but the following program printed << names. Ehat went
wrong`
void main'(
]
struct student
]
char nameOB@P, rollnoO?PX
^studX
.#-1 7fp > fopen'[somefile.dat\,\r\(X
while'Sfeof'fp((
]
fread'Ustud, sizeof'stud(, < , fp(X
puts'stud.name(X
==
^
^
Explanation:
fread reads <@ records and prints the names successfully. #t will return 1O. only when
fread tries to read another record and fails reading 1O. 'and returning 1O.(. So it prints
the last record again. After this only the condition feof'fp( becomes false, hence comes
out of the while loop.
<=?( #s there any difference between the two declarations,
<. int foo'int 7arrOP( and
;. int foo'int 7arrO;P(
Answer:
!o
Explanation:
.unctions can only pass pointers and not arrays. *he numbers that are allowed inside the OP is :ust
for more readability. So there is no difference between the two declarations.
<=F( Ehat is the subtle error in the following code segment`
void fun'int n, int arrOP(
]
int 7p>@X
int i>@X
while'i88Rn(
p > UarrOiPX
7p > @X
^
Answer & Explanation:
#f the body of the loop never e2ecutes p is assigned no address. So p remains !9--
where 7p >@ may result in problem 'may rise to runtime error [!9-- pointer
assignment\ and terminate the program(.
<=D( Ehat is wrong with the following code`
int 7foo'(
]
int 7s > malloc'sizeof'int(<@@(X
assert's S> !9--(X
return sX
^
Answer & Explanation:
assert macro should be used for debugging and finding out bugs. *he check s S> !9-- is for
errorLe2ception handling and for that assert shouldn0t be used. A plain if and the corresponding
remedy statement has to be given.
<=J( Ehat is the hidden bug with the following statement`
assert'val88 S> @(X
Answer & Explanation:
Assert macro is used for debugging and removed in release version. #n assert, the e2perssion
involves side6effects. So the behavior of the code becomes different in case of debug version and
the release version thus leading to a subtle bug.
"ule to "ee!er:
=?
!onFt use expressions that have side3effects in assert statements.
<?@( void main'(
]
int 7i > @2A@@X LL i points to the address A@@
7i > @X LL set the value of memory location pointed by iX
^
Answer:
9ndefined behavior
Explanation:
*he second statement results in undefined behavior because it points to some location whose
value may not be available for modification. Dhis type of pointer in which the non3availa.ility of
the implementation of the referenced location is 'nown as Wincomplete typeW.
<?<( Ydefine assert'cond( if'S'cond(( Z
'fprintf'stderr, Nassertion failed4 Ws, file Ws, line Wd ZnN,Ycond,Z
KK.#-1KK,KK-#!1KK(, abort'((
void main'(
]
int i > <@X
if'i>>@(
assert'i R <@@(X
else
printf'N*his statement becomes else for if in assert macroN(X
^
Answer4
!o output
Explanation:
*he else part in which the printf is there becomes the else for if in the assert macro. )ence nothing is
printed.
*he solution is to use conditional operator instead of if statement,
Ydefine assert'cond( ''cond(`'@(4 'fprintf 'stderr, Nassertion failed4 Z Ws, file Ws, line Wd ZnN,Ycond,
KK.#-1KK,KK-#!1KK(, abort'(((
!ote4
)owever this problem of [matching with nearest else\ cannot be solved by the usual method of
placing the if statement inside a block like this,
Ydefine assert'cond( ] Z
if'S'cond(( Z
'fprintf'stderr, Nassertion failed4 Ws, file Ws, line Wd ZnN,Ycond,Z
KK.#-1KK,KK-#!1KK(, abort'(( Z
^
<?;( #s the following code legal`
struct a
]
int 2X
struct a bX
^
Answer4
=F
!o
Explanation:
#s it not legal for a structure to contain a member that is of the same
type as in this case. %ecause this will cause the structure declaration to be recursive without end.
<?B( #s the following code legal`
struct a
]
int 2X
struct a 7bX
^
Answer:
Hes.
Explanation:
7b is a pointer to type struct a and so is legal. *he compiler knows, the size of the pointer to a
structure even before the size of the structure
is determined'as you know the pointer to any type is of same size(. *his type of structures is
known as /self6referencing0 structure.
<?A( #s the following code legal`
typedef struct a
]
int 2X
a*ype 7bX
^a*ype
Answer:
!o
Explanation:
*he typename a*ype is not known at the point of declaring the structure 'forward references are
not made for typedefs(.
<?=( #s the following code legal`
typedef struct a a*ypeX
struct a
]
int 2X
a*ype 7bX
^X
Answer:
Hes
Explanation:
*he typename a*ype is known at the point of declaring the structure, because it is already
typedefined.
<??( #s the following code legal`
void main'(
]
typedef struct a a*ypeX
a*ype some+ariableX
struct a
]
=D
int 2X
a*ype 7bX
^X
^
Answer:
!o
Explanation:
Ehen the declaration,
typedef struct a a*ypeX
is encountered body of struct a is not known. *his is known as /incomplete types0.

<?F( void main'(
]
printf'[sizeof 'void 7( > Wd Zn[, sizeof' void 7((X
printf'[sizeof 'int 7( > Wd Zn\, sizeof'int 7((X
printf'[sizeof 'double 7( > Wd Zn\, sizeof'double 7((X
printf'[sizeof'struct unknown 7( > Wd Zn\, sizeof'struct unknown 7((X
^
Answer :
sizeof 'void 7( > ;
sizeof 'int 7( > ;
sizeof 'double 7( > ;
sizeof'struct unknown 7( > ;
Explanation:
*he pointer to any type is of same size.
<?D( char inputStringO<@@P > ]@^X
*o get string input from the keyboard which one of the following is better`
<( gets'inputString(
;( fgets'inputString, sizeof'inputString(, fp(
Answer & Explanation:
*he second one is better because gets'inputString( doesnTt know the size of the string passed and
so, if a very big input 'here, more than <@@ chars( the charactes will be written past the input
string. Ehen fgets is used with stdin performs the same operation as gets but is safe.
<?J( Ehich version do you prefer of the following two,
<( printf'[Ws\,str(X LL or the more curt one
;( printf'str(X
Answer & Explanation:
3refer the first one. #f the str contains any format characters like Wd then it will result in a subtle
bug.
<F@( void main'(
]
int i><@, :>;X
int 7ip> Ui, 7:p > U:X
int k > 7ipL7:pX
printf'[Wd\,k(X
^
Answer:
Compiler 1rror4 [9ne2pected end of file in comment started in line =\.
=J
Explanation:
*he programmer intended to divide two integers, but by the [ma2imum munch\ rule, the
compiler treats the operator se,uence L and 7 as L7 which happens to be the starting of
comment. *o force what is intended by the programmer,
int k > 7ipL 7:pX
LL give space e2plicity separating L and 7
LLor
int k > 7ipL'7:p(X
LL put braces to force the intention
will solve the problem.
<F<( void main'(
]
char chX
for'ch>@XchR><;FXch88(
printf'[Wc Wd Zn[, ch, ch(X
^
Answer:
#mplementaion dependent
Explanation:
*he char type may be signed or unsigned by default. #f it is signed then ch88 is e2ecuted after ch
reaches <;F and rotates back to 6<;D. *hus ch is always smaller than <;F.
<F;( #s this code legal`
int 7ptrX
ptr > 'int 7( @2A@@X
Answer:
Hes
Explanation:
*he pointer ptr will point at the integer in the memory location @2A@@.
<FB( main'(
]
char aOAP>N)1--ONX
printf'NWsN,a(X
^
Answer:
Compiler error4 *oo many initializers
Explanation:
*he array a is of size A but the string constant re,uires ? bytes to get stored.
<FA( main'(
]
char aOAP>N)1--NX
printf'NWsN,a(X
^
Answer:
)1--WbSabSb```baaS
Explanation:
?@
*he character array has the memory :ust enough to hold the string [)1--\ and doesnt have
enough space to store the terminating null character. So it prints the )1-- correctly and
continues to print garbage values till it accidentally comes across a !9-- character.
<F=( main'(
]
int a><@,7:X
void 7kX
:>k>UaX
:88X
k88X
printf'NZn Wu Wu N,:,k(X
^
Answer:
Compiler error4 Cannot increment a void pointer
Explanation:
+oid pointers are generic pointers and they can be used only when the type is not known and as
an intermediate address storage type. !o pointer arithmetic can be done on it and you cannot
apply indirection operator '7( on void pointers.
<F?( main'(
]
e2tern int iX
] int i>;@X
]
const volatile unsigned i>B@X printf'NWdN,i(X
^
printf'NWdN,i(X
^
printf'NWdN,i(X
^
int iX
<FF( 3rintf can be implemented by using KKKKKKKKKK list.
Answer:
+ariable length argument lists
<FD( char 7some.un'(
]
char 7temp > [string constantNX
return tempX
^
int main'(
]
puts'some.un'((X
^
Answer4
string constant
Explanation4
*he program suffers no problem and gives the output correctly because the character constants are
stored in codeLdata area and not allocated in stack, so this doesn0t lead to dangling pointers.
?<
<FJ( char 7some.un<'(
]
char tempO P > [stringNX
return tempX
^
char 7some.un;'(
]
char tempO P > ]/s0, /t0,0r0,0i0,0n0,0g0^X
return tempX
^
int main'(
]
puts'some.un<'((X
puts'some.un;'((X
^
Answer4
"arbage values.
Explanation4
%oth the functions suffer from the problem of dangling pointers. #n some.un<'( temp is a character array
and so the space for it is allocated in heap and is initialized with character string [string\. *his is created
dynamically as the function is called, so is also deleted dynamically on e2iting the function so the string data is
not available in the calling function main'( leading to print some garbage values. *he function some.un;'( also
suffers from the same problem but the problem can be easily identified in this case.
?;
C88 Aptitude and OO3S
!ote 4 All the programs are tested under *urbo C88 B.@, A.= and icrosoft +C88 ?.@ compilers.
#t is assumed that,
3rograms run under Eindows environment,
*he underlying machine is an 2D? based system,
3rogram is compiled using *urbo CLC88 compiler.
*he program output may depend on the information based on this assumptions 'for e2ample sizeof'int(
>> ; may be assumed(.
<( class Sample
]
public4
int 7ptrX
Sample'int i(
]
ptr > new int'i(X
^
aSample'(
]
delete ptrX
^
void 3rint+al'(
]
cout RR N*he value is N RR 7ptrX
^
^X
void Some.unc'Sample 2(
]
cout RR NSay i am in some.unc N RR endlX
^
int main'(
]
Sample s<> <@X
Some.unc's<(X
s<.3rint+al'(X
^
Answer:
Say i am in some.unc
!ull pointer assignment'$un6time error(
Explanation4
?B
C++ Aptitude
and OOPS

As the ob:ect is passed by value to Some.unc the destructor of the ob:ect is called when the control
returns from the function. So when 3rint+al is called it meets up with ptr that has been freed.*he solution is to
pass the Sample ob:ect by reference to Some.unc4
void Some.unc'Sample U2(
]
cout RR NSay i am in some.unc N RR endlX
^
because when we pass ob:ects by refernece that ob:ect is not destroyed. while returning from the function.
;( Ehich is the parameter that is added to every non6static member function when it is called`
Answer:
/this0 pointer
B( class base
]
public4
int bvalX
base'(] bval>@X^
^X
class deri4public base
]
public4
int dvalX
deri'(] dval><X^
^X
void Some.unc'base 7arr,int size(
]
for'int i>@X iRsizeX i88,arr88(
coutRRarr6QbvalX
coutRRendlX
^
int main'(
]
base %aseArrO=PX
Some.unc'%aseArr,=(X
deri DeriArrO=PX
Some.unc'DeriArr,=(X
^
Answer:
@@@@@
@<@<@
Explanation:
*he function Some.unc e2pects two arguments.*he first one is a pointer to an array of base class
ob:ects and the second one is the sizeof the array.*he first call of some.unc calls it with an array of bae ob:ects,
so it works correctly and prints the bval of all the ob:ects. Ehen Somefunc is called the second time the
argument passed is the pointeer to an array of derived class ob:ects and not the array of base class ob:ects. %ut
that is what the function e2pects to be sent. So the derived class pointer is promoted to base class pointer and
?A
the address is sent to the function. Some.unc'( knows nothing about this and :ust treats the pointer as an array
of base class ob:ects. So when arr88 is met, the size of base class ob:ect is taken into consideration and is
incremented by sizeof'int( bytes for bval 'the deri class ob:ects have bval and dval as members and so is of size
Q> sizeof'int(8sizeof'int( (.
A( class base
]
public4
void base.un'(] coutRRNfrom baseNRRendlX^
^X
class deri4public base
]
public4
void base.un'(] coutRR Nfrom derivedNRRendlX^
^X
void Some.unc'base 7baseOb:(
]
baseOb:6Qbase.un'(X
^
int main'(
]
base baseOb:ectX
Some.unc'UbaseOb:ect(X
deri deriOb:ectX
Some.unc'UderiOb:ect(X
^
Answer:
from base
from base
Explanation:
As we have seen in the previous case, Some.unc e2pects a pointer to a base class. Since a pointer to a
derived class ob:ect is passed, it treats the argument only as a base class pointer and the corresponding base
function is called.
=( class base
]
public4
virtual void base.un'(] coutRRNfrom baseNRRendlX^
^X
class deri4public base
]
public4
void base.un'(] coutRR Nfrom derivedNRRendlX^
^X
void Some.unc'base 7baseOb:(
]
baseOb:6Qbase.un'(X
^
int main'(
]
base baseOb:ectX
?=
Some.unc'UbaseOb:ect(X
deri deriOb:ectX
Some.unc'UderiOb:ect(X
^
Answer:
from base
from derived
Explanation:
$emember that base.unc is a virtual function. *hat means that it supports run6time polymorphism. So
the function corresponding to the derived class ob:ect is called.
void main'(
]
int a, 7pa, UraX
pa > UaX
ra > aX
cout RRNa>NRRa RRN7pa>NRR7pa RRNraNRRra X
^
L7
Answer 4
Compiler 1rror4 TraT,reference must be initialized
12planation 4
3ointers are different from references. One of the main
differences is that the pointers can be both initialized and assigned,
whereas references can only be initialized. So this code issues an error.
7L
const int size > =X
void print'int 7ptr(
]
coutRRptrO@PX
^
void print'int ptrOsizeP(
]
coutRRptrO@PX
^
void main'(
]
int aOsizeP > ]<,;,B,A,=^X
int 7b > new int'size(X
print'a(X
print'b(X
^
L7
Answer4
Compiler 1rror 4 function Tvoid print'int 7(T already has a body
12planation4
??
Arrays cannot be passed to functions, only pointers 'for arrays, base addresses(
can be passed. So the arguments int 7ptr and int prtOsizeP have no difference
as function arguments. #n other words, both the functoins have the same signature and
so cannot be overloaded.
7L
class some]
public4
asome'(
]
coutRRNsomeTs destructorNRRendlX
^
^X
void main'(
]
some sX
s.asome'(X
^
L7
Answer4
someTs destructor
someTs destructor
12planation4
Destructors can be called e2plicitly. )ere Ts.asome'(T e2plicitly calls the
destructor of TsT. Ehen main'( returns, destructor of s is called again,
hence the result.
7L
Yinclude Riostream.hQ
class fig;d
]
int dim<X
int dim;X
public4
fig;d'( ] dim<>=X dim;>?X^
virtual void operatorRR'ostream U rhs(X
^X
void fig;d44operatorRR'ostream Urhs(
]
rhs RRthis6Qdim<RRN NRRthis6Qdim;RRN NX
^
L7class figBd 4 public fig;d
]
int dimBX
public4
?F
figBd'( ] dimB>FX^
virtual void operatorRR'ostream Urhs(X
^X
void figBd44operatorRR'ostream Urhs(
]
fig;d44operator RR'rhs(X
rhsRRthis6QdimBX
^
7L
void main'(
]
fig;d ob:<X
LL figBd ob:;X
ob:< RR coutX
LL ob:; RR coutX
^
L7
Answer 4
= ?
12planation4
#n this program, the RR operator is overloaded with ostream as argument.
*his enables the TcoutT to be present at the right6hand6side. !ormally, TcoutT
is implemented as global function, but it doesnTt mean that TcoutT is not possible
to be overloaded as member function.
Overloading RR as virtual member function becomes handy when the class in which
it is overloaded is inherited, and this becomes available to be overrided. *his is as opposed
to global friend functions, where friendTs are not inherited.
7L
class opOverload]
public4
bool operator>>'opOverload temp(X
^X
bool opOverload44operator>>'opOverload temp(]
if'7this >> temp (]
coutRRN*he both are same ob:ectsZnNX
return trueX
^
else]
coutRRN*he both are differentZnNX
return falseX
^
^
void main'(]
opOverload a<, a;X
a<> >a;X
^
?D
Answer 4
$untime 1rror4 Stack Overflow
12planation 4
Cust like normal functions, operator functions can be called recursively. *his program :ust illustrates that
point, by calling the operator >> function recursively, leading to an infinite loop.
class comple2]
double reX
double imX
public4
comple2'( 4 re'<(,im'@.=( ]^
bool operator>>'comple2 Urhs(X
operator int'(]^
^X
bool comple244operator >> 'comple2 Urhs(]
if''this6Qre >> rhs.re( UU 'this6Qim >> rhs.im((
return trueX
else
return falseX
^
int main'(]
comple2 c<X
coutRR c<X
^
Answer 4 "arbage value
12planation4
*he programmer wishes to print the comple2 ob:ect using output
re6direction operator,which he has not defined for his lass.%ut the compiler instead of giving an error sees the
conversion function
and converts the user defined ob:ect to standard ob:ect and prints
some garbage value.
class comple2]
double reX
double imX
public4
comple2'( 4 re'@(,im'@( ]^
comple2'double n( ] re>n,im>nX^X
comple2'int m,int n( ] re>m,im>nX^
void print'( ] coutRRreX coutRRimX^
^X
void main'(]
comple2 cBX
?J
double i>=X
cB > iX
cB.print'(X
^
Answer4
=,=
12planation4
*hough no operator> function taking comple2, double is defined, the double on the rhs is converted into
a temporary ob:ect using the single argument constructor taking double and assigned to the lvalue.
void main'(
]
int a, 7pa, UraX
pa > UaX
ra > aX
cout RRNa>NRRa RRN7pa>NRR7pa RRNraNRRra X
^
Answer 4
Compiler 1rror4 TraT,reference must be initialized
12planation 4
3ointers are different from references. One of the main
differences is that the pointers can be both initialized and assigned,
whereas references can only be initialized. So this code issues an error.
Tr+ it ,oursel%
<( Determine the output of the TC88T Codelet.
class base
]
public 4
out'(
]
coutRRNbase NX
^
^X
class deri]
public 4 out'(
]
coutRRNderi NX
^
^X
void main'(
] deri dpOBPX
base 7bp > 'base7(dpX
for 'int i>@X iRBXi88(
'bp88(6Qout'(X
^
F@
;( Custify the use of virtual constructors and destructors in C88.
B( 1ach C88 ob:ect possesses the A member fns,'which can be declared by the programmer e2plicitly or by the
implementation if they are not available(. Ehat are those A functions`
A( Ehat is wrong with this class declaration`
class something
]
char 7strX
public4
something'(]
st > new charO<@PX ^
asomething'(
]
delete strX
^
^X
=( #nheritance is also known as 66666666 relationship. Containership as KKKKKKKK relationship.
?( Ehen is it necessary to use member6wise initialization list 'also known as header initialization list( in C88`
F( Ehich is the only operator in C88 which can be overloaded but !O* inherited.
D( #s there anything wrong with this C88 class declaration`
class temp
]
int value<X
mutable int value;X
public 4
void fun'int val(
const]
''temp7( this(6Qvalue< > <@X
value; > <@X
^
^X
F<
1. What is a modifier?
Answer:
A modifier, also called a modifying function is a member function that changes the value of at least one
data member. #n other words, an operation that modifies the state of an ob:ect. odifiers are also known as
/mutators0.
2. What is an accessor?
Answer:
An accessor is a class operation that does not modify the state of an ob:ect. *he accessor functions need
to be declared as const operations
3. !ifferentiate .etween a template class and class template.
Answer:
Teplate 'lass:
A generic definition or a parameterized class not instantiated until the client provides the needed
information. #t0s :argon for plain templates.
-lass teplate:
A class template specifies how individual classes can be constructed much like the way a class specifies
how individual ob:ects can be constructed. #t0s :argon for plain classes.
*. When does a name clash occur?
Answer:
A name clash occurs when a name is defined in more than one place. .or e2ample., two different class
libraries could give two different classes the same name. #f you try to use many class libraries at the same time,
there is a fair chance that you will be unable to compile or link the program because of name clashes.
-. !efine namespace.
Answer:
#t is a feature in c88 to minimize name collisions in the global name space. *his namespace keyword
assigns a distinct name to a library that allows other libraries to use the same identifier names without creating
any name collisions. .urthermore, the compiler uses the namespace signature for differentiating the definitions.
0. What is the use of XusingF declaration.
Answer:
A using declaration makes it possible to use a name from a namespace without the scope operator.
5. What is an +terator class?
Answer:
A class that is used to traverse through the ob:ects maintained by a container class. *here are five
categories of iterators4
input iterators,
output iterators,
forward iterators,
bidirectional iterators,
random 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 one6at6a6time basis in order. *he order can be
storage order 'as in lists and ,ueues( or some arbitrary order 'as in array indices( or according to some ordering
relation 'as in an ordered binary tree(. *he iterator is a construct, which provides an interface that, when called,
yields either the ne2t element in the container, or some value denoting the fact that there are no more elements
to e2amine. #terators hide the details of access to and update of the elements of a container class.
F;
*he simplest and safest iterators are those that permit read6only access to the contents of a container
class. *he following code fragment shows how an iterator might appear in code4
contKiter4>new contKiterator'(X
24>contKiter.ne2t'(X
while 2L>none do
...
s'2(X
...
24>contKiter.ne2t'(X
endX
#n this e2ample, contKiter is the name of the iterator. #t is created on the first line by instantiation of
contKiterator class, an iterator class defined to iterate over some container class, cont. Succesive elements from
the container are carried to 2. *he loop terminates when 2 is bound to some empty value. ')ere, none(#n the
middle of the loop, there is s'2( an operation on 2, the current element from the container. *he ne2t element of
the container is obtained at the bottom of the loop.
?. List out some of the EE!"#$ availa.le.
Answer:
"1S*O!1LO3A- of "emstone systems.
O!*OS of Ontos.
Ob:ectivity of Ob:ectivity inc.
+ersant of +ersant ob:ect technology.
Ob:ect store of Ob:ect Design.
A$D1!* of A$D1!* software.
3O1* of 3O1* software.
1@. List out some of the o.ject3oriented methodologies.
Answer:
Ob:ect Oriented Development 'OOD( '%ooch <JJ<,<JJA(.
Ob:ect Oriented Analysis and Design 'OOALD( 'Coad and Hourdon <JJ<(.
Ob:ect odelling *echni,ues 'O*( '$umbaugh <JJ<(.
Ob:ect Oriented Software 1ngineering 'Ob:ectory( 'Cacobson <JJ;(.
Ob:ect Oriented Analysis 'OOA( 'Shlaer and ellor <JJ;(.
*he .usion ethod 'Coleman <JJ<(.
11. What is an incomplete type?
Answer:
#ncomplete types refers to pointers in which there is non availability of the implementation of the
referenced location or it points to some location whose value is not available for modification.
Exaple:
int 7i>@2A@@ LL i points to address A@@
7i>@X LLset the value of memory location pointed by i.
#ncomplete types are otherwise called uninitialized pointers.
12. What is a dangling pointer?
Answer:
A dangling pointer arises when you use the address of an ob:ect after its lifetime is over.
*his may occur in situations like returning addresses of the automatic variables from a function or using the
address of the memory block after it is freed.
FB
13. !ifferentiate .etween the message and method.
Answer:
.essa(e .etho$
Ob:ects communicate by sending messages 3rovides response to a message.
to each other.
A message is sent to invoke a method. #t is an implementation of an operation.
1*. What is an adaptor class or Wrapper class?
Answer:
A class that has no functionality of its own. #ts member functions hide the use of a third party software
component or an ob:ect with the non6compatible interface or a non6 ob:ect6 oriented implementation.
1-. What is a &ull o.ject?
Answer:
#t is an ob:ect of some class whose purpose is to indicate that a real ob:ect of that class does not e2ist.
One common use for a null ob:ect is a return value from a member function that is supposed to return an ob:ect
with some specified properties but cannot find such an ob:ect.
10. What is class invariant?
Answer:
A class invariant is a condition that defines all valid states for an ob:ect. #t is a logical condition to
ensure the correct working of a class. Class invariants must hold when an ob:ect is created, and they must be
preserved under all operations of the class. #n particular all class invariants are both preconditions and post6
conditions for all operations or member functions of the class.
15. What do you mean .y $tac' unwinding?
Answer:
#t is a process during e2ception handling when the destructor is called for all local ob:ects between the
place where the e2ception was thrown and where it is caught.

17. !efine precondition and post3condition to a mem.er function.
Answer:
/re'on$ition:
A precondition is a condition that must be true on entry to a member 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.
.or e2ample, the interface invariants of stac' class say nothing about pushing yet another element on a
stack that is already full. Ee say that isful24 is a precondition of the push operation.
/ost-'on$ition:
A post6condition is a condition that must be true on e2it from a member function if the precondition was
valid on entry to that function. A class is implemented correctly if post6conditions are never false.
.or e2ample, after pushing an element on the stack, we know that isempty24 must necessarily hold. *his
is a post6condition of the push operation.
1?. What are the conditions that have to .e met for a condition to .e an invariant of the class?
Answer:
*he condition should hold at the end of every constructor.
*he condition should hold at the end of every mutator'non6const( operation.

2@. What are proxy o.jects?
FA
Answer:
Ob:ects that stand for other ob:ects are called pro2y ob:ects or surrogates.
Exaple:
templateRclass *Q
class Array;D
]
public4
class Array<D
]
public4
*U operatorOP 'int inde2(X
const *U operatorOP 'int inde2( constX
...
^X
Array<D operatorOP 'int inde2(X
const Array<D operatorOP 'int inde2( constX
...
^X

*he following then becomes legal4
Array;DRfloatQdata'<@,;@(X
........
coutRRdataOBPO?PX LL fine
)ere dataOBP yields an Array<D ob:ect and the operator OP invocation on that ob:ect yields the float in
position'B,?( of the original two dimensional array. Clients of the Array;D class need not be aware of the
presence of the Array<D class. Ob:ects of this latter class stand for one6dimensional array ob:ects that,
conceptually, do not e2ist for clients of Array;D. Such clients program as if they were using real, live, two6
dimensional arrays. 1ach Array<D ob:ect stands for a one6dimensional array that is absent from a conceptual
model used by the clients of Array;D. #n the above e2ample, Array<D is a pro2y class. #ts instances stand for
one6dimensional arrays that, conceptually, do not e2ist.

21. &ame some pure o.ject oriented languages.
Answer:
Smalltalk,
Cava,
1iffel,
Sather.
22. &ame the operators that cannot .e overloaded.
Answer:
sizeof . .7 .6Q 44 `4
23. What is a node class?
Answer:
A node class is a class that,
relies on the base class for services and implementation,
provides a wider interface to te users than its base class,
relies primarily on virtual functions in its public interface
depends on all its direct and indirect base class
F=
can be understood only in the conte2t 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 from its base
class.
2*. What is an orthogonal .ase class?
Answer:
#f two base classes have no overlapping methods or data they are said to be independent of, or
orthogonal to each other. Orthogonal in the sense means that two classes operate in different dimensions and do
not interfere with each other in any way. *he same derived class may inherit such classes with no difficulty.
2-. What is a container class? What are the types of container classes?
Answer:
A container class is a class that is used to hold ob:ects in memory or e2ternal storage. A container class
acts as a generic holder. A container class has a predefined behavior and a well6known interface. A container
class is a supporting class whose purpose is to hide the topology used for maintaining the list of ob:ects in
memory. Ehen a container class contains a group of mi2ed ob:ects, the container is called a heterogeneous
containerX when the container is holding a group of ob:ects that are all the same, the container is called a
homogeneous container.
20. What is a protocol class?
Answer:
An abstract class is a protocol class if4
it neither contains nor inherits from classes that contain member data, non6virtual functions, or private
'or protected( members of any kind.
it has a non6inline virtual destructor defined with an empty implementation,
all member functions other than the destructor including inherited functions, are declared pure virtual
functions and left undefined.
25. What is a mixin class?
Answer:
A class that provides some but not all of the implementation for a virtual base class is often called mi2in.
Derivation done :ust for the purpose of redefining the virtual functions in the base classes is often called mi2in
inheritance. i2in classes typically donTt share common bases.
27. What is a concrete class?
Answer:
A concrete class is used to define a useful ob:ect that can be instantiated as an automatic variable on the
program stack. *he implementation of a concrete class is defined. *he concrete class is not intended to be a base
class and no attempt to minimize dependency on other classes in the implementation or behavior of the class.
2?.What is the handle class?
Answer:
A handle is a class that maintains a pointer to an ob:ect that is programmatically accessible through the
public interface of the handle class.
Explanation:
#n case of abstract classes, unless one manipulates the ob:ects of these classes through pointers and
references, the benefits of the virtual functions are lost. 9ser code may become dependent on details of
implementation classes because an abstract type cannot be allocated statistically or on the stack without its size F?
being known. 9sing pointers or references implies that the burden of memory management falls on the user.
Another limitation of abstract class ob:ect is of fi2ed size. Classes however are used to represent concepts that
re,uire varying amounts of storage to implement them.
A popular techni,ue for dealing with these issues is to separate what is used as a single ob:ect in two parts4 a
handle providing the user interface and a representation holding all or most of the ob:ectTs state. *he connection
between the handle and the representation is typically a pointer in the handle. Often, handles have a bit more
data than the simple representation pointer, but not much more. )ence the layout of the handle is typically
stable, even when the representation changes and also that handles are small enough to move around relatively
freely so that the user needn0t use the pointers and the references.

3@. What is an action class?
Answer:
*he simplest and most obvious way to specify an action in C88 is to write a function. )owever, if the
action has to be delayed, has to be transmitted TelsewhereT before being performed, re,uires its own data, has to
be combined with other actions, etc then it often becomes attractive to provide the action in the form of a class
that can e2ecute the desired action and provide other services as well. anipulators used with iostreams is an
obvious e2ample.
Explanation:
A common form of action class is a simple class containing :ust one virtual function.
class Action
]
public4
virtual int doKit' int (>@X
virtual aAction' (X
^
"iven this, we can write code say a member that can store actions for later e2ecution without using
pointers to functions, without knowing anything about the ob:ects involved, and without even knowing the
name of the operation it invokes. .or e2ample4
class writeKfile 4 public Action
]
.ileU fX
public4
int doKit'int(
]
return fwrite' (.suceed' (X
^
^X
class errorKmessage4 public Action
]
responseKbo2 db'message.cstr' (,NContinueN,NCancelN,N$etryN(X
switch 'db.getresponse' ((
]
case @4 return @X
case <4 abort'(X
case ;4 currentKoperation.redo' (Xreturn <X
^
^X
A user of the Action class will be completely isolated from any knowledge of derived classes such as
writeKfile and errorKmessage.
FF
31. When can you tell that a memory lea' will occur?
Answer:
A memory leak occurs when a program loses the ability to free a block of dynamically allocated
memory.
32.What is a parameteriCed type?
Answer:
A template is a parameterized construct or type containing generic code that can use or manipulate any
type. #t is called parameterized because an actual type is a parameter of the code body. 3olymorphism may be
achieved through parameterized types. *his type of polymorphism is called parameteric polymorphism.
3arameteric polymorphism is the mechanism by which the same code is used on different types passed as
parameters.
33. !ifferentiate .etween a deep copy and a shallow copy?
Answer:
Deep copy involves using the contents of one ob:ect to create another instance of the same class. #n a
deep copy, the two ob:ects may contain ht same information but the target ob:ect will have its own buffers and
resources. the destruction of either ob:ect will not affect the remaining ob:ect. *he overloaded assignment
operator would create a deep copy of ob:ects.
Shallow copy involves copying the contents of one ob:ect into another instance of the same class thus
creating a mirror image. Owing to straight copying of references and pointers, the two ob:ects will share the
same e2ternally contained contents of the other ob:ect to be unpredictable.
Explanation:
9sing a copy constructor we simply copy the data values member by member. *his method of copying
is called shallow copy. #f the ob:ect is a simple class, comprised of built in types and no pointers this would be
acceptable. *his 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 members are copied and not the value the address is
pointing to. *he data values of the ob:ect would then be inadvertently altered by the function. Ehen the
function goes out of scope, the copy of the ob:ect with all its data is popped off the stack.
#f the ob:ect has any pointers a deep copy needs to be e2ecuted. Eith the deep copy of an ob:ect,
memory is allocated for the ob:ect in free store and the elements pointed to are copied. A deep copy is used for
ob:ects that are returned from a function.
3*. What is an opa/ue pointer?
Answer:
A pointer is said to be opa,ue 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 of merging an implementation file with all its headers and
header files.
3-. What is a smart pointer?
Answer:
A smart pointer is an ob:ect that acts, looks and feels like a normal pointer but offers more functionality.
#n C88, smart pointers are implemented as template classes that encapsulate a pointer and override standard
pointer operators. *hey have a number of advantages over regular pointers. *hey are guaranteed to be initialized
as either null pointers or pointers to a heap ob:ect. #ndirection through a null pointer is checked. !o delete is
ever necessary. Ob:ects are automatically freed when the last pointer to them has gone away. One significant
problem with these smart pointers is that unlike regular pointers, they donTt respect inheritance. Smart pointers
are unattractive for polymorphic code. "iven below is an e2ample for the implementation of smart pointers.
Exaple:
template Rclass GQ
class smartKpointer
FD
]
public4
smartKpointer'(X LL makes a null pointer
smartKpointer'const GU 2( LL makes pointer to copy of 2
GU operator 7' (X
const GU operator7' ( constX
G7 operator6Q'( constX
smartKpointer'const smartKpointer RGQ U(X
const smartKpointer RGQ U operator >'const smartKpointerRGQU(X
asmartKpointer'(X
private4
LL...
^X
*his class implement a smart pointer to an ob:ect of type G. *he ob:ect itself is located on the heap.
)ere is how to use it4
smartKpointer RemployeeQ p> employee'N)arrisN,<BBB(X
-ike other overloaded operators, p will behave like a regular pointer,
coutRR7pX
p6QraiseKsalary'@.=(X
30. What is reflexive association?
Answer:
*he Tis6aT is called a refle2ive association because the refle2ive association permits classes to bear the is6
a association not only with their super6classes but also with themselves. #t differs from a Tspecializes6fromT as
Tspecializes6fromT is usually used to describe the association between a super6class and a sub6class. .or e2ample4
3rinter is6a printer.
35. What is slicing?
Answer:
Slicing means that the data added by a subclass are discarded when an ob:ect of the subclass is passed or
returned by value or from a function e2pecting a base class ob:ect.
Explanation:
Consider the following class declaration4
class base
]
...
baseU operator >'const baseU(X
base 'const baseU(X
^
void fun' (
]
base e>mX
e>mX
^
As base copy functions donTt know anything about the derived only the base part of the derived is
copied. *his is commonly referred to as slicing. One reason to pass ob:ects of classes in a hierarchy is to avoid
slicing. Other reasons are to preserve polymorphic behavior and to gain efficiency.
37. What is name mangling?
FJ
Answer:
!ame mangling is the process through which your c88 compilers give each function in your program a
uni,ue name. #n C88, all programs have at6least a few functions with the same name. !ame mangling is a
concession to the fact that linker always insists on all function names being uni,ue.
Exaple:
#n general, member names are made uni,ue by concatenating the name of the member with that of the
class e.g. given the declaration4
class %ar
]
public4
int ivalX
...
^X
ival becomes something like4
LL a possible member name mangling
ivalKKB%ar
Consider this derivation4
class .oo 4 public %ar
]
public4
int ivalX
...
^
*he internal representation of a .oo ob:ect is the concatenation of its base and derived class members.
LL 3seudo C88 code
LL #nternal representation of .oo
class .oo
]
public4
int ivalKKB%arX
int ivalKKB.ooX
...
^X
9nambiguous access of either ival members is achieved through name mangling. ember functions,
because they can be overloaded, re,uire an e2tensive mangling to provide each with a uni,ue name. )ere the
compiler generates the same name for the two overloaded instances'*heir argument lists make their instances
uni,ue(.

3?. What are proxy o.jects?
Answer:
Ob:ects that points to other ob:ects are called pro2y ob:ects or surrogates. #ts an ob:ect that provides the
same interface as its server ob:ect but does not have any functionality. During a method invocation, it routes
data to the true server ob:ect and sends back the return value to the ob:ect.
*@. !ifferentiate .etween declaration and definition in ,88.
Answer:
A declaration introduces a name into the programX a definition provides a uni,ue description of an entity
'e.g. type, instance, and function(. Declarations can be repeated in a given scope, it introduces a name in a given
scope. *here must be e2actly one definition of every ob:ect, function or class used in a C88 program.
A declaration is a definition unless4
it declares a function without specifying its body,
it contains an e2tern specifier and no initializer or function body,
D@
it is the declaration of a static class data member without a class definition,
it is a class name definition,
it is a typedef declaration.
A definition is a declaration unless4
it defines a static class data member,
it defines a non6inline member function.
*1. What is cloning?
Answer:
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. *he latter process is called cloning.
*2. !escri.e the main characteristics of static functions.
Answer:
*he main characteristics of static functions include,
#t is without the a this pointer,
#t canTt directly access the non6static members of its class
#t canTt be declared const, volatile or virtual.
#t doesnTt need to be invoked through an ob:ect of its class, although for convenience, it may.
*3. Will the inline function .e compiled as the inline function always? Yustify.
Answer:
An inline function is a re,uest and not a command. )ence it wonTt be compiled as an inline function
always.
Explanation:
#nline6e2pansion could fail if the inline function contains loops, the address of an inline function is used,
or an inline function is called in a comple2 e2pression. *he rules for inlining are compiler dependent.
**. !efine a way other than using the 'eyword inline to ma'e a function inline.
Answer:
*he function must be defined inside the class.
*-. )ow can a W::W operator .e used as unary operator?
Answer:
*he scope operator can be used to refer to members of the global namespace. %ecause the global
namespace doesn0t have a name, the notation 44 member6name refers to a member of the global namespace. *his
can be useful for referring to members of global namespace whose names have been hidden by names declared
in nested local scope. 9nless we specify to the compiler in which namespace to search for a declaration, the
compiler simple searches the current scope, and any scopes in which the current scope is nested, to find the
declaration for the name.
*0. What is placement new?
Answer:
Ehen you want to call a constructor directly, you use the placement new. Sometimes you have some raw
memory thatTs already been allocated, and you need to construct an ob:ect in the memory you have. Operator
newTs special version placement new allows you to do it.
class Eidget
]
public 4
Eidget'int widgetsize(X
D<
...
Eidget7 ConstructKwidgetKintKbuffer'void 7buffer,int widgetsize(
]
return new'buffer( Eidget'widgetsize(X
^
^X
*his function returns a pointer to a Eidget ob:ect thatTs constructed within the buffer passed to the
function. Such a function might be useful for applications using shared memory or memory6mapped #LO,
because ob:ects in such applications must be placed at specific addresses or in memory allocated by special
routines.
//0D
1. What do you mean .y analysis and design?
6nalysis:
%asically, it is the process of determining what needs to be done before how it should be done. #n
order to accomplish this, the developer refers the e2isting systems and documents. So, simply it is an art of
discovery.
!esign:
#t is the process of adoptingLchoosing the one among the many, which best accomplishes the
users needs. So, simply, it is compromising mechanism.
2. What are the steps involved in designing?
%efore getting into the design the designer should go through the S$S prepared by the System Analyst.
*he main tasks of design are Architectural Design and Detailed Design.
#n Architectural Design we find what are the main modules in the problem domain.
#n Detailed Design we find what should be done within each module.
3. What are the main underlying concepts of o.ject orientation?
Ob:ects, messages, class, inheritance and polymorphism are the main concepts of ob:ect orientation.
*. What do u meant .y K$"+K of an o.ject?
S%# stands for State, %ehavior and #dentity. Since every ob:ect has the above three.
$tate:
#t is :ust a value to the attribute of an ob:ect at a particular time.
"ehaviour4
#t describes the actions and their reactions of that ob:ect.
+dentity4
An ob:ect has an identity that characterizes its own e2istence. *he identity makes it possible to
distinguish any ob:ect in an unambiguous way, and independently from its state.
-. !ifferentiate persistent ( non3persistent o.jects?
3ersistent refers to an ob:ectTs ability to transcend time or space. A persistent ob:ect storesLsaves its state
in a permanent storage system with out losing the information represented by the ob:ect.
A non6persistent ob:ect is said to be transient or ephemeral. %y default ob:ects are considered as non6
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. #n simple words it can be referred as client.
D;
3assive ob:ects are one, which passively waits for the message to be processed. #t waits for another
ob:ect that re,uires its services. #n simple words it can be referred as server.
Diagram4
client server
'Active( '3assive(
5. What is meant .y software development method`
Software development method describes how to model and build software systems in a reliable and
reproducible way. *o put it simple, methods that are used to represent onesT thinking using graphical notations.
7. What are models and meta models?
#odel:
+t is a complete description of something 'i.e. system(.
#eta model:
#t describes the model elements, synta2 and semantics of the notation that allows their
manipulation.
?. What do you meant .y static and dynamic modeling?
Static modeling is used to specify structure of the ob:ects that e2ist in the problem domain. *hese are
e2pressed using class, o.ject and Q$1,6$1 diagrams.
%ut Dynamic modeling refers representing the ob:ect interactions during runtime. #t 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 e2ist in the problem domain.
e.g. for modeling element is class notation, ob:ect notation etc.
$elationships are used to represent the interaction between the modeling elements.
*he following are the $elationships.
6ssociation: #tsT :ust a semantic connection two classes.
e.g.4
6ggregation: #tsT the relationship between two classes which are related in the fashion that master and slave.
*he master takes full rights than the slave. Since the slave works under the master. #t is represented as line
with diamond in the master area.
e24
car contains wheels, etc.

car
,ontainment: *his relationship is applied when the part contained with in the whole part, dies when the
whole part dies.
#t is represented as darked diamond at the whole part.
e2ample4
class A]
LLsome code
^X
DB
car wheels
class A class %
uses
class %
]
A aaX LL an ob:ect of class AX
LL some code for class %X
^X
#n the above e2ample 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 diagram like this.
=eneraliCation: *his relationship used when we want represents a class, which captures the common states
of ob:ects of different classes. #t is represented as arrow line pointed at the class, which has captured the
common states.



!ependency: #t is the relationship between dependent and independent classes. Any change in the
independent class will affect the states of the dependent class.
D#A"$A4
class A class %
11. Why generaliCation is very strong?
1ven though "eneralization satisfies Structural, #nterface, %ehaviour properties. #t is mathematically
very strong, as it is Antisymmetric and *ransitive.
6ntisymmetric: employee is a person, but not all persons are employees. athematically all As0 are %,
but all %s0 not A.
Dransitive: A>Q%, %>Qc then A>Qc.
A. Salesman.
%. 1mployee.
C. 3erson.
)ote: All the other relationships satisfy all the properties like Structural properties, #nterface properties,
%ehaviour properties.
12. !ifferentiate 6ggregation and containment?
Aggregation is the relationship between the whole and a part. Ee can addLsubtract some properties in
the part 'slave( side. #t wonTt affect the whole part.
%est e2ample is Car, which contains the wheels and some e2tra parts. 1ven though the parts are not there
we can call it as car.
%ut, in the case of containment the whole part is affected when the part within that got affected. *he
human body is an apt e2ample for this relationship. Ehen the whole body dies the parts 'heart etc( are died.
13. ,an lin' and 6ssociation applied interchangea.ly?
!o, Hou cannot apply the link and Association interchangeably. Since link is used represent the
relationship between the two ob:ects.
DA
class A class %
class A
class % class C
%ut Association is used represent the relationship between the two classes.
link 44 student4Abhilash course4CA
Association44 student course
1*. what is meant .y Kmethod3warsK?
%efore <JJA there were different methodologies like $umbaugh, %ooch, Cacobson, eyer etc who
followed their own notations to model the systems. *he developers were in a dilemma to choose the method
which best accomplishes their needs. *his particular span was called as Nmethod6warsN
1-. Whether unified method and unified modeling language are same or different?
9nified method is convergence of the $umbaugh and %ooch.
9nified modeling lang. is the fusion of $umbaugh, %ooch and Cacobson as well as %etrand eyer
'whose contribution is Nse,uence diagramN(. #tsT the superset of all the methodologies.
10. Who were the three famous amigos and what was their contri.ution to the o.ject community?
*he *hree amigos namely,
Yames um.augh 2E#D4: A veteran in analysis who came up with an idea about the ob:ects and their
$elationships 'in particular Associations(.
=rady "ooch: A veteran in design who came up with an idea about partitioning of systems into subsystems.

+var Yaco.son 2E.jectory4: *he father of 9S1CAS1S, who described about the user and system interaction.
15. !ifferentiate the class representation of "ooch% um.augh and Q#L?
#f you look at the class representaiton of $umbaugh and 9-, #t is some what similar and both are very
easy to draw.
Represent&tion: /1T 213.
Di&4r&m:

%ooch4 #n this method classes are represented as NCloudsN which are not very easy to draw as for as the
developerTs view is concern.
Di&4r&m:
17. What is an Q$1,6$1? Why it is needed?
A 9se Case is a description of a set of se,uence of actions that a system performs that yields an
observable result of value to a particular action.
#n SSAD process R>Q #n OOAD 9S1CAS1. #t is represented elliptically.
Represent&tion:
D=
1?. Who is an 6ctor?
An Actor is someone or something that must interact with the system.#n addition to that an Actor
initiates the process'that is 9S1CAS1(.
#t is represented as a stickman like this.
Di&4r&m:
2@. What is guard condition?
"uard condition is one, which acts as a firewall. *he access from a particular ob:ect can be made only
when the particular condition is met.
.or 12ample,
customer check customer number A*.
)ere the ob:ect on the customer accesses the A* facility only when the guard condition is met.
21. !ifferentiate the following notations?
+: :o.j1 :o.j2

++: :o.j1 :o.j2
#n the above representation #, ob:< sends message to ob:;. %ut in the case of ## the data is transferred
from ob:< to ob:;.
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?
*his can be accomplished by specifying the relationship called Nrefinement\ which talks about the
two different abstraction of the same thing.
Or e2ample,
calculate pay calculate
class< class; classB
23. $uppose a class acts an 6ctor in the pro.lem domain% how to represent it in the static model?
#n this scenario you can use [stereotype\. Since stereotype is :ust a string that gives e2tra semantic to the
particular entityLmodel element. #t is given with in the RR QQ.
class A
RR ActorQQ
attributes
methods.
2*. Why does the function arguments are called as KsignaturesK?
*he arguments distinguish functions with the same name 'functional polymorphism(. *he name alone
does not necessarily identify a uni,ue function. )owever, the name and its arguments 'signatures( will uni,uely
identify a function.
#n real life we see suppose, in class there are two guys with same name, but they can be easily
D?
identified by their signatures. *he same concept is applied here.
e24
class person
]
public4
char getse2'(X
void setse2'char(X
void setse2'int(X
^X
#n the above e2ample we see that there is a function setse2'( with same name but with different
signature.
DF
Muantitative Aptitude
Exer'ise 1
0ol)e the %ollowin( an$ 'he'1 with the answers (i)en at the en$*
<. #t was calculated that F= men could complete a piece of work in ;@ days. Ehen work was scheduled to
commence, it was found necessary to send ;= men to another pro:ect. )ow much longer will it take to
complete the work`
;. A student divided a number by ;LB when he re,uired to multiply by BL;. Calculate the percentage of
error in his result.
B. A dishonest shopkeeper professes to sell pulses at the cost price, but he uses a false weight of J=@gm. for
a kg. )is gain is IW.
A. A software engineer has the capability of thinking <@@ lines of code in five minutes and can type <@@
lines of code in <@ minutes. )e takes a break for five minutes after every ten minutes. )ow many lines
of codes will he complete typing after an hour`
=. A man was engaged on a :ob for B@ days on the condition that he would get a wage of $s. <@ for the day
he works, but he have to pay a fine of $s. ; for each day of his absence. #f he gets $s. ;<? at the end, he
was absent for work for ... days.
?. A contractor agreeing to finish a work in <=@ days, employed F= men each working D hours daily. After
J@ days, only ;LF of the work was completed. #ncreasing the number of men by KKKKKKKK each working
now for <@ hours daily, the work can be completed in time.
F. what is a percent of b divided by b percent of a`
'a( a 'b( b 'c( < 'd( <@ 'd( <@@
D. A man bought a horse and a cart. #f he sold the horse at <@ W loss and the cart at ;@ 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. <@ in the
bargain. *he amount paid by him was $s.KKKKKKK for the horse and $s.KKKKKKKK for the cart.
J. A tennis marker is trying to put together a team of four players for a tennis tournament out of seven
available. males 6 a, b and cX females & m, n, o and p. All players are of e,ual ability and there must be at
least two males in the team. .or a team of four, all players must be able to play with each other under the
following restrictions4
b should not play with m,
c should not play with p, and
a should not play with o.
Ehich of the following statements must be false`
<. b and p cannot be selected together
DD
Quantitative
Aptitude
;. c and o cannot be selected together
B. c and n cannot be selected together.
<@6<;. *he following figure depicts three views of a cube. %ased on this, answer ,uestions <@6<;.
? = A
< ;; B ?
<@. *he number on the face opposite to the face carrying < is KKKKKKK .
<<. *he number on the faces ad:acent to the face marked = are KKKKKKK .
<;. Ehich of the following pairs does not correctly give the numbers on the opposite faces.
'<( ?,= ';( A,< 'B( <,B 'A( A,;
<B. .ive farmers have F, J, <<, <B U <A apple trees, respectively in their orchards. -ast year, each of them
discovered that every tree in their own orchard bore e2actly the same number of apples. .urther, if the
third farmer gives one apple to the first, and the fifth gives three to each of the second and the fourth,
they would all have e2actly the same number of apples. Ehat were the yields per tree in the orchards of
the third and fourth farmers`
<A. .ive boys were climbing a hill. C was following ). $ was :ust ahead of ". _ was between " U ). *hey
were climbing up in a column. Eho was the second`
<=6<D Cohn is undecided which of the four novels to buy. )e is considering a spy
thriller, a urder mystery, a "othic romance and a science fiction novel. *he books are written by
$othko, "orky, %urchfield and )opper, not necessary in that order, and published by )eron, 3iegon,
%lue:a and sparrow, not necessary in that order.
1 '<( *he book by $othko is published by Sparrow.
5 ';( *he Spy thriller is published by )eron.
'B( *he science fiction novel is by %urchfield and is not published by %lue:a.
6 'A(*he "othic romance is by )opper.
-
<=. 3igeon publishes KKKKKKKKKKKK.
<?. *he novel by "orky KKKKKKKKKKKKKKKK.
<F. Cohn purchases books by the authors whose names come first and third in alphabetical order. )e does
not buy the books KKKKKK.
<D. On the basis of the first paragraph and statement ';(, 'B( and 'A( only, it is possible to deduce that
<. $othko wrote the murder mystery or the spy thriller
;. Sparrow published the murder mystery or the spy thriller
B. *he book by %urchfield is published by Sparrow.
<J. #f a light flashes every ? seconds, how many times will it flash in c of an hour`
;@. #f point 3 is on line segment A%, then which of the following is always true`
DJ
; B ;
'<( A3 > 3% ';( A3 Q 3% 'B( 3% Q A3 'A( A% Q A3 '=( A% Q A3 8 3%
;<. All men are vertebrates. Some mammals are vertebrates. Ehich of the following conclusions drawn
from the above statement is correct.
All men are mammals
All mammals are men
Some vertebrates are mammals.
!one
;;. Ehich of the following statements drawn from the given statements are correct`
"iven4
All watches sold in that shop are of high standard. Some of the )* watches are sold in that shop.
a( All watches of high standard were manufactured by )*.
b( Some of the )* watches are of high standard.
c( !one of the )* watches is of high standard.
d( Some of the )* watches of high standard are sold in that shop.
;B6;F.
<. Ashland is north of 1ast -iverpool and west of Coshocton.
;. %owling green is north of Ashland and west of .redericktown.
B. Dover is south and east of Ashland.
A. 1ast -iverpool is north of .redericktown and east of Dover.
=. .redericktown is north of Dover and west of Ashland.
?. Coshocton is south of .redericktown and west of Dover.
;B. Ehich of the towns mentioned is furthest of the north & west
'a( Ashland 'b( %owling green 'c( Coshocton
'd( 1ast -iverpool 'e( .redericktown
;A. Ehich of the following must be both north and east of .redericktown`
'a( Ashland 'b( Coshocton 'c( 1ast -iverpool
# a only ## b only ### c only #+ a U b + a U c
;=. Ehich of the following towns must be situated both south and west of at least one other town`
A. Ashland only
%. Ashland and .redericktown
C. Dover and .redericktown
D. Dover, Coshocton and .redericktown
1. Coshocton, Dover and 1ast -iverpool.
;?. Ehich of the following statements, if true, would make the information in the numbered statements
more specific`
'a( Coshocton is north of Dover.
'b( 1ast -iverpool is north of Dover
'c( Ashland is east of %owling green.
'd( Coshocton is east of .redericktown
'e( %owling green is north of .redericktown
;F. Ehich of the numbered statements gives information that can be deduced from one or more of the other
statements`
'A( < '%( ; 'C( B 'D( A '1( ?
J@
;D. 1ight friends )arsha, .akis, %ala:i, 1swar, Dhinesh, Chandra, "eetha, and Ahmed 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 Ahmed. Chandra is sitting between Ahmed and "eetha and %ala:i and 1shwar are
not sitting opposite to each other. Eho is third to the left of Dhinesh`
;J. #f every alternative letter starting from % of the 1nglish alphabet is written in small letter, rest all are
written in capital letters, how the month [ September\ be written.
'<( Sept1b1r ';( S1p*e%1r 'B( Septembe$
'A( Septeber '=( !one of the above.
B@. *he length of the side of a s,uare is represented by 28;. *he length of the side of an e,uilateral triangle
is ;2. #f the s,uare and the e,uilateral triangle have e,ual perimeter, then the value of 2 is KKKKKKK.
B<. #t takes r. _arthik y hours to complete typing a manuscript. After ; hours, he was called away. Ehat
fractional part of the assignment was left incomplete`
B;. Ehich of the following is larger than BL=`
'<( d ';( BJL=@ 'B( FL;= 'A( BL<@ '=( =JL<@@
BB. *he number that does not have a reciprocal is KKKKKKKKKKKK.
BA. *here are B persons Sudhir, Arvind, and "auri. Sudhir lent cars to Arvind and "auri as many as they had
already. After some time Arvind gave as many cars to Sudhir and "auri as many as they have. After
sometime "auri did the same thing. At the end of this transaction each one of them had ;A. .ind the cars
each originally had.
B=. A man bought a horse and a cart. #f he sold the horse at <@ W loss and the cart at ;@ 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. <@ in the
bargain. *he amount paid by him was $s.KKKKKKK for the horse and $s.KKKKKKKK for the cart.
0ns7ers:
<. Answer:
B@ days.
Explanation:
"efore:
One day work > < L ;@
One man0s one day work > < L ' ;@ 7 F=(
&ow:
!o. Of workers > =@
One day work > =@ 7 < L ' ;@ 7 F=(
*he total no. of days re,uired to complete the work > 'F= 7 ;@( L =@ > B@
;. Answer:
@ W
Explanation:
Since B2 L ; > 2 L '; L B(
B. Answer:
J<
=.B W
Explanation:
)e sells J=@ grams of pulses and gains =@ grams.
#f he sells <@@ grams of pulses then he will gain '=@ L J=@( 7<@@ > =.;?
A. Answer:
;=@ lines of codes
=. Answer:
F days
Explanation:
*he e,uation portraying the given problem is4
<@ 7 2 & ; 7 'B@ & 2( > ;<? where 2 is the number of working days.
Solving this we get 2 > ;B
!umber of days he was absent was F 'B@6;B( days.
?. Answer:
<=@ men.
Explanation:
One day0s work > ; L 'F 7 J@(
One hour0s work > ; L 'F 7 J@ 7 D(
One man0s work > ; L 'F 7 J@ 7 D 7 F=(
*he remaining work '=LF( has to be completed within ?@ days, because the total number of days
allotted for the pro:ect is <=@ days.
So we get the e,uation
'; 7 <@ 7 2 7 ?@( L 'F 7 J@ 7 D 7 F=( > =LF where 2 is the number of men working after the J@
th
day.
Ee get 2 > ;;=
Since we have F= men already, it is enough to add only <=@ men.
F. Answer:
'c( <
Explanation:
a percent of b 4 'aL<@@( 7 b
b percent of a 4 'bL<@@( 7 a
a percent of b divided by b percent of a 4 ''a L <@@ (7b( L 'bL<@@( 7 a (( > <
D. Answer:
Cost price of horse > $s. A@@ U the cost price of cart > ;@@.
Explanation:-
-et 2 be the cost price of the horse and y be the cost price of the cart.
#n the first sale there is no loss or profit. 'i.e.( *he loss obtained is e,ual to the gain.
*herefore '<@L<@@( 7 2 > ';@L<@@( 7 y
G > ; 7 y 66666666666666666'<(
#n the second sale, he lost $s. <@. 'i.e.( *he loss is greater than the profit by $s. <@.
J;
*herefore '= L <@@( 7 2 > '= L <@@( 7 y 8 <@ 6666666';(
Substituting '<( in ';( we get
'<@ L <@@( 7 y > '= L <@@( 7 y 8 <@
'= L <@@( 7 y > <@
' 8 500
.rom '<( ; 7 ;@@ > x 8 -00
J. Answer:
B.
Explanation:
Since inclusion of any male player will re:ect a female from the team. Since there should be four
member in the team and only three males are available, the girl, n should included in the team always
irrespective of others selection.
<@. Answer:
=
<<. Answer:
<,;,B U A
<;. Answer:
%
<B. Answer:
<< U J apples per tree.
Explanation:
-et a, b, c, d U e be the total number of apples bored per year in A, %, C, D U 1 /s orchard.
"iven that a 8 < > b 8 B > c & < > d 8 B > e & ?
%ut the ,uestion is to find the number of apples bored per tree in C and D /s orchard. #f is enough to
consider c & < > d 8 B.
Since the number of trees in C0s orchard is << and that of D0s orchard is <B. -et 2 and y be the
number of apples bored per tree in C U d /s orchard respectively.
*herefore << 2 & < > <B y 8 B
%y trial and error method, we get the value for 2 and y as << and J
<A. Answer:
".
Explanation:
*he order in which they are climbing is $ & " & _ & ) & C
<= & <D
Answer:
!ovel !ame Author 3ublisher
Spy thriller $athko )eron
urder mystery "orky 3iegon
"othic romance %urchfield %lue:a
Science fiction )opper Sparrow
Explanation:
"iven
JB
!ovel !ame Author 3ublisher
Spy thriller $athko )eron
urder mystery "orky 3iegon
"othic romance %urchfield %lue:a
Science fiction )opper Sparrow
Since %lue:a doesn0t publish the novel by %urchfield and )eron publishes the novel spy thriller,
3iegon publishes the novel by %urchfield.
Since )opper writes "othic romance 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 "orky, "orky
writes Spy thriller and $athko writes urder mystery.
<J. Answer:
A=< times.
Explanation:
*here are ?@ minutes in an hour.
#n c of an hour there are '?@ 7 c( minutes > A= minutes.
#n c of an hour there are '?@ 7 A=( seconds > ;F@@ seconds.
-ight flashed for every ? seconds.
#n ;F@@ seconds ;F@@L? > A=@ times.
*he count start after the first flash, the light will flashes A=< times in c of an hour.
;@. Answer:
'A(
Explanation:
3
A %
Since p is a point on the line segment A%, A% Q A3
;<. Answer: 'c(
;;. Answer: 'b( U 'd(.
Ahmed
;B 6 ;F.Answer:
.akis Chandra
;D. Answer: .akis
Explanation: )arsha =eetha
1swar %ala:i
Dhinesh
;J. Answer:
JA
'=(.
Explanation:
Since every alternative letter starting from % of the 1nglish alphabet is written in small letter, the
letters written in small letter are b, d, f...
#n the first two answers the letter 1 is written in both small U capital letters, so they are not the
correct answers. %ut in third and fourth answers the letter is written in small letter instead capital letter,
so they are not the answers9

B@. Answer:
2 > A
Explanation:
Since the side of the s,uare is 2 8 ;, its perimeter > A '2 8 ;( > A2 8 D
Since the side of the e,uilateral triangle is ;2, its perimeter > B 7 ;2 > ?2
Also, the perimeters of both are e,ual.
'i.e.( A2 8 D > ?2
'i.e.( ;2 > D 2 > A.
B<. Answer:
5 'y & ;( L y.
Explanation:
*o type a manuscript karthik took y hours.
*herefore his speed in typing > <Ly.
)e was called away after ; hours of typing.
*herefore the work completed > <Ly 7 ;.
*herefore the remaining work to be completed > < & ;Ly.
'i.e.( work to be completed > 'y6;(Ly
B;. Answer:
';(
BB. Answer:
<
Explanation:
One is the only number e2ists without reciprocal because the reciprocal of one is one itself.
BA. Answer:
Sudhir had BJ cars, Arvind had ;< cars and "auri had <; cars.
Explanation:
Sudhir Arvind "auri
.inally ;A ;A ;A
%efore "auri0s transaction <; <; AD
%efore Arvind0s transaction ? A; ;A
%efore Sudhir0 s transaction BJ ;< <;
B=. Answer:
Cost price of horse4 $s. A@@ U
Cost price of cart4 $s. ;@@
Explanation:
-et 2 be the cost of horse U y be the cost of the cart.
<@ W of loss in selling horse > ;@ W of gain in selling the cart
J=
*herefore '<@ L <@@( 7 2 > ';@ 7 <@@( 7 y
2 > ;y 66666666666'<(
= W of loss in selling the horse is <@ more than the = W gain in selling the cart.
*herefore '= L <@@( 7 2 6 <@ > '= L <@@( 7 y
=2 6 <@@@ > =y
Substituting '<(
<@y 6 <@@@ > =y
=y > <@@@
y > ;@@
2 > A@@ from '<(
Exer'ise 2*1
:or the follo7in4( fin% the next term in the series
<. ?, ;A, ?@,<;@, ;<@
a( BB? b( B?? c( BB@ d( ??@
Answer 4 a( BB?
Explanation 4 *he series is <.;.B, ;.B.A, B.A.=, A.=.?, =.?.F, ..... ' T.T means product(
;. <, =, <B, ;=
Answer 4 A<
Explanation 4 *he series is of the form @5;8<5;, <5;8;5;,...
B. @, =, D, <F
Answer 4 ;A
Explanation 4 <5;6<, ;5;8<, B5;6<, A5;8<, =5;6<
A. <, D, J, ?A, ;= ')int 4 1very successive terms are related(
Answer 4 ;<?
Explanation 4 <5;, ;5B, B5;, A5B, =5;, ?5B
=. D,;A,<;,B?,<D,=A

Answer 4 ;F
?. F<,F?,?J,FA,?F,F;
Answer 4 ?F
F. =,J,<?,;J,=A
Answer 4 <@B
Explanation 4 =7;6<>JX J7;6;><?X <?7;6B>;JX ;J7;6A>=AX =A7;6=><@B
D. <,;,A,<@,<?,A@,?A 'Successive terms are related(
Answer 4 ;@@
Explanation 4 *he series is powers of ; ';5@,;5<,..(.
All digits are less than D. 1very second number is in octal number system.
J?
<;D should follow ?A. <;D base <@ > ;@@ base D.
Exer'ise 2*2
:in% the o%% m&n out9
<. B,=,F,<;,<B,<F,<J
Answer 4 <;
Explanation 4 All but <; are odd numbers
;. ;,=,<@,<F,;?,BF,=@,?A
Answer 4 ?A
Explanation 4 ;8B>=X =8=><@X <@8F><FX <F8J>;?X ;?8<<>BFX BF8<B>=@X =@8<=>?=X
B. <@=,D=,?@,B@,@,6A=,6J@
Answer 4 @
Explanation 4 <@=6;@>D=X D=6;=>?@X ?@6B@>B@X B@6B=>6=X 6=6A@>6A=X 6A=6A=>6J@X
Exer'ise 2
Sol;e the follo7in49
<. Ehat is the number of zeros at the end of the product of the numbers from < to <@@`
Answer 4 <;F
;. A fast typist can type some matter in ; hours and a slow typist can type the same in B hours. #f both type
combinely, in how much time will they finish`
Answer 4 < hr <; min
Explanation : *he fast typistTs work done in < hr > <L;
*he slow typistTs work done in < hr > <LB
#f they work combinely, work done in < hr > <L;8<LB > =L?
So, the work will be completed in ?L= hours. i.e., <8<L= hours > <hr <; min
B. "avaskarTs average in his first =@ innings was =@. After the =<st innings, his average was =<. )ow many runs
did he score in his =<st innings. 'supposing that he lost his wicket in his =<st innings(
Answer 4 <@<
Explanation 4 *otal score after =@ innings > =@7=@ > ;=@@
*otal score after =< innings > =<7=< > ;?@<
So, runs made in the =<st innings > ;?@<6;=@@ > <@<
#f he had not lost his wicket in his =<st innings, he would have scored an unbeaten =@ in his =<st
innings.
A. Out of D@ coins, one is counterfeit. Ehat is the minimum number of weighings needed to find out the
counterfeit coin`
Answer 4 A
=. Ehat can you conclude from the statement 4 All green are blue, all blue are red. `
'i( some blue are green
'ii( some red are green
'iii( some green are not red
'iv( all red are blue
'a( i or ii but not both
JF
'b( i U ii only
'c( iii or iv but not both
'd( iii U iv
Answer 4 'b(
?. A rectangular plate with length D inches, breadth << inches and thickness ; inches is available. Ehat is the
length of the circular rod with diameter D inches and e,ual to the volume of the rectangular plate`
Answer 4 B.= inches
Explanation 4 +olume of the circular rod 'cylinder( > +olume of the rectangular plate
';;LF(7A7A7h > D7<<7;
h > FL; > B.=
F. Ehat is the sum of all numbers between <@@ and <@@@ which are divisible by <A `
Answer 4 B=BJ;
Explanation 4 *he number closest to <@@ which is greater than <@@ and divisible by <A is <<;, which is
the first term of the series which has to be summed.
*he number closest to <@@@ which is less than <@@@ and divisible by <A is JJA, which is the last
term of the series.
<<; 8 <;? 8 .... 8 JJA > <A'D8J8 ... 8 F<( > B=BJ;
D. #f s'a( denotes s,uare root of a, find the value of s'<;8s'<;8s'<;8 ...... upto infinity.
Answer 4 A
Explanation 4 -et 2 > s'<;8s'<;8s'<;8.....
Ee can write 2 > s'<;82(. i.e., 25; > <; 8 2. Solving this ,uadratic e,uation, we get 2 > 6B or 2>A. Sum
cannot be 6ve and hence sum > A.
J. A cylindrical container has a radius of eight inches with a height of three inches. Compute how many inches
should be added to either the radius or height to give the same increase in volume`
Answer 4 <?LB inches
Explanation 4 -et 2 be the amount of increase. *he volume will increase by the same amount if the
radius increased or the height is increased.
So, the effect on increasing height is e,ual to the effect on increasing the radius.
i.e., ';;LF(7D7D7'B82( > ';;LF(7'D82(7'D82(7B
Solving the ,uadratic e,uation we get the 2 > @ or <?LB. *he possible increase would be by <?LB inches.
<@. Eith :ust si2 weights and a balance scale, you can weigh any unit number of kgs from < to B?A. Ehat could
be the si2 weights`
Answer 4 <, B, J, ;F, D<, ;AB 'All powers of B(
<<. Diophantus passed one si2th of his life in childhood, one twelfth in youth, and one seventh more as a
bachelorX five years after his marriage a son was born who died four years before his father at half his final age.
)ow old is Diophantus`
Answer 4 DA years
Explanation 4 2L? 8 2L<; 8 2LF 8 = 8 2L; 8 A > 2
<; . #f time at this moment is J 3.., what will be the time ;BJJJJJJJJ; hours later`
Answer 4 < 3..
Explanation 4 ;A billion hours later, it would be J 3.. and D hours before that it would be < 3..
<B. )ow big will an angle of one and a half degree look through a glass that magnifies things three times`
JD
Answer 4 < <L; degrees
Explanation 4 *he magnifying glass cannot increase the magnitude of an angle.
<A. Divide A= into four parts such that when ; is added to the first part, ; is subtracted from the second part, ; is
multiplied by the third part and the fourth part is divided by two, all result in the same number.
Answer4 D, <;, =, ;@
Explanation4 a 8 b 8 c 8 d >A=X a8; > b6; > ;c > dL;X a>b6AX c > 'b6;(L;X d > ;'b6;(X b6A 8 b
8 'b6;(L; 8 ;'b6;( > A=X
<=. # drove ?@ km at B@ kmph and then an additional ?@ km at =@ kmph. Compute my average speed over my
<;@ km.
Answer 4 BF <L;
Explanation 4 *ime re,d for the first ?@ km > <;@ min.X *ime re,d for the second ?@ km > F; min.X
*otal time re,d > <J; min
Avg speed > '?@7<;@(L<J; > BF <L;
Auestions 10 and 15 are .ased on the following :
.ive e2ecutives of 1uropean Corporation hold a Conference in $ome
r. A converses in Spanish U #talian
r. %, a spaniard, knows 1nglish also
r. C knows 1nglish and belongs to #taly
r. D converses in .rench and Spanish
r. 1 , a native of #taly knows .rench
<?. Ehich of the following can act as interpreter if r. C U r. D wish to converse
a( only r. A b( Only r. % c( r. A U r. % d( Any of the other three
Answer 4 d( Any of the other three.
Explanation 4 .rom the data given, we can infer the following.
A knows Spanish, #talian
% knows Spanish, 1nglish
C knows #talian, 1nglish
D knows Spanish, .rench
1 knows #talian, .rench
*o act as an interpreter between C and D, a person has to know one of the combinations
#talianUSpanish, #talianU.rench, 1nglishUSpanish, 1nglishU.rench
A, %, and 1 know atleast one of the combinations.

<F. #f a ?th e2ecutive is brought in, to be understood by ma2imum number of original five he should be fluent in
a( 1nglish U .rench b( #talian U Spanish c( 1nglish U .rench d( .rench U #talian
Answer 4 b( #talian U Spanish
Explanation 4 !o of e2ecutives who know
i( 1nglish is ;
ii( Spanish is B
iii( #talian is B
iv( .rench is ;
#talian U Spanish are spoken by the ma2imum no of e2ecutives. So, if the ?th e2ecutive is fluent in #talian U
Spanish, he can communicate with all the original five because everybody knows either Spanish or #talian.
<D. Ehat is the sum of the first ;= natural odd numbers`
JJ
Answer 4 ?;=
Explanation 4 *he sum of the first n natural odd nos is s,uare'n(.
<8B > A > s,uare';( <8B8= > J > s,uare'B(
<J. *he sum of any seven consecutive numbers is divisible by
a( ; b( F c( B d( <<
Exer'ise 2
Tr' the follo7in49
<. *here are seventy clerks working in a company, of which B@ are females. Also, B@ clerks are marriedX
;A clerks are above ;= years of ageX <J married clerks are above ;= years, of which F are malesX <;
males are above ;= years of ageX and <= males are married. )ow many bachelor girls are there and how
many of these are above ;=`
;. A man sailed off from the !orth 3ole. After covering ;,@@@ miles in one direction he turned Eest, sailed
;,@@@ miles, turned !orth and sailed ahead another ;,@@@ miles till he met his friend. )ow far was he
from the !orth 3ole and in what direction`
B. )ere is a series of comments on the ages of three persons C, $, S by themselves.
S 4 *he difference between $Ts age and mine is three years.
C 4 $ is the youngest.
$ 4 1ither # am ;A years old or C ;= or S ;?.
C 4 All are above ;A years of age.
S 4 # am the eldest if and only if $ is not the youngest.
$ 4 S is elder to me.
C 4 # am the eldest.
$ 4 S is not ;F years old.
S 4 *he sum of my age and CTs is two more than twice $Ts age.
One of the three had been telling a lie throughout whereas others had spoken the truth. Determine the
ages of S,C,$.
A. #n a group of five people, what is the probability of finding two persons with the same month of birth`
=. A father and his son go out for a Twalk6and6runT every morning around a track formed by an e,uilateral
triangle. *he fatherTs walking speed is ; mph and his running speed is = mph. *he sonTs walking and
running speeds are twice that of his father. %oth start together from one ape2 of the triangle, the son
going clockwise and the father anti6clockwise. #nitially the father runs and the son walks for a certain
period of time. *hereafter, as soon as the father starts walking, the son starts running. %oth complete
the course in A= minutes. .or how long does the father run` Ehere do the two cross each other`
?. *he Director of edical Services was on his annual visit to the 1!* )ospital. Ehile going through the
out patientsT records he came across the following data for a particular day 4 N 1ar consultations A=X
!ose =@X *hroat F@X 1ar and !ose B@X !ose and *hroat ;@X 1ar and *hroat B@X 1ar, !ose and *hroat <@X
*otal patients <@@.N *hen he came to the conclusion that the records were bogus. Eas he right`
F. Amongst $am, Sham and "obind are a doctor, a lawyer and a police officer. *hey are married to $adha,
"ita and Sita 'not in order(. 1ach of the wives have a profession. "obindTs wife is an artist. $am is not
married to "ita. *he lawyerTs wife is a teacher. $adha is married to the police officer. Sita is an e2pert
cook. EhoTs who`
<@@
D. Ehat should come ne2t`
<, ;, A, <@, <?, A@, ?A,
Auestions ?312 are .ased on the following :
*hree adults & $oberto, Sarah and +icky & will be traveling in a van with five children & .reddy, )illary,
Conathan, -upe, and arta. *he van has a driver0s seat and one passenger seat in the front, and two
benches behind the front seats, one beach behind the other. 1ach bench has room for e2actly three
people. 1veryone must sit in a seat or on a bench, and seating is sub:ect to the following restrictions4
An adult must sit on each bench.
1ither $oberto or Sarah must sit in the driver0s seat.
Conathan must sit immediately beside arta.
J. Of the following, who can sit in the front passenger seat `
'a( Conathan 'b( -upe 'c( $oberto 'd( Sarah 'e( +icky
<@. Ehich of the following groups of three can sit together on a bench`
'a( .reddy, Conathan and arta 'b( .reddy, Conathan and +icky
'c( .reddy, Sarah and +icky 'd( )illary, -upe and Sarah
'e( -upe, arta and $oberto
<<. #f .reddy sits immediately beside +icky, which of the following cannot be true `
a. Conathan sits immediately beside Sarah
b. -upe sits immediately beside +icky
c. )illary sits in the front passenger seat
d. .reddy sits on the same bench as )illary
e. )illary sits on the same bench as $oberto
<;. #f Sarah sits on a bench that is behind where Conathan is sitting, which of the following must be true `
a. )illary sits in a seat or on a bench that is in front of where arta is sitting
b. -upe sits in a seat or on a bench that is in front of where .reddy is sitting
c. .reddy sits on the same bench as )illary
d. -upe sits on the same bench as Sarah
e. arta sits on the same bench as +icky
<B. ake si2 s,uares of the same size using twelve match6sticks. ')int 4 Hou will need an adhesive to
arrange the re,uired figure(
<A. A farmer has two rectangular fields. *he larger field has twice the length and A times the width of the
smaller field. #f the smaller field has area _, then the are of the larger field is greater than the area of the
smaller field by what amount`
'a( ?_ 'b( D_ 'c( <;_ 'd( F_
<=. !ine e,ual circles are enclosed in a s,uare whose area is B?s, units. .ind the area of each circle.
<?. *here are J cards. Arrange them in a B7B matri2. Cards are of A colors. *hey are red, yellow, blue, green.
Conditions for arrangement4 one red card must be in first row or second row. ; green cards should be in
B
rd
column. Hellow cards must be in the B corners only. *wo blue cards must be in the ;nd row. At least
one green card in each row.
<F. #s z less than w` z and w are real numbers.
<@<
'#( z
;
> ;=
'##( w > J
*o answer the ,uestion,
a( 1ither # or ## is sufficient
b( %oth # and ## are sufficient but neither of them is alone sufficient
c( # U ## are sufficient
d( %oth are not sufficient
<D. A speaks truth F@W of the timeX % speaks truth D@W of the time. Ehat is the probability that both are
contradicting each other`
<J. #n a family F children donTt eat spinach, ? donTt eat carrot, = donTt eat beans, A donTt eat spinach U
carrots, B donTt eat carrot U beans, ; donTt eat beans U spinach. One doesnTt eat all B. .ind the no. of
children.
;@. Anna, %ena, Catherina and Diana are at their monthly business meeting. *heir occupations are author,
biologist, chemist 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 from the doctor and ne2t
to the chemist. *he doctor was thinking that %ena was a good name for parentTs to choose, but didnTt say
anything. Ehat is each personTs occupation`
<@;
9!#G Concepts
S1C*#O! 6 #
.#-1 A!A"11!* #! 9!#G
1. )ow are devices represented in Q&+Z?
All devices are represented by files called special files that are located inLdev directory. *hus,
device files and other files are named and accessed in the same way. A Tregular fileT is :ust an ordinary data file
in the disk. A Tblock special fileT represents a device with characteristics similar to a disk 'data transfer in terms
of blocks(. A Tcharacter special fileT represents a device with characteristics similar to a keyboard 'data transfer
is by stream of bits in se,uential order(.
2. What is WinodeW?
All 9!#G files have its description stored in a structure called TinodeT. *he inode contains info about the
file6size, its location, time of last access, time of last modification, permission and so on. Directories are also
represented as files and have an associated inode. #n addition to descriptions about the file, the inode contains
pointers to the data blocks of the file. #f the file is large, inode has indirect pointer to a block of pointers to
additional data blocks 'this further aggregates for larger files(. A block is typically Dk.
#node consists of the following fields4
.ile owner identifier
.ile type
.ile access permissions
.ile access times
!umber of links
.ile size
-ocation of the file data
3. "rief a.out the directory representation in Q&+Z
A 9ni2 directory is a file containing a correspondence between filenames and inodes. A directory is a
special file that the kernel maintains. Only kernel modifies directories, but processes can read directories. *he
contents of a directory are a list of filename and inode number pairs. Ehen new directories are created, kernel
makes two entries named T.T 'refers to the directory itself( and T..T 'refers to parent directory(.
System call for creating directory is mkdir 'pathname, mode(.
*. What are the Qnix system calls for +GE?
open'pathname,flag,mode( 6 open file
creat'pathname,mode( 6 create file
close'filedes( 6 close an open file
read'filedes,buffer,bytes( 6 read data from an open file
write'filedes,buffer,bytes( 6 write data to an open file
lseek'filedes,offset,from( 6 position an open file
dup'filedes( 6 duplicate an e2isting file descriptor
<@B
UNIX Concepts

dup;'oldfd,newfd( 6 duplicate to a desired file descriptor
fcntl'filedes,cmd,arg( 6 change properties of an open file
ioctl'filedes,re,uest,arg( 6 change the behaviour of an open file
*he difference between fcntl anf ioctl is that the former is intended for any open file, while the latter is for
device6specific operations.
-. )ow do you change <ile 6ccess >ermissions?
1very file has following attributes4
ownerTs user #D ' <? bit integer (
ownerTs group #D ' <? bit integer (
.ile access mode word
Tr w 2 6r w 26 r w 2T
'user permission6group permission6others permission(
r6read, w6write, 26e2ecute
*o change the access mode, we use chmod'filename,mode(.
12ample <4
*o change mode of myfile to Trw6rw6r66T 'ie. read, write permission for user 6 read,write permission for
group 6 only read permission for others( we give the args as4
chmod'myfile,@??A( .
1ach operation is represented by discrete values
TrT is A
TwT is ;
T2T is <
*herefore, for TrwT the value is ?'A8;(.
12ample ;4
*o change mode of myfile to Trw2r66r66T we give the args as4
chmod'myfile,@FAA(.
0. What are lin's and sym.olic lin's in Q&+Z file system?
A link is a second name 'not a file( for a file. -inks can be used to assign more than one name to a file,
but cannot be used to assign a directory more than one name or link filenames on different computers.
Symbolic link TisT a file that only contains the name of another file.Operation on the symbolic link is
directed to the file pointed by the it.%oth the limitations of links are eliminated in symbolic links.
Commands for linking files are4
-ink ln filename< filename;
Symbolic link ln 6s filename< filename;
5. What is a <+<E?
.#.O are otherwise called as Tnamed pipesT. .#.O 'first6in6first6out( is a special file which is said to be
data transient. Once data is read from named pipe, it cannot be read again. Also, data can be read only in the
order written. #t is used in interprocess communication where a process writes to one end of the pipe 'producer(
and the other reads from the other end 'consumer(.
7. )ow do you create special files li'e named pipes and device files?
*he system call mknod creates special files in the following se,uence.
<. kernel assigns new inode,
;. sets the file type to indicate that the file is a pipe, directory or special file,
B. #f it is a device file, it makes the other entries like ma:or, minor device numbers.
.or e2ample4
#f the device is a disk, ma:or device number refers to the disk controller and minor device number is the <@A
disk.

?. !iscuss the mount and unmount system calls
*he privileged mount system call is used to attach a file system to a directory of another file systemX the
unmount system call detaches a file system. Ehen you mount another file system on to your directory, you are
essentially splicing one directory tree onto a branch in another directory tree. *he first argument to mount call is
the mount point, that is , a directory in the current file naming system. *he second argument is the file system to
mount to that point. Ehen you insert a cdrom to your uni2 systemTs drive, the file system in the cdrom
automatically mounts to LdevLcdrom in your system.
1@. )ow does the inode map to data .loc' of a file?
#node has <B block addresses. *he first <@ are direct block addresses of the first <@ data blocks in the
file. *he <<th address points to a one6level inde2 block. *he <;th address points to a two6level 'double in6
direction( inde2 block. *he <Bth address points to a three6level'triple in6direction(inde2 block. *his provides a
very large ma2imum file size with efficient access to large files, but also small files are accessed directly in one
disk read.
11. What is a shell?
A shell is an interactive user interface to an operating system services that allows an user to enter commands as
character strings or through a graphical user interface. *he shell converts them to system calls to the OS or forks
off a process to e2ecute the command. System call results and other information from the OS are presented to
the user through an interactive interface. Commonly used shells are sh,csh,ks etc.
S1C*#O! 6 ##
3$OC1SS OD1- and #3C
1. "rief a.out the initial process se/uence while the system .oots up.
Ehile booting, special process called the TswapperT or TschedulerT is created with 3rocess6#D @. *he
swapper manages memory allocation for processes and influences C39 allocation. *he swapper inturn creates B
children4
the process dispatcher,
vhand and
dbflush
with #Ds <,; and B respectively.
*his is done by e2ecuting the file LetcLinit. 3rocess dispatcher gives birth to the shell. 9ni2 keeps track
of all the processes in an internal data structure called the 3rocess *able 'listing command is ps 6el(.
2. What are various +!s associated with a process?
9ni2 identifies each process with a uni,ue integer called 3rocess#D. *he process that e2ecutes the
re,uest for creation of a process is called the Tparent processT whose 3#D is T3arent 3rocess #DT. 1very process is
associated with a particular user called the TownerT who has privileges over the process. *he identification for
the user is T9ser#DT. Owner is the user who e2ecutes the process. 3rocess also has T1ffective 9ser #DT which
determines the access privileges for accessing resources like files.
getpid'( 6process id
getppid'( 6parent process id
getuid'( 6user id
geteuid'( 6effective user id
3. 1xplain for'24 system call.
*he efork'(T used to create a new process from an e2isting process. *he new process is called the child
process, and the e2isting process is called the parent. Ee can tell which is which by checking the return value
<@=
from efork'(T. *he parent gets the childTs pid returned to him, but the child gets @ returned to him.
*. >redict the output of the following program code
main'(
]
fork'(X
printf'N)ello EorldSN(X
^
Answer:
)ello EorldS)ello EorldS
Explanation4
*he fork creates a child that is a duplicate of the parent process. *he child begins from the fork'(.All the
statements after the call to fork'( will be e2ecuted twice.'once by the parent process and other by child(. *he
statement before fork'( is e2ecuted only by the parent process.
-. >redict the output of the following program code
main'(
]
fork'(X fork'(X fork'(X
printf'N)ello EorldSN(X
^
Answer:
N)ello EorldN will be printed D times.
Explanation4
;5n times where n is the number of calls to fork'(
0. List the system calls used for process management:
S'stem *&lls Des*ription
fork'( *o create a new process
e2ec'( *o e2ecute a new program in a process
wait'( *o wait until a created process completes its e2ecution
e2it'( *o e2it from a process e2ecution
getpid'( *o get a process identifier of the current process
getppid'( *o get parent process identifier
nice'( *o bias the e2isting priority of a process
brk'( *o increaseLdecrease the data segment size of a process
5. )ow can you getGset an environment varia.le from a program?
"etting the value of an environment variable is done by using egetenv'(T.
Setting the value of an environment variable is done by using eputenv'(T.
7. )ow can a parent and child process communicate?
A parent and child can communicate through any of the normal inter6process communication schemes
'pipes, sockets, message ,ueues, shared memory(, but also have some special ways to communicate that take
advantage of their relationship as a parent and child. One of the most obvious is that the parent can get the e2it
status of the child.
?. What is a Com.ie?
Ehen a program forks and the child finishes before the parent, the kernel still keeps some of its
information about the child in case the parent might need it 6 for e2ample, the parent may need to check the
childTs e2it status. *o be able to get this information, the parent calls ewait'(TX #n the interval between the child
<@?
terminating and the parent calling ewait'(T, the child is said to be a ezombieT '#f 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 e2ecutes it changes state according to its circumstances. 9ni2 processes have the following
states4
$unning 4 *he process is either running or it is ready to run .
Eaiting 4 *he process is waiting for an event or for a resource.
Stopped 4 *he process has been stopped, usually by receiving a signal.
fombie 4 *he process is dead but have not been removed from the process table.
11. What )appens when you execute a program?
Ehen you e2ecute a program on your 9!#G system, the system creates a special environment for that
program. *his environment contains everything needed for the system to run the program as if no other program
were running on the system. 1ach process has process conte2t, which is everything that is uni,ue about the state
of the program you are currently running. 1very time you e2ecute a program the 9!#G system does a fork,
which performs a series of operations to create a process conte2t and then e2ecute your program in that conte2t.
*he steps include the following4
Allocate a slot in the process table, a list of currently running programs kept by 9!#G.
Assign a uni,ue process identifier '3#D( to the process.
iCopy the conte2t of the parent, the process that re,uested the spawning of the new process.
$eturn the new 3#D to the parent process. *his enables the parent process to e2amine or control the process
directly.
After the fork is complete, 9!#G runs your program.
12. What )appens when you execute a command?
Ehen you enter TlsT command to look at the contents of your current working directory, 9!#G does a
series of things to create an environment for ls and the run it4 *he shell has 9!#G perform a fork. *his creates a
new process that the shell will use to run the ls program. *he shell has 9!#G perform an e2ec of the ls program.
*his replaces the shell program and data with the program and data for ls and then starts running that new
program. *he ls program is loaded into the new process conte2t, replacing the te2t and data of the shell. *he ls
program performs its task, listing the contents of the current directory.
13. What is a !aemon?
A daemon is a process that detaches itself from the terminal and runs, disconnected, in the background,
waiting for re,uests and responding to them. #t can also be defined as the background process that does not
belong to a terminal session. any system functions are commonly performed by daemons, including the
sendmail daemon, which handles mail, and the !!*3 daemon, which handles 9S1!1* news. any other
daemons may e2ist. Some of the most common daemons are4
init4 *akes over the basic running of the system when the kernel has finished the boot process.
inetd4 $esponsible for starting network services that do not have their own stand6alone daemons. .or
e2ample, inetd usually takes care of incoming rlogin, telnet, and ftp connections.
cron4 $esponsible for running repetitive tasks on a regular schedule.
1*. What is WpsW command for?
*he ps command prints the process status for some or all of the running processes. *he information
given are the process identification number '3#D(,the amount of time that the process has taken to e2ecute so far
etc.
1-. )ow would you 'ill a process?
<@F
*he kill command takes the 3#D as one argumentX this identifies which process to terminate. *he 3#D of
a process can be got using TpsT command.
10. What is an advantage of executing a process in .ac'ground?
*he most common reason to put a process in the background is to allow you to do something else
interactively without waiting for the process to complete. At the end of the command you add the special
background symbol, U. *his symbol tells your shell to e2ecute the given command in the background.
12ample4 cp 7.7 ..LbackupU 'cp is for copy(
15. )ow do you execute one program from within another?
*he system calls used for low6level process creation are e2eclp'( and e2ecvp'(. *he e2eclp call overlays
the e2isting program with the new one , runs that and e2its. *he original program gets back control only when
an error occurs.
e2eclp'path,fileKname,arguments..(X LLlast argument must be !9--
A variant of e2eclp called e2ecvp is used when the number of arguments is not known in advance.
e2ecvp'path,argumentKarray(X LLargument array should be terminated by !9--
17. What is +>,? What are the various schemes availa.le?
*he term #3C '#nter63rocess Communication( describes various ways by which different process
running on some operating system communicate between each other. +arious schemes available are as follows4
>ipes:
One6way communication scheme through which different process can communicate. *he
problem is that the two processes should have a common ancestor 'parent6child relationship(. )owever
this problem was fi2ed with the introduction of named6pipes '.#.O(.
#essage Aueues :
essage ,ueues can be used between related and unrelated processes running on a machine.
$hared #emory:
*his is the fastest of all #3C schemes. *he memory to be shared is mapped into the address space
of the processes 'that are sharing(. *he speed achieved is attributed to the fact that there is no kernel
involvement. %ut this scheme needs synchronization.
+arious forms of synchronisation are mute2es, condition6variables, read6write locks, record6locks,
and semaphores.
S1C*#O! 6 ###
1O$H A!A"11!*
1. What is the difference .etween $wapping and >aging?
$wapping:
Ehole process is moved from the swap device to the main memory for e2ecution. 3rocess size
must be less than or e,ual to the available main memory. #t is easier to implementation and overhead to the
system. Swapping systems does not handle the memory more fle2ibly as compared to the paging systems.
>aging:
Only the re,uired memory pages are moved to main memory from the swap device for
e2ecution. 3rocess size does not matter. "ives the concept of the virtual memory.
#t provides greater fle2ibility in mapping the virtual address space into the physical memory of the
machine. Allows more number of processes to fit in the main memory simultaneously. Allows the greater
process size than the available physical memory. Demand paging systems handle the memory more fle2ibly.
<@D
2. What is major difference .etween the )istoric Qnix and the new "$! release of Qnix $ystem B in terms of
#emory #anagement?
)istoric 9ni2 uses Swapping & entire process is transferred to the main memory from the swap device,
whereas the 9ni2 System + uses Demand 3aging & only the part of the process is moved to the main memory.
)istoric 9ni2 uses one Swap Device and 9ni2 System + allow multiple Swap Devices.
3. What is the main goal of the #emory #anagement?
#t decides which process should reside in the main memory,
anages the parts of the virtual address space of a process which is non6core resident,
onitors the available main memory and periodically write the processes into the swap device to provide
more processes fit in the main memory simultaneously.
*. 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 number of the resource units available there.
*his allows .irst6.it allocation of contiguous blocks of a resource. #nitially the ap contains one entry &
address 'block offset from the starting of the swap area( and the total number of resources.
_ernel treats each unit of ap as a group of disk blocks. On the allocation and freeing of the resources
_ernel updates the ap for accurate information.
-. What scheme does the [ernel in Qnix $ystem B follow while choosing a swap device among the multiple
swap devices?
_ernel follows $ound $obin scheme choosing a swap device among the multiple swap devices in 9ni2
System +.
0. What is a egion?
A $egion is a continuous area of a process0s address space 'such as te2t, data and stack(. *he kernel in a
/$egion *able0 that is local to the process maintains region. $egions are sharable among the process.
5. What are the events done .y the [ernel after a process is .eing swapped out from the main memory?
Ehen _ernel swaps the process out of the primary memory, it performs the following4
_ernel decrements the $eference Count of each region of the process. #f the reference count
becomes zero, swaps the region out of the main memory,
_ernel allocates the space for the swapping process in the swap device,
_ernel locks the other swapping process while the current swapping operation is going on,
*he _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.
3rocess before swapping is residing in the primary memory in its original form. *he regions 'te2t, data
and stack( may not be occupied fully by the process, there may be few empty slots in any of the regions and
while swapping _ernel do not bother about the empty slots while swapping the process out.
After swapping the process resides in the swap 'secondary memory( device. *he regions swapped out
will be present but only the occupied region slots but not the empty slots that were present before assigning.
Ehile swapping the process once again into the main memory, the _ernel referring to the 3rocess
emory ap, it assigns the main memory accordingly taking care of the empty slots in the regions.
<@J
< <@,@@@
Address 9nits
?. What do you mean .y u3area 2user area4 or u3.loc'?
*his contains the private data that is manipulated only by the _ernel. *his is local to the 3rocess, i.e.
each process is allocated a u6area.
1@. What are the entities that are swapped out of the main memory while swapping the process out of the main
memory?
All memory space occupied by the process, process0s u6area, and _ernel stack are swapped out,
theoretically.
3ractically, if the process0s u6area contains the Address *ranslation *ables for the process then _ernel
implementations do not swap the u6area.
11. What is <or' swap?
fork'( is a system call to create a child process. Ehen the parent process calls fork'( system call, the
child process is created and if there is short of memory then the child process is sent to the read6to6run state in
the swap device, and return to the user state without swapping the parent process. Ehen the memory will be
available the child process will be swapped into the main memory.
12. What is 1xpansion swap?
At the time when any process re,uires more memory than it is currently allocated, the _ernel performs
12pansion swap. *o do this _ernel reserves enough space in the swap device. *hen the address translation
mapping is ad:usted for the new virtual address space but the physical memory is not allocated. At last _ernel
swaps the process into the assigned space in the swap device. -ater when the _ernel swaps the process into the
main memory this assigns memory according to the new address translation mapping.
13. )ow the $wapper wor's?
*he swapper is the only process that swaps the processes. *he Swapper operates only in the _ernel
mode and it does not uses System calls instead it uses internal _ernel functions for swapping. #t is the archetype
of all kernel process.
1*. What are the processes that are not .othered .y the swapper? =ive eason.
fombie process4 *hey do not take any up physical memory.
3rocesses locked in memories that are updating the region of the process.
_ernel swaps only the sleeping processes rather than the /ready6to6run0 processes, as they have the
higher probability of being scheduled than the Sleeping processes.
1-. What are the re/uirements for a swapper to wor'?
*he swapper works on the highest scheduling priority. .irstly it will look for any sleeping process, if not
found then it will look for the ready6to6run process for swapping. %ut the ma:or re,uirement for the swapper to
work the ready6to6run process must be core6resident for at least ; seconds before swapping out. And for
swapping in the process must have been resided in the swap device for at least ; seconds. #f the re,uirement is
not satisfied then the swapper will go into the wait state on that event and it is awaken once in a second by the
_ernel.
10. What are the criteria for choosing a process for swapping into memory from the swap device?
*he resident time of the processes in the swap device, the priority of the processes and the amount of
time 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?
*he process0s memory resident time,
<<@
3riority of the process and
*he nice value.
17. What do you mean .y nice value?
!ice value is the value that controls ]increments or decrements^ the priority of the process. *his value
that is returned by the nice '( system call. *he e,uation for using nice value is4
>riority I 2\recent ,>Q usage]Gconstant4 8 2.ase3 priority4 8 2nice value4
Only the administrator can supply the nice value. *he nice '( system call works 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 main memory are asleep.
All /ready6to6run0 processes are swapped out.
*here is no space in the swap device for the new incoming process that are swapped out of the main
memory.
*here is no space in the main memory for the new incoming process.
2@. What are conditions for a machine to support !emand >aging?
emory architecture must based on 3ages,
*he machine must support the /restartable0 instructions.
21. What is Xthe principle of localityF?
#t0s the nature of the processes that they refer only to the small subset of the total data space of the
process. i.e. the process fre,uently calls the same subroutines or e2ecutes the loop instructions.
22. What is the wor'ing set of a process?
*he set of pages that are referred by the process in the last /n0, references, where /n0 is called the
window of the working set of the process.
23. What is the window of the wor'ing set of a process?
*he window of the working set of a process is the total number in which the process had referred the set
of pages in the working set of the process.
2*. What is called a page fault?
3age fault is referred to the situation when the process addresses a page in the working set of the process
but the process fails to locate the page in the working set. And on a page fault the kernel updates the working set
by reading the page from the secondary device.
2-. What are data structures that are used for !emand >aging?
_ernel contains A data structures for Demand paging. *hey are,
3age table entries,
Disk block descriptors,
3age frame data table 'pfdata(,
Swap6use table.

20. What are the .its that support the demand paging?
+alid, $eference, odify, Copy on write, Age. *hese bits are the part of the page table entry, which
includes physical address of the page and protection bits.
<<<
3age address
Age Copy on write odify $eference +alid 3rotection
25. )ow the [ernel handles the for'24 system call in traditional Qnix and in the $ystem B Qnix% while
swapping?
_ernel in traditional 9ni2, makes the duplicate copy of the parent0s address space and attaches it to the
child0s process, while swapping. _ernel in System + 9ni2, manipulates the region tables, page table, and pfdata
table entries, by incrementing the reference count of the region table of shared regions.
27. !ifference .etween the for'24 and vfor'24 system call?
During the fork'( system call the _ernel makes a copy of the parent process0s address space and attaches
it to the child process.
%ut the vfork'( system call do not makes any copy of the parent0s address space, so it is faster than the
fork'( system call. *he child process as a result of the vfork'( system call e2ecutes e2ec'( system call. *he child
process from vfork'( system call e2ecutes in the parent0s address space 'this can overwrite the parent0s data and
stack ( which suspends the parent process until the child process e2its.
2?. What is "$$2"loc' $tarted .y $ym.ol4?
A data representation at the machine level, that has initial values when a program starts and tells about
how much space the kernel allocates for the un6initialized data. _ernel initializes it to zero at run6time.
3@. What is >age3$tealer process?
*his is the _ernel process that makes rooms for the incoming pages, by swapping the memory pages
that are not the part of the working set of a process. 3age6Stealer is created by the _ernel at the system
initialization and invokes it throughout the lifetime of the system. _ernel locks 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?
*he two paging states are4
*he page is aging and is not yet eligible for swapping,
*he page is eligible for swapping but not yet eligible for reassignment to other virtual address space.
32. What are the phases of swapping a page from the memory?
3age stealer finds the page eligible for swapping and places the page number 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, decrements the pfdata reference count, and places the pfdata table entry at the end of the free
list if its reference count is @.
33. What is page fault? +ts types?
3age fault refers to the situation of not having a page in the main memory when any process references
it.
*here are two types of page fault 4
+alidity fault,
3rotection fault.
3*. +n what way the <ault )andlers and the +nterrupt handlers are different?
.ault handlers are also an interrupt handler with an e2ception that the interrupt handlers cannot sleep.
.ault handlers sleep in the conte2t of the process that caused the memory fault. *he fault refers to the running
process and no arbitrary processes are put to sleep.
<<;
3-. What is validity fault?
#f a process referring a page in the main memory whose valid bit is not set, it results in validity fault.
*he valid bit is not set for those pages4
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.
B?. What does the swapping system do if it identifies the illegal page for swapping?
#f the disk block descriptor does not contain any record of the faulted page, then this causes the
attempted memory reference is invalid and the kernel sends a \$egmentation violation] signal to the offending
process. *his happens when the swapping system identifies any invalid memory reference.
35. What are states that the page can .e in% after causing a page fault?
On a swap device and not in memory,
On the free page list in the main memory,
#n an e2ecutable file,
arked [demand zero\,
arked [demand fill\.
37. +n what way the validity fault handler concludes?
#t sets the valid bit of the page by clearing the modify bit.
#t recalculates the process priority.
3?. 6t what mode the fault handler executes?
At the _ernel ode.
*@. What do you mean .y the protection fault?
3rotection fault refers to the process accessing the pages, which do not have the access permission. A
process also incur the protection fault when it attempts to write a page whose copy on write bit was set during
the fork'( system call.
*1. )ow the [ernel handles the copy on write .it of a page% when the .it is set?
#n situations like, where the copy on write bit of a page is set and that page is shared by more 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
number. *hen _ernel decrements the reference count of the old pfdata table entry.
#n cases like, 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 from its disk copy 'if one e2ists(, because other process may share the disk copy. *hen it removes the
pfdata table entry from the page6,ueue as the new copy of the virtual page is not on the swap device. #t
decrements the swap6use count for the page and if count drops to @, frees the swap space.
*2. <or which 'ind of fault the page is chec'ed first?
*he page is first checked for the validity fault, as soon as it is found that the page is invalid 'valid bit is
clear(, the validity fault handler returns immediately, 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 e2ecution of the fault handler, it sets the modify and protection bits and clears the
copy on write bit. #t recalculates the process6priority and checks for signals.
<<B
**. )ow the [ernel handles .oth the page stealer and the fault handler?
*he page stealer and the fault handler thrash because of the shortage of the memory. #f the sum of the
working sets of all processes is greater that the physical memory then the fault handler will usually sleep
because it cannot allocate pages for a process. *his results in the reduction of the system throughput because
_ernel spends too much time in overhead, rearranging the memory in the frantic pace.
<<A
$D%S Concepts
1. What is data.ase?
A database is a logically coherent collection of data with some inherent meaning, representing some
aspect of real world and which is designed, built and populated with data for a specific purpose.
2. What is !"#$?
#t is a collection of programs that enables user to create and maintain a database. #n other words it is
general6purpose 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?
*he database and D%S software together is called as Database system.
*. 6dvantages of !"#$?
$edundancy is controlled.
9nauthorised access is restricted.
3roviding multiple user interfaces.
1nforcing integrity constraints.
3roviding backup 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 3roblems.
0. !escri.e the three levels of data a.straction?
*he are three levels of abstraction4
>hysical level: *he lowest level of abstraction describes how data are stored.
Logical level: *he ne2t higher level of abstraction, describes what data are stored in database and what
relationship among those data.
Biew level: *he highest level of abstraction describes only part of entire database.
5. !efine the Kintegrity rulesK
*here are two #ntegrity rules.
1ntity +ntegrity: States that [3rimary key cannot have !9-- value\
eferential +ntegrity: States that [.oreign _ey can be either a !9-- value or should be 3rimary
_ey value of other relation.
<<=
RDBMS Concepts

7. What is extension and intension?
1xtension 6
#t is the number of tuples present in a table at any instance. *his is time dependent.
+ntension 6
#t is a constant value that gives the name, structure of table and the constraints laid on it.
?. What is $ystem ? What are its two major su.systems?
System $ was designed and developed over a period of <JFA6FJ at #% San Cose $esearch Center. #t is
a prototype and its purpose was to demonstrate that it is possible to build a $elational System that can be used
in a real life environment to solve real life problems, with performance at least comparable to that of e2isting
system.
#ts two subsystems are
$esearch Storage
System $elational Data System.
1@. )ow is the data structure of $ystem different from the relational structure?
9nlike $elational systems in System $
Domains are not supported
1nforcement of candidate key uni,ueness is optional
1nforcement of entity integrity is optional
$eferential integrity is not enforced
11. What is !ata +ndependence?
Data independence means that [the application is independent of the storage structure and access
strategy of data\. #n other words, *he ability to modify the schema definition in one level should not affect the
schema definition in the ne2t higher level.
*wo types of Data #ndependence4
3hysical Data #ndependence4 odification in physical level should not affect the logical level.
-ogical Data #ndependence4 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?
A view may be thought of as a virtual table, that is, a table that does not really e2ist in its own right but
is instead derived from one or more underlying base table. #n 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. *hus the view can insulate users from
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 semantics and constraints.
1*. What is 13 model?
*his data model is based on real world that consists of basic ob:ects called entities and of relationship
among these ob:ects. 1ntities are described in a database by a set of attributes.
1-. What is E.ject Eriented model?
*his model 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. *hese bodies of code are called
methods. Ob:ects that contain same types of values and the same methods are grouped together into classes.
<<?
10. What is an 1ntity?
#t is a TthingT in the real world with an independent e2istence.
15. What is an 1ntity type?
#t is a collection 'set( of entities that have same attributes.
17. What is an 1ntity set?
#t is a collection of all entities of particular entity type in the database.
1?. What is an 1xtension of entity type?
*he collections of entities of a particular entity type are grouped together into an entity set.
2@. What is Wea' 1ntity set?
An entity set may not have sufficient attributes to form a primary key, and its primary key compromises
of its partial key and primary key of its parent entity, then it is said to be Eeak 1ntity set.
21. What is an attri.ute?
#t is a particular property, which describes the entity.
22. What is a elation $chema and a elation?
A relation Schema denoted by $'A<, A;, I, An( is made up of the relation name $ and the list of
attributes Ai that it contains. A relation is defined as a set of tuples. -et r be the relation which contains set
tuples 't<, t;, tB, ..., tn(. 1ach tuple is an ordered list of n6values t>'v<,v;, ..., vn(.
23. What is degree of a elation?
#t is the number of attribute of its relation schema.
2*. What is elationship?
#t is an association among two or more entities.
2-. What is elationship set?
*he collection 'or set( of similar relationships.
20. What is elationship type?
$elationship type defines a set of associations or a relationship set among a given set of entity types.

25. What is degree of elationship type?
#t is the number of entity type participating.
2-. What is !!L 2!ata !efinition Language4?
A data base schema is specifies by a set of definitions e2pressed by a special language called DD-.
20. What is B!L 2Biew !efinition Language4?
#t specifies user views and their mappings to the conceptual schema.
25. What is $!L 2$torage !efinition Language4?
*his language is to specify the internal schema. *his language may specify the mapping between two
schemas.
27. What is !ata $torage 3 !efinition Language?
<<F
*he storage structures and access methods used by database system are specified by a set of definition in
a special type of DD- called data storage6definition language.
2?. What is !#L 2!ata #anipulation Language4?
*his language that enable user to access or manipulate data as organised by appropriate data model.
>rocedural !#L or Low level: D- re,uires a user to specify what data are needed and how to get those
data.
&on3>rocedural !#L or )igh level: D- re,uires a user to specify what data are needed without
specifying how to get those data.
31. What is !#L ,ompiler?
#t translates D- statements in a ,uery language into low6level instruction that the ,uery evaluation
engine can understand.
32. What is Auery evaluation engine?
#t e2ecutes low6level instruction generated by compiler.
33. What is !!L +nterpreter?
#t interprets DD- statements and record them in tables containing metadata.
3*. What is ecord3at3a3time?
*he -ow level or 3rocedural D- can specify and retrieve each record from a set of records. *his
retrieve of a record is said to be $ecord6at6a6time.
3-. What is $et3at3a3time or $et3oriented?
*he )igh level or !on6procedural D- can specify and retrieve many records in a single D-
statement. *his retrieve of a record is said to be Set6at6a6time or Set6oriented.
30. What is elational 6lge.ra?
#t is procedural ,uery language. #t consists of a set of operations that take one or two relations as input
and produce a new relation.
35. What is elational ,alculus?
#t is an applied predicate calculus specifically tailored for relational databases proposed by 1... Codd.
1.g. of languages based on it are DS- A-3)A, M91-.
38. )ow does Duple3oriented relational calculus differ from domain3oriented relational calculus
*he tuple6oriented calculus uses a tuple variables i.e., variable whose only permitted values are tuples of
that relation. 1.g. M91-
*he domain6oriented calculus has domain variables i.e., variables that range over the underlying domains
instead of over relation. 1.g. #--, D1D9C1.
3?. What is normaliCation?
#t is a process of analysing the given relation schemas based on their .unctional Dependencies '.Ds(
and primary key to achieve the properties
inimizing redundancy
inimizing insertion, deletion and update anomalies.
*@. What is <unctional !ependency?
<<D
A .unctional dependency is denoted by G H between two sets of attributes G and H that are subsets of
$ specifies a constraint on the possible tuple that can form a relation state r of $. *he constraint is for any two
tuples t< and t; in r if t<OGP > t;OGP then they have t<OHP > t;OHP. *his means the value of G component of a
tuple uni,uely determines the value of component H.
*1. When is a functional dependency < said to .e minimal?
1very dependency in . has a single attribute for its right hand side.
Ee cannot replace any dependency G A in . with a dependency H A where H is a proper subset of G and
still have a set of dependency that is e,uivalent to ..
Ee cannot remove any dependency from . and still have set of dependency that is e,uivalent to ..
*2. What is #ultivalued dependency?
ultivalued dependency denoted by G H specified on relation schema $, where G and H are both
subsets of $, specifies the following constraint on any relation r of $4 if two tuples t< and t; e2ist in r such that
t<OGP > t;OGP then tB and tA should also e2ist in r with the following properties
tBO2P > tAOGP > t<OGP > t;OGP
tBOHP > t<OHP and tAOHP > t;OHP
tBOfP > t;OfP and tAOfP > t<OfP
where Of > '$6'G 9 H(( P

*3. What is Lossless join property?
#t guarantees that the spurious tuple generation does not occur with respect to relation schemas after
decomposition.
**. What is 1 &< 2&ormal <orm4?
*he domain of attribute must include only atomic 'simple, indivisible( values.
*-. What is <ully <unctional dependency?
#t is based on concept of full functional dependency. A functional dependency G H is full functional
dependency if removal of any attribute A from G means that the dependency does not hold any more.
*0. What is 2&<?
A relation schema $ is in ;!. if it is in <!. and every non6prime attribute A in $ is fully functionally
dependent on primary key.
*5. What is 3&<?
A relation schema $ is in B!. if it is in ;!. and for every .D G A either of the following is true
G is a Super6key of $.
A is a prime attribute of $.
#n other words, if every non prime attribute is non6transitively dependent on primary key.
*7. What is ",&< 2"oyce3,odd &ormal <orm4?
A relation schema $ is in %C!. if it is in B!. and satisfies an additional constraint that for every .D G
A, G must be a candidate key.

*?. What is *&<?
A relation schema $ is said to be in A!. if for every ultivalued dependency G H that holds
over $, one of following is true
G is subset or e,ual to 'or( GH > $.
G is a super key.
<<J
-@. What is -&<?
A $elation schema $ is said to be =!. if for every :oin dependency ]$<, $;, ..., $n^ that holds $, one
the following is true
$i > $ for some i.
*he :oin dependency is implied by the set of .D, over $ in which the left side is key of $.
-1. What is !omain3[ey &ormal <orm?
A relation is said to be in D_!. if all constraints and dependencies that should hold on the the
constraint can be enforced by simply enforcing the domain constraint and key constraint on the relation.

-2. What are partial% alternate%% artificial% compound and natural 'ey?
>artial [ey:
#t is a set of attributes that can uni,uely identify weak entities and that are related to same owner
entity. #t is sometime called as Discriminator.
6lternate [ey:
All Candidate _eys e2cluding the 3rimary _ey are known as Alternate _eys.
6rtificial [ey4
#f no obvious key, either stand alone or compound is available, then the last resort is to simply
create a key, by assigning a uni,ue number to each record or occurrence. *hen this is known as developing an
artificial key.
,ompound [ey:
#f no single data element uni,uely identifies occurrences within a construct, then combining
multiple elements to create a uni,ue identifier for the construct is known as creating a compound key.
&atural [ey:
Ehen one of the data elements stored within a construct is utilized as the primary key, then it is
called the natural key.
-3. What is indexing and what are the different 'inds of indexing?
#nde2ing is a techni,ue for determining how ,uickly specific data can be found.
*ypes4
%inary search style inde2ing
%6*ree inde2ing
#nverted list inde2ing
emory resident table
*able inde2ing
-*. What is system catalog or catalog relation? )ow is .etter 'nown as?
A $D%S maintains a description of all the data that it contains, information about every relation and
inde2 that it contains. *his information is stored in a collection of relations maintained by the system called
metadata. #t is also called data dictionary.
--. What is meant .y /uery optimiCation?
*he phase that identifies an efficient e2ecution plan for evaluating a ,uery that has the least estimated
cost is referred to as ,uery optimization.
-0. What is join dependency and inclusion dependency?
Yoin !ependency:
A Coin dependency is generalization of ultivalued dependency.A CD ]$<, $;, ..., $n^ is
said to hold over a relation $ if $<, $;, $B, ..., $n is a lossless6:oin decomposition of $ . *here is no set of
sound and complete inference rules for CD.
<;@
+nclusion !ependency:
An #nclusion Dependency is a statement of the form that some columns of a relation are
contained in other columns. A foreign key constraint is an e2ample of inclusion dependency.
-5. What is dura.ility in !"#$?
Once the D%S informs the user that a transaction has successfully completed, its effects should persist
even if the system crashes before all its changes are reflected on disk. *his property is called durability.
-7. What do you mean .y atomicity and aggregation?
6tomicity:
1ither all actions are carried out or none are. 9sers should not have to worry about the effect of
incomplete transactions. D%S ensures this by undoing the actions of incomplete transactions.
6ggregation:
A concept which is used to model a relationship between a collection of entities and
relationships. #t is used when we need to e2press a relationship among relationships.
-?. What is a >hantom !eadloc'?
#n distributed deadlock detection, the delay in propagating local information might cause the deadlock
detection algorithms to identify deadlocks that do not really e2ist. Such situations are called phantom deadlocks
and they lead to unnecessary aborts.
0@. What is a chec'point and When does it occur?
A Checkpoint is like a snapshot of the D%S state. %y taking checkpoints, the D%S can reduce the
amount of work to be done during restart in the event of subse,uent crashes.
01. What are the different phases of transaction?
Different phases are
Analysis phase
$edo 3hase
9ndo phase
02. What do you mean .y flat file data.ase?
#t is a database in which there are no programs or user access languages. #t has no cross6file capabilities
but is user6friendly and provides user6interface management.
03. What is Ktransparent !"#$K?
#t is one, which keeps its 3hysical Structure hidden from user.
0*. "rief theory of &etwor'% )ierarchical schemas and their properties
!etwork schema uses a graph data structure to organize records e2ample for such a database
management system is C*C" while a hierarchical schema uses a tree data structure e2ample for such a system
is #S.
0-. What is a /uery?
A ,uery with respect to D%S relates to user commands that are used to interact with a data base. *he
,uery language can be classified into data definition language and data manipulation language.
00. What do you mean .y ,orrelated su./uery?
Sub,ueries, or nested ,ueries, are used to bring back a set of rows to be used by the parent ,uery.
Depending on how the sub,uery is written, it can be e2ecuted once for the parent ,uery or it can be e2ecuted
<;<
once for each row returned by the parent ,uery. #f the sub,uery is e2ecuted for each row of the parent, this is
called a correlated su./uery.
A correlated sub,uery can be easily identified if it contains any references to the parent sub,uery
columns in its E)1$1 clause. Columns from the sub,uery cannot be referenced anywhere else in the parent
,uery. *he following e2ample demonstrates a non6correlated sub,uery.
1.g. Select 7 .rom C9S* Ehere T<@L@BL<JJ@T #! 'Select ODA*1 .rom O$D1$ Ehere C9S*.C!9 >
O$D1$.C!9(
05. What are the primitive operations common to all record management systems?
Addition, deletion and modification.
07. &ame the .uffer in which all the commands that are typed in are stored
<=%it$ %uffer
0?. What are the unary operations in elational 6lge.ra?
3$OC1C*#O! and S1-1C*#O!.
5@. 6re the resulting relations of >E!Q,D and YE+& operation the same?
!o.
>E!Q,D4 Concatenation of every row in one relation with every row in another.
YE+&4 Concatenation of rows from one relation and related rows from another.
51. What is !"#$ [1&1L?
*wo important pieces of $D%S architecture are the kernel, which is the software, and the data
dictionary, which consists of the system6level data structures used by the kernel to manage the database
Hou might think of an $D%S as an operating system 'or set of subsystems(, designed specifically for
controlling data accessX its primary functions are storing, retrieving, and securing data. An $D%S maintains
its own list of authorized users and their associated privilegesX manages memory caches and pagingX controls
locking for concurrent resource usageX dispatches and schedules user re,uestsX and manages space usage within
its table6space structures
.
52. &ame the su.3systems of a !"#$
#LO, Security, -anguage 3rocessing, 3rocess Control, Storage anagement, -ogging and $ecovery,
Distribution Control, *ransaction Control, emory anagement, -ock anagement
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
maintained e2clusively by the kernel.
5*. What is the jo. of the information stored in data3dictionary?
*he information in the data dictionary validates the e2istence of the ob:ects, provides access to them,
and maps the actual physical storage location.
5-. &ot only !"#$ ta'es care of locating data it also
determines an optimal access path to store or retrieve the data
50. )ow do you communicate with an !"#$?
Hou communicate with an $D%S using Structured Muery -anguage 'SM-(
55. !efine $AL and state the differences .etween $AL and other conventional programming Languages
<;;
SM- is a nonprocedural language that is designed specifically for data access operations on normalized
relational database structures. *he primary difference between SM- and other conventional programming
languages is that SM- statements specify what data operations should be performed rather than how to perform
them.
57. &ame the three major set of files on dis' that compose a data.ase in Eracle
*here are three ma:or sets of files on disk that compose a database. All the files are binary. *hese are
Database files
Control files
$edo logs
*he most important of these are the database files where the actual data resides. *he control files and the
redo logs support the functioning of the architecture itself.
All three sets of files must be present, open, and available to Oracle for any data on the database to be
useable. Eithout these files, you cannot access the database, and the database administrator might have to
recover some or all of the database using a backup, if there is one.
5?. What is an Eracle +nstance?
*he Oracle system processes, also known as Oracle background processes, provide functions for the
user processesgfunctions that would otherwise be done by the user processes themselves
Oracle database6wide system memory is known as the S"A, the system glo.al area or shared glo.al
area. *he data and control structures in the S"A are shareable, and all the Oracle background processes and
user processes can use them.
*he combination of the S"A and the Oracle background processes is known 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
*he four Oracle system processes that must always be up and running for the database to be useable
include !"W 'Database Eriter(, L=W '-og Eriter(, $#E& 'System onitor(, and >#E& '3rocess
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
*he database files hold the actual data and are typically the largest in size. Depending on their
sizes, 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 make the database structure very fle2ible for controlling access to storage for
different users, putting the database on different disk drives, or backing up and restoring :ust part of the
database.
Hou must have at least one database file but usually, more than one files are used. #n terms of
accessing and using the data in the tables and other ob:ects, the number 'or location( of the files is immaterial.
*he database files are fi2ed in size and never grow bigger than the size at which they were
created
,ontrol <iles
*he control files and redo logs support the rest of the architecture. Any database must have at
least one control file, although you typically have more than one to guard against loss. *he control file records
the name of the database, the date and time it was created, the location of the database and redo logs, and the
synchronization information to ensure that all three sets of files are always in step. 1very time you add a new
database or redo log file to the database, the information is recorded in the control files.
edo Logs
Any database must have at least two redo logs. *hese are the :ournals for the databaseX the redo
logs record all changes to the user ob:ects or system ob:ects. #f any type of failure occurs, the changes recorded
<;B
in the redo logs can be used to bring the database to a consistent state without losing any committed
transactions. #n the case of non6data loss failure, Oracle can apply the information in the redo logs automatically
without intervention from the D%A.
*he redo log files are fi2ed in size and never grow dynamically from the size at which they were
created.
72. What is EW+!?
*he $OE#D is a uni,ue database6wide physical address for every row on every table. Once assigned
'when the row is first inserted into the database(, it never changes until the row is deleted or the table is
dropped.
*he $OE#D consists of the following three components, the combination of which uni,uely identifies
the physical storage location of the row.
Oracle database file number, which contains the block with the rows
Oracle block address, which contains the row
*he row within the block 'because each block can hold many rows(
*he $OE#D is used internally in inde2es as a ,uick means of retrieving rows with a particular key
value. Application developers also use it in SM- statements as a ,uick way to access a row once they know the
$OE#D
73. What is Eracle "loc'? ,an two Eracle "loc's have the same address?
Oracle NformatsN the database files into a number of Oracle blocks when they are first createdgmaking
it easier for the $D%S software to manage the files and easier to read data into the memory areas.
*he block size should be a multiple of the operating system block size. $egardless of the block size, the
entire block is not available for holding dataX Oracle takes up some space to manage the contents of the block.
*his block header has a minimum size, but it can grow.
*hese Oracle blocks are the smallest unit of storage. #ncreasing the Oracle block size can improve
performance, but it should be done only when the database is first created.
1ach Oracle block is numbered se,uentially for each database file starting at <. *wo blocks can have the
same block address if they are in different database files.
7*. What is data.ase Drigger?
A database trigger is a 3-LSM- block that can defined to automatically e2ecute for insert, update, and
delete statements against a table. *he trigger can e defined to e2ecute once for the entire statement or once for
every row that is inserted, updated, or deleted. .or 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 3-LSM-.
7-. &ame two utilities that Eracle provides% which are use for .ac'up and recovery.
Along with the $D%S software, Oracle provides two utilities that you can use to back up and restore
the database. *hese utilities are 1xport and +mport.
*he 1xport utility dumps the definitions and data for the specified part of the database to an operating
system binary file. *he +mport utility reads the file produced by an e2port, recreates the definitions of ob:ects,
and inserts the data
#f 12port and #mport are used as a means of backing up and recovering the database, all the changes
made to the database cannot be recovered since the e2port was performed. *he best you can do is recover the
database to the time when the e2port was last performed.
70. What are stored3procedures? 6nd what are the advantages of using them.
Stored procedures are database ob:ects that perform a user defined operation. A stored procedure can
have a set of compound SM- statements. A stored procedure e2ecutes the SM- commands and returns the result
to the client. Stored procedures are used to reduce network traffic.
<;A
75. )ow are exceptions handled in >LG$AL? =ive some of the internal exceptionsW name
3-LSM- e2ception handling is a mechanism for dealing with run6time errors encountered during
procedure e2ecution. 9se of this mechanism enables e2ecution to continue if the error is not severe enough to
cause procedure termination.
*he e2ception handler must be defined within a subprogram specification. 1rrors cause the program to
raise an e2ception with a transfer of control to the e2ception6handler block. After the e2ception handler
e2ecutes, control returns to the block in which the handler was defined. #f there are no more e2ecutable
statements in the block, control returns to the caller.
Qser3!efined 1xceptions
3-LSM- enables the user to define e2ception handlers in the declarations area of subprogram
specifications. 9ser accomplishes this by naming an e2ception as in the following e2ample4
otKfailure 1GC13*#O!X
#n this case, the e2ception name is otKfailure. Code associated with this handler is written in the 1GC13*#O!
specification area as follows4
1GC13*#O!
when O*K.A#-9$1 then
outKstatusKcode 4> gKoutKstatusKcodeX
outKmsg 4> gKoutKmsgX
*he following is an e2ample of a subprogram e2ception4
1GC13*#O!
when !OKDA*AK.O9!D then
gKoutKstatusKcode 4> T.A#-TX
$A#S1 otKfailureX
Eithin this e2ception is the $A#S1 statement that transfers control back to the otKfailure e2ception handler.
*his techni,ue of raising the e2ception is used to invoke all user6defined e2ceptions.
$ystem3!efined 1xceptions
12ceptions internal to 3-LSM- are raised automatically upon error. !OKDA*AK.O9!D is a system6
defined e2ception. *able below gives a complete list of internal e2ceptions.
>LG$AL internal exceptions.
Ex'eption Nae 3ra'le Error
C9$SO$KA-$1ADHKO31! O$A6@?=<<
D93K+A-KO!K#!D1G O$A6@@@@<
#!+A-#DKC9$SO$ O$A6@<@@<
#!+A-#DK!9%1$ O$A6@<F;;
-O"#!KD1!#1D O$A6@<@<F
!OKDA*AK.O9!D O$A6@<A@B
!O*K-O""1DKO! O$A6@<@<;
3$O"$AK1$$O$ O$A6@?=@<
S*O$A"1K1$$O$ O$A6@?=@@
*#1O9*KO!K$1SO9$C1 O$A6@@@=<
*OOKA!HK$OES O$A6@<A;;
*$A!SAC*#O!K%AC_1DKO9* O$A6@@@?<
+A-91K1$$O$ O$A6@?=@;
f1$OKD#+#D1 O$A6@<AF?
#n addition to this list of e2ceptions, there is a catch6all e2ception named ED)1$ that traps all errors
for which specific error handling has not been established.
77. !oes >LG$AL support KoverloadingK? 1xplain
<;=
*he concept of overloading in 3-LSM- relates to the idea that you can define procedures and functions
with the same name. 3-LSM- does not look only at the referenced name, however, to resolve a procedure or
function call. *he count and data types of formal parameters are also considered.
3-LSM- also attempts to resolve any procedure or function calls in locally defined packages before
looking at globally defined packages or internal functions. *o further ensure calling the proper procedure, you
can use the dot notation. 3refacing a procedure or function name with the package name fully ,ualifies any
procedure or function reference.
7?. Da.les derived from the 1!
a( Are totally unnormalised
b( Are always in <!.
c( Can be further denormalised
d( ay have multi6valued attributes
'b( Are always in <!.
?@. $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
c( i U iii d( ii U iii
'a( i U iii because theta :oins are :oins made on keys that are not primary keys.
?1. 6 " , is a set of attri.utes. Dhe functional dependency is as follows
6" 3V "
6, 3V ,
, 3V "
a( is in <!.
b( is in ;!.
c( is in B!.
d( is in %C!.
'a( is in <!. since 'AC(
8
> ] A, %, C^ hence AC is the primary key. Since C % is a .D given,
where neither C is a _ey nor % is a prime attribute, this it is not in B!.. .urther % is not functionally dependent
on key AC thus it is not in ;!.. *hus the given .Ds is in <!..
?2. +n mapping of 1! to !<!
a( entities in 1$D should correspond to an e2isting entityLstore in D.D
b( entity in D.D is converted to attributes of an entity in 1$D
c( relations in 1$D has < to < correspondence to processes in D.D
d( relationships in 1$D has < to < correspondence to flows in D.D
'a( entities in 1$D should correspond to an e2isting entityLstore in D.D
?3. 6 dominant entity is the entity
a( on the ! side in a < 4 ! relationship
b( on the < side in a < 4 ! relationship
c( on either side in a < 4 < relationship
d( nothing to do with < 4 < or < 4 ! relationship
<;?
'b( on the < side in a < 4 ! relationship
?*. $elect W&ED)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
*he above is
a( !ot an error
b( 1rror 6 the string in single ,uotes T!O$*)T and TSO9*)T
c( 1rror 6 the string should be in double ,uotes
d( 1rror 6 O$D1$ %H clause
'd( 1rror 6 the O$D1$ %H clause. Since O$D1$ %H clause cannot be used in 9!#O!S
?-. What is $torage #anager?
#t is a program module that provides the interface between the low6level data stored in database,
application programs and ,ueries submitted to the system.

?0. What is "uffer #anager?
#t is a program module, which is responsible for fetching data from disk storage into main memory and
deciding what data to be cache in memory.
?5. What is Dransaction #anager?
#t is a program module, which ensures that database, remains in a consistent state despite system failures
and concurrent transaction e2ecution proceeds without conflicting.
?7. What is <ile #anager?
#t is a program module, which manages the allocation of space on disk storage and data structure used to
represent information stored on a disk.
??. What is 6uthoriCation and +ntegrity manager?
#t is the program module, which tests for the satisfaction of integrity constraint and checks the authority
of user to access data.

1@@. What are stand3alone procedures?
3rocedures that are not part of a package are known as stand6alone because they independently defined.
A good e2ample of a stand6alone procedure is one written in a SM-7.orms application. *hese types of
procedures are not available for reference from other Oracle tools. Another limitation of stand6alone procedures
is that they are compiled at run time, which slows e2ecution.
1@1. What are cursors give different types of cursors.
3-LSM- uses cursors for all database information accesses statements. *he 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:
#t is copying the three sets of files 'database files, redo logs, and control file( when the
instance is shut down. *his is a straight file copy, usually from the disk directly to tape. Hou must shut down the
instance to guarantee a consistent copy.
<;F
#f a cold backup is performed, the only option available in the event of data file loss is
restoring all the files from the latest backup. All work performed on the database since the last backup is lost.
)ot "ac'up:
Some sites 'such as worldwide airline reservations systems( cannot shut down the database
while making a backup copy of the files. *he cold backup is not an available option.
So different means of backing up database must be used g the hot backup. #ssue a SM-
command to indicate to Oracle, on a tablespace6by6tablespace basis, that the files of the tablespace are to
backed up. *he users can continue to make full use of the files, including making changes to the data. Once the
user has indicated that heLshe wants to back up the tablespace files, heLshe can use the operating system to copy
those files to the desired backup destination.
*he database must be running in A$C)#+1-O" mode for the hot backup option.
#f a data loss failure does occur, the lost database files can be restored using the hot backup
and the online and offline redo logs created since the backup was done. *he database is restored to the most
consistent state without any loss of committed transactions.
1@3. What are 6rmstrong rules? )ow do we say that they are complete andGor sound
*he well6known inference rules for .Ds
$efle2ive rule 4
#f H is subset or e,ual to G then G H.
Augmentation rule4
#f G H then Gf Hf.
*ransitive rule4
#f ]G H, H f^ then G f.
Decomposition rule 4
#f G Hf then G H.
9nion or Additive rule4
#f ]G H, G f^ then G Hf.
3seudo *ransitive rule 4
#f ]G H, EH f^ then EG f.
Of these the first three are known as Amstrong $ules. *hey are sound because it is enough if a set of
.Ds satisfy these three. *hey are called complete because using these three rules we can generate the rest all
inference rules.
1@*. )ow can you find the minimal 'ey of relational schema?
inimal key is one which can identify each tuple of the given relation schema uni,uely. .or finding the
minimal key it is re,uired 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.
0l4o9 > Determining G
8
, closure for G, given set of .Ds .
<. Set G
8
> G
;. Set Old G
8 >
G
8
B. .or each .D H f in . and if H belongs to G
8
then add f to G
8
A. $epeat steps ; and B until Old G
8
> G
8
0l4o9>> Determining minimal _ for relation schema $, given set of .Ds .
<. Set _ to $ that is make _ a set of all attributes in $
;. .or each attribute A in _
a. Compute '_ & A(
8
with respect to .
b. #f '_ & A(
8
> $ then set _ > '_ & A(
8
<;D
1@-. What do you understand .y dependency preservation?
"iven a relation $ and a set of .Ds ., dependency preservation states that the closure of the
union of the pro:ection of . on each decomposed relation $i is e,ual to the closure of .. i.e.,
''$<'.(( 9 I 9 '$n'.(((
8
> .
8

if decomposition is not dependency preserving, then some dependency is lost in the decomposition.

1@0. What is meant .y >roactive% etroactive and $imultaneous Qpdate.
>roactive Qpdate:
*he updates that are applied to database before it becomes effective in real world .
etroactive Qpdate:
*he updates that are applied to database after it becomes effective in real world .
$imulatneous Qpdate:
*he updates that are applied to database at the same time when it becomes effective in
real world .
1@5. What are the different types of YE+& operations?
1/ui Yoin: *his is the most common type of :oin which involves only e,uality comparisions.
*he disadvantage in this type of :oin is that there
<;J
SM-
1. Which is the su.set of $AL commands used to manipulate Eracle !ata.ase structures% including ta.les?
Data Definition -anguage 'DD-(
2. What operator performs pattern matching?
-#_1 operator
3. What operator tests column for the a.sence of data?
#S !9-- operator
*. Which command executes the contents of a specified file?
S*A$* RfilenameQ or bRfilenameQ
-. What is the parameter su.stitution sym.ol used with +&$1D +&DE command?
U
0. Which command displays the $AL command in the $AL .uffer% and then executes it?
$9!
5. What are the wildcards used for pattern matching?
K for single character substitution and W for multi6character substitution
7. $tate true or false. 1Z+$D$% $E#1% 6&_ are operators in $AL.
*rue
?. $tate true or false. UI% RV% ;I all denote the same operation.
*rue
1@. What are the privileges that can .e granted on a ta.le .y a user to others?
#nsert, update, delete, select, references, inde2, e2ecute, alter, all
11. What command is used to get .ac' the privileges offered .y the =6&D command?
$1+O_1
12. Which system ta.les contain information on privileges granted and privileges o.tained?
9S1$K*A%K3$#+SKAD1, 9S1$K*A%K3$#+SK$1CD
13. Which system ta.le contains information on constraints on all the ta.les created?
9S1$KCO!S*$A#!*S
1*. DQ&,6D1 D6"L1 1#>J
<B@
SQL
!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 13.
1-. What is the difference .etween DQ&,6D1 and !1L1D1 commands?
*$9!CA*1 is a DD- command whereas D1-1*1 is a D- command. )ence D1-1*1 operation
can be rolled back, but *$9!CA*1 operation cannot be rolled back. E)1$1 clause can be used with
D1-1*1 and not with *$9!CA*1.
10. What command is used to create a ta.le .y copying the structure of another ta.le?
Answer :
C$1A*1 *A%-1 .. AS S1-1C* command
Explanation :
*o copy only the structure, the E)1$1 clause of the S1-1C* command should contain a .A-S1
statement as in the following.
C$1A*1 *A%-1 !1E*A%-1 AS S1-1C* 7 .$O 1G#S*#!"*A%-1 E)1$1 <>;X
#f the E)1$1 condition is true, then all the rows or rows satisfying the condition will be copied to the
new table.
15. What will .e the output of the following /uery?
$1L1,D 1>L6,12D6&$L6D12LD+#2D+#2WUU 6D)1& UUW%WUW4% WUW4% W6&W%
W99W4%W9W%WDEQ"L1W4 <E# !Q6LJ
*$O9%-1*)1*$O9%-1
17. What will .e the output of the following /uery?
$1L1,D !1,E!12D6&$L6D12W6W%W123*-057?@W%W1111111111W4% W1W%W_1$W% W&EW 4J
Answer :
!O
Explanation :
*he ,uery checks whether a given string is a numerical digit.
1?. What does the following /uery do?
$1L1,D $6L 8 &BL2,E##%@4 <E# 1#>J
*his displays the total salary of all employees. *he null values in the commission column will be
replaced by @ and added to salary.
2@. Which date function is used to find the difference .etween two dates?
O!*)SK%1*E11!
21. Why does the following command give a compilation error?
!E> D6"L1 (D6"L1^&6#1J
+ariable names should start with an alphabet. )ere the table name starts with an TUT symbol.
22. What is the advantage of specifying W+D) =6&D E>D+E& in the =6&D command?
*he privilege receiver can further grant the privileges heLshe has obtained from the owner to any other
user.
23. What is the use of the !E> option in the 6LD1 D6"L1 command?
#t is used to drop constraints specified on the table.
<B<
2*. 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 > <<@@@, comm > <@@@
2-. What is the use of !1$, in $AL?
Answer :
D1SC has two purposes. #t is used to describe a schema as well as to retrieve rows from table in
descending order.
Explanation :
*he ,uery S1-1C* 7 .$O 13 O$D1$ %H 1!A1 D1SC will display the output sorted on
1!A1 in descending order.
20. What is the use of ,6$,6!1 ,E&$D6+&D$?
Ehen this clause is used with the D$O3 command, a parent table can be dropped even when a child
table e2ists.
25. Which function is used to find the largest integer less than or e/ual to a specific value?
.-OO$
27. What is the output of the following /uery?
$1L1,D DQ&,2123*.-057%324 <E# !Q6LJ
<;@@
S?3 @ ?2=R>=S
4* 0-5E.A0
Da.le 1 : 0T674E0
3!A1 '+A$C)A$(, S3-AC1 '+A$C)A$(, CO9$S1 '+A$C)A$(, CCOS* '!9%1$(
Da.le 2 : 038T9A"E
3!A1 '+A$C)A$(, *#*-1 '+A$C)A$(, D1+#! '+A$C)A$(, SCOS* '!9%1$(, DCOS*
'!9%1$(, SO-D '!9%1$(
Da.le 3 : /"3:"A..E"
3!A1 '+A$C)A$(, DO% 'DA*1(, DOC 'DA*1(, S1G 'C)A$(, 3$O.< '+A$C)A$(, 3$O.;
'+A$C)A$(, SA- '!9%1$(
3=A=)D :
3!A1 & 3rogrammer !ame, S3-AC1 & Study 3lace, CCOS* & Course Cost, D1+#! & Developed in,
SCOS* & Software Cost, DCOS* & Development Cost, 3$O.< & 3roficiency <
<B;
;6E"4E0 :
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.
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.
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
B=CS:
<. S1-1C* A+"'SCOS*( .$O SO.*EA$1 E)1$1 D1+#! > TO$AC-1TX
;. S1-1C* 3!A1,*$9!C'O!*)SK%1*E11!'SHSDA*1,DO%(L<;( NA"1N,
*$9!C'O!*)SK%1*E11!'SHSDA*1,DOC(L<;( N1G31$#1!C1N .$O 3$O"$A1$X
B. S1-1C* 3!A1 .$O S*9D#1S E)1$1 CO9$S1 > T3"DCATX
A. S1-1C* AG'SO-D( .$O SO.*EA$1X
=. S1-1C* 3!A1, DO% .$O 3$O"$A1$ E)1$1 DO% -#_1 TWA3$WTX
?. S1-1C* #!'CCOS*( .$O S*9D#1SX
F. S1-1C* CO9!*'7( .$O S*9D#1S E)1$1 CO9$S1 > TDCATX
<BB
D. S1-1C* S9'SCOS*7SO-D6DCOS*( .$O SO.*EA$1 "$O93 %H D1+#! )A+#!" D1+#! >
TCTX
J. S1-1C* 7 .$O SO.*EA$1 E)1$1 3!A1 > T$A_1S)TX
<@. S1-1C* 7 .$O S*9D#1S E)1$1 S3-AC1 > T31!*A.O9$TX
<<. S1-1C* 7 .$O SO.*EA$1 E)1$1 SCOS*7SO-D6DCOS* Q =@@@X
<;. S1-1C* C1#-'DCOS*LSCOS*( .$O SO.*EA$1X
<B. S1-1C* 7 .$O SO.*EA$1 E)1$1 SCOS*7SO-D Q> DCOS*X
<A. S1-1C* AG'SCOS*( .$O SO.*EA$1 "$O93 %H D1+#! )A+#!" D1+#! > T+%TX
<=. S1-1C* CO9!*'7( .$O SO.*EA$1 E)1$1 D1+#! > TO$AC-1TX
<?. S1-1C* CO9!*'7( .$O S*9D#1S E)1$1 S3-AC1 > T3$A"A*)#TX
<F. S1-1C* CO9!*'7( .$O S*9D#1S E)1$1 CCOS* %1*E11! <@@@@ A!D <=@@@X
<D. S1-1C* A+"'CCOS*( .$O S*9D#1SX
<J. S1-1C* 7 .$O 3$O"$A1$ E)1$1 3$O.< > TCT O$ 3$O.; > TCTX
;@. S1-1C* 7 .$O 3$O"$A1$ E)1$1 3$O.< #! 'TCT,T3ASCA-T( O$ 3$O.; #!
'TCT,T3ASCA-T(X
;<. S1-1C* 7 .$O 3$O"$A1$ E)1$1 3$O.< !O* #! 'TCT,TC88T( A!D 3$O.; !O* #!
'TCT,TC88T(X
;;. S1-1C* *$9!C'AG'O!*)SK%1*E11!'SHSDA*1,DO%(L<;(( .$O 3$O"$A1$
E)1$1 S1G > TTX
;B. S1-1C* *$9!C'A+"'O!*)SK%1*E11!'SHSDA*1,DO%(L<;(( .$O 3$O"$A1$
E)1$1 S1G > T.TX
;A. S1-1C* 3!A1, *$9!C'O!*)SK%1*E11!'SHSDA*1,DOC(L<;( .$O 3$O"$A1$
O$D1$ %H 3!A1 D1SCX
;=. S1-1C* 3!A1 .$O 3$O"$A1$ E)1$1 *OKC)A$'DO%,TO!T( >
*OKC)A$'SHSDA*1,TO!T(X
;?. S1-1C* CO9!*'7( .$O 3$O"$A1$ E)1$1 S1G > T.TX
;F. S1-1C* D#S*#!C*'3$O.<( .$O 3$O"$A1$ E)1$1 S1G > TTX
;D. S1-1C* A+"'SA-( .$O 3$O"$A1$X
;J. S1-1C* CO9!*'7( .$O 3$O"$A1$ E)1$1 SA- %1*E11! =@@@ A!D F=@@X
B@. S1-1C* 7 .$O 3$O"$A1$ E)1$1 3$O.< !O* #! 'TCT,TC88T,T3ASCA-T( A!D 3$O.;
!O* #! 'TCT,TC88T,T3ASCA-T(X
B<. S1-1C* 3!A1,*#*-1,SCOS* .$O SO.*EA$1 E)1$1 SCOS* #! 'S1-1C* AG'SCOS*(
.$O SO.*EA$1 "$O93 %H 3!A1(X
B;.S1-1C* Tr.T VV 3!A1 VV T 6 has T VV *$9!C'O!*)SK%1*E11!'SHSDA*1,DOC(L<;( VV T years of
e2perienceT [3rogrammer\ .$O 3$O"$A1$ E)1$1 S1G > TT 9!#O! S1-1C* Ts.T VV
3!A1 VV T 6 has T VV *$9!C 'O!*)SK%1*E11! 'SHSDA*1,DOC(L<;( VV T years of e2perienceT
[3rogrammer\ .$O 3$O"$A1$ E)1$1 S1G > T.TX
44 * 0-5E.A :
Da.le 1 : D=DT
D13*!O '!O* !9-- , !9%1$';((, D!A1 '+A$C)A$;'<A((,
-OC '+A$C)A$;'<B(
Da.le 2 : =1D
13!O '!O* !9-- , !9%1$'A((, 1!A1 '+A$C)A$;'<@((,
CO% '+A$C)A$;'J((, "$ '!9%1$'A((, )#$1DA*1 'DA*1(,
<BA
SA- '!9%1$'F,;((, CO '!9%1$'F,;((, D13*!O '!9%1$';((
"$ is the empno of the employee whom the employee reports to. D13*!O is a foreign key.
;6E"4E0
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.
-. 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. Write a correlated su.3/uery to list out the employees who earn more than the average salary of their
department.
13. <ind the nth maximum salary.
1*. $elect the duplicate records 2ecords% 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.
B=CS:
<. S1-1C* D#S*#!C*'A.1!A1( .$O 13 A, 13 % E)1$1 A.13!O > %."$X or S1-1C*
1!A1 .$O 13 E)1$1 13!O #! 'S1-1C* "$ .$O 13(X
;. S1-1C* 7 .$O 13 E)1$1 D13*!O #! 'S1-1C* D13*!O .$O 13 "$O93 %H D13*!O
)A+#!" CO9!*'13!O(Q<@ A!D D13*!O><@(X
B. S1-1C* A.1!A1 N13-OH11N, %.1!A1 N$13O$*S *ON .$O 13 A, 13 % E)1$1
A."$>%.13!OX
A. S1-1C* 7 .$O 13 E)1$1 13!O #! ' S1-1C* 13!O .$O 13 #!9S S1-1C* "$
.$O 13(X
=. S1-1C* 7 .$O 13 E)1$1 SA- Q ' S1-1C* #!'SA-( .$O 13 "$O93 %H D13*!O
)A+#!" D13*!O>;@(X
?. S1-1C* 7 .$O 13 E)1$1 SA- Q ' S1-1C* AG'SA-( .$O 13 "$O93 %H CO% )A+#!"
CO% > TA!A"1$T (X
F. S1-1C* CO%, AG'SA-( .$O 13 "$O93 %H CO%X
D. S1-1C* 7 .$O 13 E)1$1 'D13*!O, )#$1DA*1( #! 'S1-1C* D13*!O, AG')#$1DA*1(
.$O 13 "$O93 %H D13*!O(X
J. S1-1C* *OKC)A$')#$1DA*1,THHHHT( NH1A$N, CO9!*'13!O( N!O. O. 13-OH11SN .$O
13 "$O93 %H *OKC)A$')#$1DA*1,THHHHT( )A+#!" CO9!*'13!O( > 'S1-1C*
AG'CO9!*'13!O(( .$O 13 "$O93 %H *OKC)A$')#$1DA*1,THHHHT((X
<@. S1-1C* D13*!O, -3AD'S9'<;7'SA-8!+-'CO,@(((,<=( NCO31!SA*#O!N .$O 13
"$O93 %H D13*!O )A+#!" S9' <;7'SA-8!+-'CO,@((( > 'S1-1C*
AG'S9'<;7'SA-8!+-'CO,@(((( .$O 13 "$O93 %H D13*!O(X
<<. S1-1C* 1!A1, )#$1DA*1, -3AD'T7T,D( N$1C1!*-H )#$1DN .$O 13 E)1$1 )#$1DA*1 >
'S1-1C* AG')#$1DA*1( .$O 13( 9!#O! S1-1C* 1!A1 !A1, )#$1DA*1, -3AD'T T,<=(
N$1C1!*-H )#$1DN .$O 13 E)1$1 )#$1DA*1 S> 'S1-1C* AG')#$1DA*1( .$O 13(X
<;. S1-1C* 1!A1,SA- .$O 13 1 E)1$1 SA- Q 'S1-1C* A+"'SA-( .$O 13 . E)1$1
1.D13*!O > ..D13*!O(X
<B=
<B. S1-1C* 1!A1, SA- .$O 13 A E)1$1 U! > 'S1-1C* CO9!* 'D#S*#!C*'SA-(( .$O
13 % E)1$1 A.SA-R>%.SA-(X
<A. S1-1C* 7 .$O 13 A E)1$1 A.13!O #! 'S1-1C* 13!O .$O 13 "$O93 %H 13!O
)A+#!" CO9!*'13!O(Q<( A!D A.$OE#DS>#! '$OE#D((X
<=. S1-1C* 1!A1
N13-OH11N,*OKC)A$'*$9!C'O!*)SK%1*E11!'SHSDA*1,)#$1DA*1(L<;((VVT H1A$S TVV
*OKC)A$'*$9!C'OD'O!*)SK%1*E11! 'SHSDA*1, )#$1DA*1(,<;(((VVT O!*)S T N-1!"*)
O. S1$+#C1N .$O 13X
<B?
Computer !etworks
1. What are the two types of transmission technology availa.le?
'i( %roadcast and 'ii( point6to6point
2. What is su.net?
A generic term for section of a large networks usually separated by a bridge or router.
3. !ifference .etween the communication and transmission.
*ransmission is a physical movement of information and concern issues like bit polarity,
synchronisation, clock etc.
Communication means the meaning full e2change of information between two communication media.
*. What are the possi.le ways of data exchange?
'i( Simple2 'ii( )alf6duple2 'iii( .ull6duple2.
-. What is $6>?
Series of interface points that allow other computers to communicate with the other layers of network
protocol stack.
0. What do you meant .y Ktriple ZK in &etwor's?
*he function of 3AD '3acket Assembler Disassembler( is described in a document known as G.B. *he
standard protocol has been defined between the terminal and the 3AD, called G.;DX another standard protocol
e2ists between hte 3AD and the network, called G.;J. *ogether, these three recommendations are often called
Ntriple GN
5. What is frame relay% in which layer it comes?
.rame relay is a packet switching technology. #t will operate in the data link layer.
7. What is terminal emulation% in which layer it comes?
*elnet is also called as terminal emulation. #t belongs to application layer.
?. What is "eaconing?
*he process that allows a network to self6repair networks problems. *he stations on the network notify
the other stations on the ring when they are not receiving the transmissions. %eaconing is used in *oken ring
and .DD# networks.
1@. What is redirector?
$edirector is software that intercepts file or prints #LO re,uests and translates them into network
re,uests. *his comes under presentation layer.
11. What is &1D"+E$ and &1D"1Q+?
<BF
Computer
Netor!s

!1*%#OS is a programming interface that allows #LO re,uests to be sent to and received from a remote
computer and it hides the networking hardware from applications.
!1*%19# is !et%#OS e2tended user interface. A transport protocol designed by microsoft and #% for
the use on small subnets.
12. What is 6+!?
A method for providing fault tolerance by using multiple hard disk drives.
13. What is passive topology?
Ehen the computers on the network simply listen and receive the signal, they are referred to as passive
because they don0t amplify the signal in any way. 12ample for passive topology 6 linear bus.
1*. What is "router?
)ybrid devices that combine the features of both bridges and routers.
1-. What is cladding?
A layer of a glass surrounding the center fiber of glass inside a fiber6optic cable.
10. What is point3to3point protocol
A communications protocol used to connect computers to remote networking services including #nternet
service providers.
15. )ow =ateway is different from outers?
A gateway operates at the upper levels of the OS# model and translates information between two
completely different network architectures or data formats
17. What is attenuation?
*he degeneration of a signal over distance on a network cable is called attenuation.
1?. What is #6, address?
*he address for a device as it is identified at the edia Access Control 'AC( layer in the network
architecture. AC address is usually stored in $O on the network adapter card and is uni,ue.
2@. !ifference .etween .it rate and .aud rate.
%it rate is the number of bits transmitted during one second whereas baud rate refers to the number of
signal units per second that are re,uired to represent those bits.
.aud rate I .it rate G &
where ! is no6of6bits represented by each signal shift.
21. What is "andwidth?
1very line has an upper limit and a lower limit on the fre,uency of signals it can carry. *his limited
range is called the bandwidth.
22. What are the types of Dransmission media?
Signals are usually transmitted over some transmission media that are broadly classified in to two
categories.
a4 =uided #edia:
*hese are those that provide a conduit from one device to another that include twisted6pair,
coa2ial cable and fiber6optic cable. A signal traveling along any of these media is directed and is contained by
the physical limits of the medium. *wisted6pair and coa2ial cable use metallic that accept and transport signals
<BD
in the form of electrical current. Optical fiber is a glass or plastic cable that accepts and transports signals in the
form of light.
.4 Qnguided #edia:
*his is the wireless media that transport electromagnetic waves without using a physical
conductor. Signals are broadcast either through air. *his is done through radio communication, satellite
communication and cellular telephony.
23. What is >roject 7@2?
#t is a pro:ect started by #111 to set standards to enable intercommunication between e,uipment from a
variety of manufacturers. #t is a way for specifying functions of the physical layer, the data link layer and to
some e2tent the network layer to allow for interconnectivity of ma:or -A!
protocols.
#t consists of the following4
D@;.< is an internetworking standard for compatibility of different -A!s and A!s across protocols.
D@;.; -ogical link control '--C( is the upper sublayer of the data link layer which is non6architecture6
specific, that is remains the same for all #1116defined -A!s.
edia access control 'AC( is the lower sublayer of the data link layer that contains some distinct modules
each carrying proprietary information specific to the -A! product being used. *he modules are 1thernet
-A! 'D@;.B(, *oken ring -A! 'D@;.A(, *oken bus -A! 'D@;.=(.
D@;.? is distributed ,ueue dual bus 'DMD%( designed to be used in A!s.
2*. What is >rotocol !ata Qnit?
*he data unit in the --C level is called the protocol data unit '3D9(. *he 3D9 contains of four fields a
destination service access point 'DSA3(, a source service access point 'SSA3(, a control field and an
information field. DSA3, SSA3 are addresses used by the --C to identify the protocol stacks on the receiving
and sending machines that are generating and using the data. *he control field specifies whether the 3D9 frame
is a information frame '# 6 frame( or a supervisory frame 'S 6 frame( or a unnumbered frame '9 6 frame(.
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. #t receives
the signal in the network before it becomes weak, regenerates the original bit pattern and puts the refreshed
copy back in to the link.
"ridges:
*hese operate both in the physical and data link layers of -A!s of same type. *hey divide a
larger network in to smaller segments. *hey contain logic that allow them to keep the traffic for each segment
separate and thus are repeaters that relay a frame only the side of the segment containing the intended recipent
and control congestion.
outers:
*hey relay packets among multiple interconnected networks 'i.e. -A!s of different type(. *hey
operate in the physical, data link and network layers. *hey contain software that enable them to determine
which of the several possible paths is the best for a particular transmission.
=ateways:
*hey relay packets among networks that have different protocols 'e.g. between a -A! and a EA!(.
*hey accept a packet formatted for one protocol and convert it to a packet formatted for another protocol before
forwarding it. *hey operate in all seven layers of the OS# model.

20. What is +,#>?
#C3 is #nternet Control essage 3rotocol, a network layer protocol of the *C3L#3 suite used by hosts
and gateways to send notification of datagram problems back to the sender. #t uses the echo test L reply to test
whether a destination is reachable and responding. #t also handles both control and error messages.
<BJ
25. What are the data units at different layers of the D,> G +> protocol suite?
*he data unit created at the application layer is called a message, at the transport layer the data unit
created is called either a segment or an user datagram, at the network layer the data unit created is called the
datagram, at the data link layer the datagram is encapsulated in to a frame and finally transmitted as signals
along the transmission media.
27. What is difference .etween 6> and 6>?
*he address resolution protocol 'A$3( is used to associate the B; bit #3 address with the AD bit physical
address, used by a host or a router to find the physical address of another host on its network by sending a A$3
,uery packet that includes the #3 address of the receiver.
*he reverse address resolution protocol '$A$3( allows a host to discover its #nternet address when it
knows only its physical address.
2?. What is the minimum and maximum length of the header in the D,> segment and +> datagram?
*he header should have a minimum length of ;@ bytes and can have a ma2imum length of ?@ bytes.

3@. What is the range of addresses in the classes of internet addresses?
Class A @.@.@.@ 6 <;F.;==.;==.;==
Class % <;D.@.@.@ 6 <J<.;==.;==.;==
Class C <J;.@.@.@ 6 ;;B.;==.;==.;==
Class D ;;A.@.@.@ 6 ;BJ.;==.;==.;==
Class 1 ;A@.@.@.@ 6 ;AF.;==.;==.;==
31. What is the difference .etween D<D> and <D> application layer protocols?
*he *rivial .ile *ransfer 3rotocol '*.*3( allows a local host to obtain files from a remote host but does
not provide reliability or security. #t uses the fundamental packet delivery services offered by 9D3.
*he .ile *ransfer 3rotocol '.*3( is the standard mechanism provided by *C3 L #3 for copying a file
from one host to another. #t uses the services offer by *C3 and so is reliable and secure. #t establishes two
connections 'virtual circuits( between the hosts, one for data transfer and another for control information.
32. What are major types of networ's and explain?
Server6based network
3eer6to6peer network
3eer6to6peer network, computers can act as both servers sharing resources and as clients using the
resources.
Server6based networks provide centralized control of network resources and rely on server computers to
provide security and network administration
33. What are the important topologies for networ's?
"Q$ topology:
#n this each computer is directly connected to primary network cable in a single line.
6dvantages:
#ne2pensive, easy to install, simple to understand, easy to e2tend.
$D6 topology:
#n this all computers are connected using a central hub.
6dvantages:
Can be ine2pensive, easy to install and reconfigure and easy to trouble shoot physical problems.
<A@
+&= topology:
#n this all computers are connected in loop.
6dvantages:
All computers have e,ual access to network media, installation can be simple, and signal does
not degrade as much as in other topologies because each computer regenerates it.
3*. What is mesh networ'?
A network in which there are multiple network links between computers to provide multiple paths for
data to travel.
3-. What is difference .etween .ase.and and .road.and transmission?
#n a baseband transmission, the entire bandwidth of the cable is consumed by a single signal. #n
broadband transmission, signals are sent on multiple fre,uencies, allowing multiple signals to be sent
simultaneously.
30. 1xplain -3*33 rule?
#n a 1thernet network, between any two points on the network ,there can be no more than five network
segments or four repeaters, and of those five segments only three of segments can be populated.
35. What #6Q?
#n token $ing , hub is called ultistation Access 9nit'A9(.
37. What is the difference .etween routa.le and non3 routa.le protocols?
$outable protocols can work with a router and can be used to build large networks. !on6$outable
protocols are designed to work on small, local networks and cannot be used with a router
3?. Why should you care a.out the E$+ eference #odel?
#t provides a framework for discussing network operations and design.
*@. What is logical lin' control?
One of two sublayers of the data link layer of OS# reference model, as defined by the #111 D@;
standard. *his sublayer is responsible for maintaining the link between computers when they are sending data
across the physical network connection.
*1. What is virtual channel?
+irtual channel is normally a connection from one source to one destination, although multicast
connections are also permitted. *he other name for virtual channel is virtual circuit.
*2. What is virtual path?
Along any transmission path from 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?
3acket filter is a standard router e,uipped with some e2tra functionality. *he e2tra functionality allows
every incoming or outgoing packet to be inspected. 3ackets meeting some criterion are forwarded normally.
*hose that fail the test are dropped.
**. What is traffic shaping?
One of the main causes of congestion is that traffic is often busy. #f hosts could be made to transmit at a
uniform rate, congestion would be less common. Another open loop method to help manage congestion is
forcing the packet to be transmitted at a more predictable rate. *his is called traffic shaping.
<A<
*-. What is multicast routing?
Sending a message to a group is called multicasting, and its routing algorithm is called multicast routing.
*0. What is region?
Ehen hierarchical routing is used, the routers are divided into what we will call regions, with each
router knowing all the details about how to route packets to destinations within its own region, but knowing
nothing about the internal structure of other regions.
*5. What is silly window syndrome?
#t is a problem that can ruin *C3 performance. *his problem occurs when data are passed to the sending
*C3 entity in large blocks, but an interactive application on the receiving side reads < byte at a time.
*7. What are !igrams and Drigrams?
*he most common two letter combinations are called as digrams. e.g. th, in, er, re and an. *he most
common three letter combinations are called as trigrams. e.g. the, ing, and, and ion.
*?. 1xpand +!16.
#D1A stands for #nternational Data 1ncryption Algorithm.
-@. What is wide3mouth frog?
Eide6mouth frog is the simplest known key distribution center '_DC( authentication protocol.
-1. What is #ail =ateway?
#t is a system that performs a protocol translation between different electronic mail delivery protocols.
-2. What is +=> 2+nterior =ateway >rotocol4?
#t is any routing protocol used within an autonomous system.
-3. What is 1=> 21xterior =ateway >rotocol4?
#t is the protocol the routers in neighboring autonomous systems use to identify the set of networks that
can be reached within or via each autonomous system.
-*. What is autonomous system?
#t is a collection of routers under the control of a single administrative authority and that uses a common
#nterior "ateway 3rotocol.
--. What is "=> 2"order =ateway >rotocol4?
#t is a protocol used to advertise the set of networks that can be reached with in an autonomous system.
%"3 enables this information to be shared with the autonomous system. *his is newer than 1"3 '12terior
"ateway 3rotocol(.
-0. What is =ateway3to3=ateway protocol?
#t is a protocol formerly used to e2change routing information between #nternet core routers.
-5. What is &BD 2&etwor' Birtual Derminal4?
#t is a set of rules defining a very simple virtual terminal interaction. *he !+* is used in the start of a
*elnet session.
-7. What is a #ulti3homed )ost?
#t is a host that has a multiple network interfaces and that re,uires multiple #3 addresses is called as a
<A;
ulti6homed )ost.
-?. What is [er.eros?
#t is an authentication service developed at the assachusetts #nstitute of *echnology. _erberos uses
encryption to prevent intruders from discovering passwords and gaining unauthorized access to files.
0@. What is E$><?
#t is an #nternet routing protocol that scales well, can route traffic along multiple paths, and uses
knowledge of an #nternetTs topology to make accurate routing decisions.
01. What is >roxy 6>?
#t is using a router to answer A$3 re,uests. *his will be done when the originating host believes that a
destination is local, when in fact is lies beyond router.
02. What is $L+> 2$erial Line +nterface >rotocol4?
#t is a very simple protocol used for transmission of #3 datagrams across a serial line.
03. What is +> 2outing +nformation >rotocol4?
#t is a simple protocol used to e2change information between the routers.
0*. What is source route?
#t is a se,uence of #3 addresses identifying the route a datagram must follow. A source route may
optionally be included in an #3 datagram header.
<AB
Operating Systems
.ollowing are a few basic ,uestions that cover the essentials of OS4
1. 1xplain the concept of eentrancy.
#t is a useful, memory6saving techni,ue for multiprogrammed timesharing systems. A eentrant
>rocedure is one in which multiple users can share a single copy of a program during the same period.
$eentrancy has ; key aspects4 *he program code cannot modify itself, and the local data for each user process
must be stored separately. *hus, the permanent part is the code, and the temporary part is the pointer back to the
calling program and local variables used by that program. 1ach e2ecution instance is called activation. #t
e2ecutes the code in the permanent part, but has its own copy of local variablesLparameters. *he temporary part
associated with each activation is the activation record. "enerally, the activation record is kept on the stack.
)ote4 A reentrant procedure can be interrupted and called by an interrupting program, and still e2ecute
correctly on returning to the procedure.
2. 1xplain "eladyWs 6nomaly.
Also called .#.O anomaly. 9sually, on increasing the number of frames allocated to a processT virtual
memory, the process e2ecution is faster, because fewer page faults occur. Sometimes, the reverse happens, i.e.,
the e2ecution time increases even when more frames are allocated to the process. *his is %eladyTs Anomaly.
*his is true for certain page reference patterns.
3. What is a .inary semaphore? What is its use?
A binary semaphore is one, which takes only @ and < as values. *hey are used to implement mutual
e2clusion and synchronize concurrent processes.
*. What is thrashing?
#t is a phenomenon in virtual memory schemes when the processor spends most of its time swapping
pages, rather than e2ecuting instructions. *his is due to an inordinate number of page faults.
-. List the ,offmanWs conditions that lead to a deadloc'.
utual 12clusion4 Only one process may use a critical resource at a time.
)old U Eait4 A process may be allocated some resources while waiting for others.
!o 3re6emption4 !o resource can be forcible removed from a process holding it.
Circular Eait4 A closed chain of processes e2ist such that each process holds at least one resource needed by
another process in the chain.
0. What are short3% long3 and medium3term scheduling?
-ong term scheduler determines which programs are admitted to the system for processing. #t controls
the degree of multiprogramming. Once admitted, a :ob becomes a process.
edium term scheduling is part of the swapping function. *his relates to processes that are in a blocked
or suspended state. *hey are swapped out of real6memory until they are ready to e2ecute. *he swapping6in
decision is based on memory6management criteria.
<AA
Operatin" S#stems

Short term scheduler, also know as a dispatcher e2ecutes most fre,uently, and makes the finest6grained
decision of which process should e2ecute ne2t. *his scheduler is invoked whenever an event occurs. #t may lead
to interruption of one process by preemption.
5. What are turnaround time and response time?
*urnaround time is the interval between the submission of a :ob and its completion. $esponse time is the
interval between submission of a re,uest, and the first response to that re,uest.
7. What are the typical elements of a process image?
9ser data4 odifiable part of user space. ay include program data, user stack area, and programs that may
be modified.
9ser program4 *he instructions to be e2ecuted.
System Stack4 1ach process has one or more -#.O stacks associated with it. 9sed to store parameters and
calling addresses for procedure and system calls.
3rocess control %lock '3C%(4 #nfo needed by the OS to control processes.
?. What is the Dranslation Loo'aside "uffer 2DL"4?
#n a cached system, the base addresses of the last few referenced pages is maintained in registers called
the *-% that aids in faster lookup. *-% contains those page6table entries that have been most recently used.
!ormally, each virtual memory reference causes ; physical memory accesses66 one to fetch appropriate page6
table entry, and one to fetch the desired data. 9sing *-% in6between, this is reduced to :ust one physical
memory access in cases of *-%6hit.
1@. What is the resident set and wor'ing set of a process?
$esident set is that portion of the process image that is actually in real6memory at a particular instant.
Eorking set is that subset of resident set that is actually needed for e2ecution. '$elate this to the variable6
window size method for swapping techni,ues.(
11. When is a system in safe state?
*he set of dispatchable processes is in a safe state if there e2ists at least one temporal order in which all
processes can be run to completion without resulting in a deadlock.
12. What is cycle stealing?
Ee encounter cycle stealing in the conte2t of Direct emory Access 'DA(. 1ither the DA controller
can use the data bus when the C39 does not need it, or it may force the C39 to temporarily suspend operation.
*he latter techni,ue is called cycle stealing. !ote that cycle stealing can be done only at specific break points in
an instruction cycle.
13. What is meant .y arm3stic'iness?
#f one or a few processes have a high access rate to data on one track of a storage disk, then they may
monopolize the device by repeated re,uests to that track. *his generally happens with most common device
scheduling algorithms '-#.O, SS*., C6SCA!, etc(. )igh6density multisurface disks are more likely to be
affected by this than low density ones.
1*. What are the stipulations of ,2 level security?
C; level security provides for4
Discretionary Access Control
#dentification and Authentication
Auditing
$esource reuse
<A=
1-. What is .usy waiting?
*he repeated e2ecution of a loop of code while waiting for an event to occur is called busy6waiting. *he
C39 is not engaged in any real productive activity during this period, and the process does not progress toward
completion.
10. 1xplain the popular multiprocessor thread3scheduling strategies.
Load $haring: 3rocesses are not assigned to a particular processor. A global ,ueue of threads is maintained.
1ach processor, when idle, selects a thread from this ,ueue. !ote that load .alancing refers to a scheme
where work is allocated to processors on a more permanent basis.
=ang $cheduling: A set of related threads is scheduled to run on a set of processors at the same time, on a <6
to6< basis. Closely related threads L processes may be scheduled this way to reduce synchronization
blocking, and minimize process switching. "roup scheduling predated this strategy.
!edicated processor assignment: 3rovides implicit scheduling defined by assignment of threads to
processors. .or the duration of program e2ecution, each program is allocated a set of processors e,ual in
number to the number of threads in the program. 3rocessors are chosen from the available pool.
!ynamic scheduling: *he number of thread in a program can be altered during the course of e2ecution.
15. When does the condition WrendeCvousW arise?
#n message passing, it is the condition in which, both, the sender and receiver are blocked until the
message is delivered.
17. What is a trap and trapdoor?
*rapdoor is a secret undocumented entry point into a program used to grant access without normal
methods 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?
-ocal replacement means that an incoming page is brought in only to the relevant processT address
space. "lobal replacement policy allows any page frame from any process to be replaced. *he latter is
applicable to variable partitions model only.
2@. !efine latency% transfer and see' time with respect to dis' +GE.
Seek time is the time re,uired to move the disk arm to the re,uired track. $otational delay or latency is
the time it takes for the beginning of the re,uired sector to reach the head. Sum of seek time 'if any( and latency
is the access time. *ime taken to actually transfer a span of data is transfer time.
21. !escri.e the "uddy system of memory allocation.
.ree memory is maintained in linked lists, each of e,ual sized blocks. Any such block is of size ;5k.
Ehen some memory is re,uired by a process, the block size of ne2t higher order is chosen, and broken into two.
!ote that the two such pieces differ in address only in their kth bit. Such pieces are called buddies. Ehen any
used block is freed, the OS checks to see if its buddy is also free. #f so, it is re:oined, and put into the original
free6block linked6list.
22. What is time3stamping?
#t is a techni,ue proposed by -amport, used to order events in a distributed system without the use of
clocks. *his scheme is intended to order events consisting of the transmission of messages. 1ach system TiT in
the network maintains a counter Ci. 1very time a system transmits a message, it increments its counter by < and
attaches the time6stamp *i to the message. Ehen a message is received, the receiving system T:T sets its counter
C: to < more than the ma2imum of its current value and the incoming time6stamp *i. At each site, the ordering
of messages is determined by the following rules4 .or messages 2 from site i and y from site :, 2 precedes y if
one of the following conditions holds....'a( if *iR*: or 'b( if *i>*: and iR:.
<A?
23. )ow are the waitGsignal operations for monitor different from those for semaphores?
#f a process in a monitor signal and no task is waiting on the condition variable, the signal is lost. So this
allows easier program design. Ehereas in semaphores, every operation affects the value of the semaphore, so
the wait and signal operations should be perfectly balanced in the program.
2*. +n the context of memory management% what are placement and replacement algorithms?
3lacement algorithms determine where in available real6memory to load a program. Common methods
are first6fit, ne2t6fit, best6fit. $eplacement algorithms are used when memory is full, and one process 'or part of
a process( needs to be swapped out to accommodate a new program. *he replacement algorithm determines
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?
.or load6time dynamic linking4 -oad module to be loaded is read into memory. Any reference to a target
e2ternal module causes that module to be loaded and the references are updated to a relative address from the
start base address of the application module.
Eith run6time dynamic loading4 Some of the linking is postponed until actual reference during
e2ecution. *hen the correct module is loaded and linked.
20. What are demand3 and pre3paging?
Eith demand paging, a page is brought into memory only when a location on that page is actually
referenced during e2ecution. Eith pre6paging, pages other than the one demanded by a page fault are brought
in. *he selection of such pages is done based on common access patterns, especially for secondary memory
devices.
25. >aging a memory management function% while multiprogramming a processor management function% are
the two interdependent?
Hes.
27. What is page canni.aliCing?
3age swapping or page replacements are called page cannibalizing.
2?. What has triggered the need for multitas'ing in >,s?
#ncreased speed and memory capacity of microprocessors together with the support fir virtual memory and
"rowth of client server computing
3@. What are the four layers that Windows &D have in order to achieve independence?
)ardware abstraction layer
_ernel
Subsystems
System Services.
31. What is $#>?
*o achieve ma2imum efficiency and reliability a mode of operation known as symmetric
multiprocessing is used. #n essence, with S3 any process or threads can be assigned to any processor.
32. What are the 'ey o.ject oriented concepts used .y Windows &D?
1ncapsulation <AF
Ob:ect class and instance
33. +s Windows &D a full .lown o.ject oriented operating system? =ive reasons.
!o Eindows !* is not so, because its not implemented in ob:ect oriented language and the data
structures reside within one e2ecutive component and are not represented as ob:ects and it does not support
ob:ect oriented capabilities .
3*. What is a draw.ac' of #BD?
#t does not have the features like
ability to support multiple processors
virtual storage
source level debugging
3-. What is process spawning?
Ehen the OS at the e2plicit re,uest of another process creates a process, this action is called process
spawning.
30. )ow many jo.s can .e run concurrently on #BD?
<= :obs
35. List out some reasons for process termination.
!ormal completion
*ime limit e2ceeded
emory unavailable
%ounds violation
3rotection error
Arithmetic error
*ime overrun
#LO failure
#nvalid instruction
3rivileged instruction
Data misuse
Operator or OS intervention
3arent termination.
37. What are the reasons for process suspension?
swapping
interactive user re,uest
timing
parent process re,uest
3?. What is process migration?
#t is the transfer of sufficient amount of the state of process from one machine to the target machine
*@. What is mutant?
#n Eindows !* a mutant provides kernel mode or user mode mutual e2clusion with the notion of
ownership.
*1. What is an idle thread?
<AD
*he special thread a dispatcher will e2ecute when no ready thread is found.
*2. What is <t!is'?
#t is a fault tolerance disk driver for Eindows !*.
*3. Ehat are the possible threads a thread can have`
$eady
Standby
$unning
Eaiting
*ransition
*erminated.
**. What are rings in Windows &D?
Eindows !* uses protection mechanism called rings provides by the process to implement separation
between the user mode and kernel mode.
*-. What is 1xecutive in Windows &D?
#n Eindows !*, e2ecutive refers to the operating system code that runs in kernel mode.
*0. What are the su.3components of +GE manager in Windows &D?
!etwork redirectorL Server
Cache manager.
.ile systems
!etwork driver
Device driver
*5. What are !!'s? &ame an operating system that includes this feature.
DDks are device driver kits, which are e,uivalent to SD_s for writing device drivers. Eindows !*
includes DDks.
*7. What level of security does Windows &D meets?
C; level security.
<AJ
Table of Contents
Data Structures Aptitude.............................................................................1
C Aptitude..................................................................................................10
C++ Aptitude and OOPS.............................................................................73
Quantitative Aptitude...............................................................................102
UNIX Concepts.........................................................................................120
RDBMS Concepts.....................................................................................134
SQL..........................................................................................................152
Computer Networks.................................................................................160
Operating Systems...................................................................................168
<=@

You might also like