1. Which of the following statements is/are true about optical fibres?
1. Optical fibre transports signal on the basis of total internal reflection principle. 2. Refractive index of core should be less than that of cladding.
3. ver! beam which stri"es the interface of core and cladding is reflected bac". #$$
### #$# $$$
2. %assage
&i'a! wants to print the following pattern on the screen( 1
1 2 1 2 3
)e writes the following program( *nteger * + 1 // statement 1 While,i -+3 *nt ' // statement 2 While , ' -+ i // statement 3 print '
'+ '01 // statement
print endofline // ta"es the cursor to the next line i+i01 4uestion( a. 5tatement 1 b. 5tatement 2 675 c. 5tatement 3 d. 5tatement
e. %rogram does not have error 3. %assage(
6bhinav wants to find the largest number in a given list of 28 numbers. which of the following options is an efficient approach to do this?
1 use bubble sort to sort the list in descending order and then print the first number of the series.
2 use selection sort to sort the list in descending order and then print the first number of the series
3 implement one iteration of selection sort for descending order and print the first number in the series.675
passage(
what is implied b! the argument of a function? 9uestion
1. the variables passed to it when it is called675 2. the value it returns on execution
3. the execution code inside it . its return t!pe
passage( there are two loops which are nested. this implies which one of the following?
9uestion
1. two loops: one after the other 2. two loops: one inside the otherans
3. one loop with two different iteration counts . two loops with the same iteration count
%assage(
;ar! is ma"ing a database of animals in a <oo and their properties. #he possible animals are dog: lion and <ebra. ach one has as attributes is herbivorous: colour and is nocturnal. 5he uses the ob'ect oriented programming paradigm for this. )ow will she conceptuali<e the s!stem?
4uestion
1. class( 6nimal = ob'ects(dog: lion and <ebra= data members( is herbivorous: colour and is nocturnal675
2. class( 6nimal= ob'ects( is)erbivorous: colour and is7octurnal= data members( dog: lion and <ebra
3. classes( dog: lion and <ebra= ob'ects( 6nimal= data members( is)erbivours:colour and *s7octurnal
. none of these
passage
what is space complexit! of a program? 4uestion
1. amount of harddis" space re9uired to store the program 2. amount of harddis" space re9uired to compile the program 3. amount of memor! re9uired b! the program to runans . amount of memor! re9uired for the program to compile
passage(
function ;u$unc1,integer n
return n>2
$unction ;!$unc2, integer n
%rint the value is@ n
Which of the given two functions can be categori<ed as procedure? 1. ;!$unc1
2. ;!$unc2
3. Aoth ;!$unc1 and ;!$un2 . 6 function cannot be a procedure
%assage(
Benab and shashi independentl! write a program to find the mass of one mole of water:which includes mass of h!drogen and ox!gen. Benab defines the cariables(
*nteger h!drogen:ox!gen:water //code 6 While shashi defines the three 9uantities as( *nteger a: b :c // code A
Which is a better programming practice and wh!?
4uestion
1. Code A is better because variable names are shorter
2. Code 6 is better because the variable names are understandable and non confusingans
3. Code 6 will run correctl!: while Code A will give an error. . Code A will run correctl!: while code 6 will give an error.
%assage(
6 derived class ma! inherit from the base class which of the following ,consider assumptions as in C00
4uestion 1. Data members 2. ;ember functions
3. Constructors and destructors
. Aoth data members and member functionsans
%assage(
6 9ueue is implemented as a ,singl! lin"ed lin"edlist. ach node has an element and pointer to another node. Rear and $ront contain the addresses of the rear and front node respectivel!. *f the condition ,rear is e9ual front is true and neither is 7EFF: What do we infer about the lin"ed list?
4uestion(
1. *t has no elements 2. *t has one elementsans 3. #here is an error . 7one of these
%assage(
5aloni writes the code for a function that ta"es as input n: an even integer and calculates the sum of first n even natural numbers.
function sum, n
return 2 else
return n 0 sum,n2 end
5he then calls the function b! the statement1:sum,38. )ow man! times will the function sum be called to compute this sum?
4uestion 1. 1 2. 38 3. 1Gans . 1H %assage(
What is implied b! the argument of a function? 4uestion
1. #he variables passed to it when it is calledans 2. #he value it returns on execution
3. #he execution code inside it . its return t!pe
%assage(
$or solving a problem: which of these is the first step in developing a wor"ing program for it?
4uestion
1. writing the program in the programming language
2. writing a stepb!step algorithm to solve the programans 3. compiling the libraries re9uired.
. Code debugging. %assage(
*nteger a+8:b+3G:c+28:d+18
Comment about the output of the following two statements( %rint a>b/cd
%rint a>b/,cd
Choose the correct answer
6ssume the following precedence ,high to low.operators in the same row have the same precedence(
• ,. • > / • 0 • 67D • OR
$or operators with e9ual precedence: the precedence is from left to right in expression
4uestion 1. Differ b! I8 Jans 2. 5ame 3. Differ b! G8 . Differ b! 1H8 %assage
6s part of the maintenance wor":Kou are entrusted with the wor" of rearranging the librar! boo"s in a shelf in proper order: at the end of each da!. #he ideal choice will be 4uestion 1. Aubble sort 2. *nsertion sortans 3. 5election sort . )eap sort 4uestion
Which one of the following is not a program control instruction? 1. L;%
2. C6FF J675 3. R#
4E5#*O7
$or 9 relation R,6:A:C:D::$ given are functional dependencies on R 1. 6A
2. CD
3. DA$
. $C
Which of the following functional dependencies is not true for R? 1. D6$ 2. CA 3. 6$DA . $D %6556M( *nteger num1:num2 *nput num1:num2 *nteger "+8:final+num1 //missing statements %rint final
Choose the correct answer(
6 pseudocode is used which is self explanator!. // in pseudo code refers to comment
Reema wanted to multipl! two numbers but the > "e! of her "e!board is
bro"en.she decides to write the program without using N operator. 5he writes the given code:where some statements are missing.
What should be the missing statements in the given code? 1. While,"00 - num1 final0+num1 2. While,"00 - num21 $inal0+num1 3. While,"00 -+num2 $inal0+num1 . While ,"00 - num2 $inal0+num2 %assage( $unction modif!,!:< !+!01= <+<01= return ! J < $unction calculator, *nteger a+G: b+18: c C+modif!,a:b=
%rint a %rint space %rint c
Consider the code given in the passageP. 6ssume that a@ and b@ are passed b! value. What will the output of the program be when the function calculate, is executed?
1. 11/8G/1G 2. 18/8G/1G 3. 8H/8G/1G . 8G/8G/1Gans
6 programmer wants the program given below to print the largest number out of three numbers entered b! the user(
*nt number1:number2:number3:temp= *nput number1:number2:number3= *f,number1Qnumber2 temp + number1 else temp + number2 end if if,?? // statement1 temp+number 3 end if
print temp
which of the following should be substituted in place of ??@ in statement 1 in the code? 1.number3Qnumber2 2. number3Qtemp 3. number3-temp . number3Qnumber1 4uestion
Which of the following is not a data t!pe 1. *nteger
2. Character 3. Aoolean . 6rra!ans
4uestion
7alanda wants to implement virtual functions. which of the following options will she have to following in order to bring out the same?
1. D!namic dispatching 2. 5tatic dispactching 3. 5tatic binding . 6non!mous class
4uestion
1. Ese bubble sort to sort the list in a descending order and then print the first number of the series
2. Ese selection sort to sort the list in a desc ending order and then print the first number of the series
3. *mplement one iteration of selection sort for descending order and print the first number in the seriesans
. 7one of the above
4uestion
What is the minimum numbers of stac"s of si<e n@ re9uired to implement a 9ueue of si<e n@? 1. 1 2. 2 3. 3 . 4uestion
%reeti writes a program in a low level language: now she wants to translate it into a higher language without rewriting the program: what another program she must use for this purpose?
1. Compilerans 2. Decompiller 3. *nterpreter
. xecuter G. Cross compiler
4uestion
6ssume the following precedence ,high to low. Operators in the same row have the same precedence.
• ,. • > / • 0 • 67D • OR
#he precedence is from left to right for the operators with e9ual precedence. What will the output of the following code statements?
*nteger a+G8: b+2G: c+G %rint a>b/c0c 1. 128 2. 12G 3. 2GG . 2G8 4uestion
6 programmer writes a program to find an element in the arra! 6GS With elements I 38 8 G T8. #he program is run to find a number U@: that is found in the first iteration of binar! search.what is the value of x@?
2. I 3. T8 . 38
4uestion
)ow man! nodes does a full binar! tree with n@ nonleaf nodes contain? 1. log n
2. n 0 1 3. 2n01 . 2n
4uestion
6 programmer tries to debug a code of 18:888 lines. *t is "now that there is a logical error in the first 2G lines of the code. Which of the following is an efficient wa! to debug the code?
1. Compile the entire code and chec" it line b! line 2. Ese an interpreter on the first 2G lines of codeans 3. Compile the entire code and run it
. 7one of the above can be used to debug the code.
%assage function main, integer i+8.T static float m +8.T if ,m e9uals i
print@we are e9ual@ else if ,mQi print * am Mreater@ else print@* am Fesser@ 4uestion(
What will be the output of the given code? We are e9ual
• * am greater Jans • * am lesser
• #his code wil generate an error
4uestion=
Wh! is an algorithm designer concerned primaril! about the run time and not the compile time while calculating time complexit! of an algorithm?
Run time is alwa!s more than the compile time Compile time is alwa!s more than the run time Compile time is a function of run time
6 program needs to be compiled once but can be run several times675 4uestion=
6 integer U@ is saved as an unsigned Ibit number 88881811.What is U?
• 22 • 11675 • 18
4uestion=
6 full binar! tree with n non Jleaf nodes contains
• ,logn nodes • n01 nodes • 2n01 nodes J675 • 2n nodes 4uestion =
Ravi is writing a program in C00: C00 uses the forP "e!word for loops . Due to distraction :Ravi writes gor intead of forP.What will this result to?
• #he code will not compile675
• #he code will give an error while in execution
• #he code ma! wor" for some inputs and not for others • *t will create no problems
4uestion=
Which of the following sorting algorithms !ields approximatel! the same worst case and averagecase running time behavior in O ,n logn?
• Aubble sort and selection sort • )eap sort and merge sort J675 • 4uic" sort and radix sort
• #ree sort and medianof3 9uic" sort
4uestion=
*n which of the following methods is sorting 7O# possible?
• *nsertion • 5election • xchange • Deletion675 %assage class brush
private( integer si<e :c rcode function getdata,V..//5tatement1 public( integer name//5tatement2 function putdata,V. fuction main brush b1:b2 printb1.name //5tatement 3 b2.getdata,//5tatement 4uestion=
Refer to the pseudocode given in the %assageP . #he code is similar to that in C00 and is selfexplanator!. 6n accessible member function and a data member for an ob'ect are accessed b! statements ob'ectname.functionname and
ob'ectname.datamembername: respectivel!. Which statement should be deleted from the code to rectif! the eroor in it?
• 5tatement 1 • 5tatement 2 • 5tatement 3 • 5tatement 675
4uestion=
#he program to print the sum of all cubes that lie between 8 and 188 is given below. Does this program have an error? *f !es :which statement should be modified to correct the program?
integer i+8:a //5tatement 1 integer sum +8=
a+,i>i>i
while,i-188 //5tatement 2
sum+ sum0a //5tatement 3 i+i01 a+,i>i>i //5tatement print sum • 5tatement 1 • 5tatement 2 J675 • 5tatement 3 • 5tatement 7o error 4uestion =
Which of the following data structures ma! produce an overflow error even though the current number of elements in its lower than its si<e?
• 6 9ueue implemented in a linear arra!675
• 6 9ueue implemented in a circularl! connected arra! • 6 stac" implemented in a linear arra!
• 7one of the above
4uestion=
$unction main is the starting point of execution of a program. Which of the following option shall help in ma"ing an executable program without the use of main function in the program?
• 6n! function can be made and mar"ed as starting point using a language
dependent s!ntax
• #wo macros can be used. One to hold the name of a function and its wor"ing and
the other to call the first macro675
• 6n! program without a main function shall not do an!thing but can onl!
produce a blan" screen
• *t is not possible to run a program without a main function in a program
4uestion=
6 function in the base class is redefined in the inherited class. What is the term used to describe the situation?
• *nheritance • Overriding J675 • Overloading • ncapsulation
4usetion=
#he function given below ta"es a number n@ as the input and calculates the sum of first n@ naural numbers. Which of the following statements should be inserted in place of ??@ to get the re9uired output?
function sum ,n
return 1 else return,n0sum,n1 end n e9uals 1 J675 n e9uals 2 nQ+1 nQ1 4uestion=
Which of the following algorithms is called the shortestremainingtimefirst scheduling?
• %reemptive short 'ob first,5L$ scheduling J675 • 7onpreemptive shortest 'ob first,5L$ scheduling • %riorit! scheduling
• Round robin scheduling
4uestion=
Which of the following option is not a necessar! condition for Deadloc" to occur?
• ;utual exclusion • )old and wait • 7o preemption • Circular wait • 7one of these675
4uestion=
What will happen if some indentations are made in some statements of a code written in C00?
• $aster execution of code
• Fower memor! re9uirement for the code •
Correction of errors in the code
• Aetter readabilit! of the code J675
%assage( function modif!,a:b integer c:d+2 c+a>d0b return c function calculate, integer a+G:b+28:c integer d+18 c+modif!,a:b= c+c0d print c 4uestion=
Consider the code given in the %assageP. 6ssume that a@ and b@ are passed b! the value. What wil be the output of the program be when the function calculate, is executed? • I8 • 8 J675 • 32 • T2 4uestion=
#risha wants to use a data structure in which the cost of deleting: adding and traversing its elements is the same and constant. Which of the following data structures should she use?
• A #ree • 6&F #ree • 4ueue • 5tac" 4uestion=
#he program to print the larger of the two numbers entered b! the user is given below. Which of the following should be substituted in place of ??@ in 5tatement 1
of the code to get the desired output? int number1: number2
input number1: number2 if ,?? //5tatement1 print number1
else
endif Option=
number1Qnumber2 J675 number2Qnumber1 number2 e9uals number1 number1-+number2 %assage(
integer i:":':n +G
for i+n to 1 decreament 1
for '+n to i01 decreament1
print blan"s pace
for "+1 to ,,2>i1 increament 1
print@>@
print endofline //ta"es the cursor to the next line
4uestion=
What will be the output when the given code is executed? a>>>>>
>>>> >>> >> > b>>>>> >>>> >>> >> >675 C>>>>> >>>> >>>>> >>>> >>>>> d > >> >>> >>>> >>>>> e>>>>>>>>> >>>>>>> >>>>> >>>
>
4uestion=
Consider the given conditions in regards to binar! search performed on an named ;!6rra!
1. Aeg Qend 2. Aeg-+end
3. ;!6rra!midS+ itemXtoXbeXsearched
Which of the given conditions forms the termination condition of an iterative binar! search when the variables Aeg:nd and mid have their usual meanings?
• Onl! 1 J675 • Onl! 2 • Onl! 3 • Aoth 2 and 3 • 6ll 1:2 and 3 4uestion=
6ssume the following procedure ,high:low. Operators in the same row have the same procedure. ,. >/ 0 67D OR
#he precedence is from the left to right in the expression for the operators with the e9ual precedence:
Which of the following statements is #RE about the output of the code statements given below?
integer a+8: b+3G: c+28: d+18 print a>b /cd
print a>b/,cd
• the outputs differ b! I8 675 • the outputs are the same • the outputs differ b! G8 • the outputs differ b! 1H8
$rom pg num(3T to H %assage function modif!,!:< <+!01= <+<01= return !< function calculate, integer a+G:b+18:c c+,modif!,a:b= print a print space print c
4uestion=
Consider the code given in the passageP.assume that@a@ and b@ are passed b! value .what will the output of the program be when the function calculate , is executed? • 11/8G/1G • 18/8G/1G • 8H/8G/1G • 8G/8G/1G ,ans 4uestion
)ow man! nodes in a tree with n nodes have no ancestors?
• 8 • 1 • 2
• Fog n,ans
4uestion
6 programmer wants the program given below to print the largest number out of three numbers entered b! the user .
int number 1:number2:number3:temp= input number1:number 2:number3= if,number1Qnumber2 temp+number1 else temp+number2 end if if,??//statement1
temp+number3 end if
print temp
which of the following should be substituted in place of ??@ in statement 1 in the code? • number3Qnumber 2 • number3Qtemp ,ans • number3-temp • number3Qnumber1 9uestion
6 sorting mechanism uses the binar! tree concept such that an! number in the tree is larger than all the numbers in the subtree below it . what is this method called?
• 5election sort • *nsertion sort • )eap sort ,ans • 4uic" sort
4uestion
Which of the following implies that there are two loops that are nested?
• #wo loops: one after the other
• #wo loops : one inside the other ,ans • One loop with two different iteration counts • #wo loops with the same iteration count
4uestion
Which of the following can be inherited b! a derived class from a base class?
• Data members • ;ember functions
• Constructors and destructors
• Data members and member functions ,ans
4uestion
Which of the given function protot!pes can be considered to be overloaded ,no ambiguit!?
a.function m!func ,integer num: float me// does not return an!thing b.function m!func,integer num: double me //does not return an!thing
c.function m!func,character num:float me //does not return an!thing d.function m!func,integer num: float me //returns an integer
• 6 and A • 6:A and C • 6:C and D • A:C and D • Aoth 2 and 4uestion
Which of the following describes a tree ?
• 6 connected graph
• 6 connected ac!clic graph ,ans • 6 complete graph
4uestion
)ow man! nodes does a full binar! tree with n@ non Jleaf nodes contain?
• log n • n01
• 2n01 ,6ns • 2n
4uestion
What is the minimum number of stac"s of si<e n@ re9uired to implement a 9ueue of si<e n@?
• 1 • 2 ,ans • 3 •
Which of the following options is an exception to being a part of composite data t!pes? • Enion • 6rra! 5tructure • 5tac" ,ans 4uestion
#wo programmers independentl! write a program to find the mass of one mole of water : that includes the masses of h!drogen and ox!gen .
#he first programmer defines the variables as( integer h!drogen : ox!gen : water //code 6
the second programmer defines three 9uantities as( integer a: b: c //code A
which of the two is a better programming practice and wh!?
• Code A is better because variable names are shorter.
• Code 6 is better because the variable names are understandable and non
confusing . ,ans
• Code 6 would run correctl! while code A would give an error. • Code A would run correctl! while Code 6 would give an error
4uestion
U and K are as"ed to write a program to sum the rows of a 2x2 matrix stored in an arra! 6.
U writes the code ,code 6 as follows( for n+8 to 1
sum Row1nS+ 6nS 06nS2S end
K writes the code ,Code A as follows( sumRow18S +68S1S 068S2S
sumRow11S +61S1S 061S2S
which of the following statements is correct about these codes if no loop unrolling is done b! the compiler?
• Code 6 would execute faster than Code A.
• Code 6 is logicall! incorrect . • Code A is logicall! incorrect.
4uestion
Which of the following abstract data t!pe can be used to represent a man! to man! relation? • #ree • 5tac" • Mraph ,ans • 4ueue 4uestion
$or which of the following purposes is the construct given below used? if ,condition then 6 else A
• decision Jma"ing ,ans • iteration
• recursion
• ob'ectoriented programming
9uestion (
6 librarian has to rearrange the librar! boo"s on a shelf in aproper order at the end of each da!. Which of the following sorting techni9ues should be the librarianPs ideal choice?
• Aubble sort
• *nsertion sort ,ans • 5election sort • )eap sort
4uestion(
W hich of the following sorting techni9ues has the worst case functioning time less than O,n>n?
• )eap sort • 4uic" sort • *nsertion sort • 5election sort %assage(
5tac" is useful for implementing.
• Radix search • Areadth first search • Recursion ,6ns • 7one of these
4uestion(
What is the term given to the variable whose scope is be!ond all the scopes .i.e..:it can be accesses b! all the scopes ?
• Eniversal variable • Mlobal variable ,ans • xternal variable • 6uto variable • Aoth 2 and 3
4uestion(
Kashi wants to implement priorit! 9ueues using arra!s. What is the minimum number of arra!s that she should use to serve the purpose?
• 1
• 3 •
%assage(
$or solving a problem which of these is the first step in developing a wor"ing program for it?
• Writing the program in the programming language.
• Writing a step b! step algorithm to solve the problem. ,ans • Compiling the libraries re9uired .
• Code debugging.
%assage(
)ow can a call to an overload function to ambiguous?
• A! misspelling the name .
• #here might be two or more functions with the same name .
• #here might be two or more functions with e9uall! appropriate signatures
,ans
• 7one of these
While calculating time complexit! of an algorithm : the designer concerns himself /herself primaril! with the run time and not the compile time .wh!?
• Runtime is alwa!s more than compile time . • Compile time is alwa!s more than run time. • Compile time is a function of runtime.
• 6 program needs to be compile once but can be run several times. ,ans
4uestion (
Which of the following options is an exception to being a part of composite data t!pes?
• Enion • 6rra! • 5tructure
• 5tac" ,ans
4uestion(
Which of the following options is both necessar! and sufficient condition for preparing binar! search?
• 6rra! must be sorted:direct access to the middle element should be
provided. ,ans
• 6rra! should be in ascending order .
• Direct access to the middle element must be provided. • 6rra! should be sorted.
4uestion(
Which of the following statement is not true in the context of anon!mous union data t!pe?
• *t is a union that does not have an! name. ,ans • *t is not followed b! a declarator!.
• *t defines an unnamed ob'ect. • *t defines a data t!pe .
%age no(TGH
Wh! is an algorithm concerned primaril! about the run time and not the compile time while calculating time complexit! of an algorithm?
• Run time is alwa!s more than the compile time • Compile time alwa!s more than the run time • Compile time is a function of run time
• 6 program needs to be compiled but once can be run several times ,ans
#wo programmers independentl! write the program to find the mass of one mole of water: that includes the masses of h!drogen and ox!gen.
#he first programmer defines the variables as( *nteger h!drogen : ox!gen :water // code 6 #he second programmer defines the 9uantities as( *nteger a: b: c // code A
Which one of a two is better and wh!?
• Code A is better because variable names are shorter
• Code 6 is better because variable names are understandable and non
confusing ,ans
• Code 6 would run correctl! while code A would give an error • Code A would run correctl! while code 6 would give an error
%arthiv has included several classes and their several ob'ects in his pro'ects.7ow he wants to use something that will hold all these ob'ects,of different
classes.which one of the following option provides him with the best alternate?
• 5tore them in database • $inal class
• Meneric class ,ans • 6non!mous class
*n a linear list of elements : a deletion can be made from one end ,front and an insertion can be made at the other end,rear.what is this linear list "nown as?
• 4ueue ,ans • 5tac" • #ree • Aranch
What is the first step for developing wor"ing program to solve a problem?
• #o write the program in the programming language
• #o compile the re9uired libraries • #o debug the code
ver! element of an data structure has an address and a "e! associated with it. 6 search mechanism deals with the two or more values assigned to the same address b! using the "e! . what is this search mechanism?
• Finear search • Ainar! search
• )ash code search ,ans • 7one of the above
)ow man! nodes does a complete binar! tree with G levels have : if the root is considered to be at 1? • 1H • 2G • H3 • 31 ,ans %assage Enion m!union 5tructure m!structure *nteger m= $loat n( Character 8 m!str *nteger p=
m!union
Miven that the si<e of integer is 2 units : float is units character is 1 unit : what will be the amount of memor! occupied b! the m!union ob'ect?
• 2 units • H units • T units • Y units ,ans
6 program to be solved is bro"en into the se9uence of smaller of subproblems unit a stage where the subproblem can be easil! solved .what is this design approach called?
• #op down approach ,ans • Aottom up approach • procedural programming • 7one of the above
*n which one of the following method is sorting not possible?
• *nsertion • 5election • xchange • Deletion ,ans
Which one the following gives the maximum nodes at level *@ of a binar! tree ? • 2*1,ans • 3*1 • 2* • 2*1
#he function given below ta"es a number n@ as the input and calculate the sum of first n@ natural numbers . which one the following statements should be inserted in place of ??@ to get the re9uired output ?
$unction sum,n *f,?? Return 1 lse Return ,n0sum,n01 nd 7 e9uals 1 ,ans 7 e9uals 2 nQ+1 nQ1
what is implied b! the argument of a function?
• #he variables passed to the function when it is called ,ans • #he value that the function returns on execution
• #he execution code inside the the function • Return t!pe of the function
Which one of the following implies that there are two loops that are nested?
• #wo loops : one inside the another ,ans • One loop with two different iteration count • #wo loops with the same iteration count
%assage
$un m!binar!search,arra! arr : integer low : integer high : integer item
*f, low Qhigh
Return 1
*nteger mid +,low 0 high /2 *f,arrmidS+ e9uals item Return mid lseif ,arrmidSQitem Return lse Return
)arshul uses the given code to implement the binar! search respectivel! . find the statement that will replace missing statement 1 in the given code such that it wor"s efficientl! ?
• ;!binar! search, arr : low 01 : mid 1 : item • ;!binar! search, arr : mid 01 : high 1 : item • ;!binar! search, arr : mid01 : high: item • ;!binar! search, arr: low: mid1 : item ,ans
*n an implementation of a lin"ed list : each node contain data and address . which of the following can the address field possibl! contain?
• 6ddress of the next node in se9uence ,ans • *ts own address
• 6ddress of the last node • 6ddress of the first node
Which one of the following statements is #RE about the variable?
• 6 variable cannot be used before it is declared ,ans • 6 variable cannot be used after it is declared
• 6 variable cannot be used in the function it is declared in • 6 variable can alwa!s be used
•
#he program to print the larger of the two numbers entered b! a user is given below . which one of the following should be replaced in place of ??@ in statement 1
*nt number1:number2 *nput number1:number2
*f,?? print number1 else print number2 end if number1Qnumber2 ,ans number2Qnumber1 number1+number2 number1-+number2
6 programmer writes a program to find an element *n the arra! 6GS with the elements ( I 38 8 G T8 . the program is run to find the number x@ that is found in the first iteration of binar! search . what is the values of x@?
• 8 ,ans • I • T8 • 38 %assage Class brush %rivate( *nteger si<e : c Rcode $unction getdata ,
%ublic( *nteger name $unction putdat , $unction main Arush b1: b2 %rintb1.name A2.getdata
Refer to the pseudocode given in the passage . this code is similar to that in c00 and ic selfexplanator! . an accessible member function and a data member for an ob'ect accessed b! the statements ob'ect name .function name and
ob'ectname.datamembername respectivel! . which statement should be deleted from the code to rectif! the error in it ?
• 5tatement 1 • 5tatement 2 • 5tatement 3 • 5tatement ,ans
)ow can a call to an overloaded function be ambiguous ?
• #he name of the function might have been misspelled • #here might be two or more function with the same name
• #here might be two or more functions with e9uall! appropriate signatures
,ans
#he function given below ta"es the number n@ as the input and calculate the sum of first n@ natural number . which one of the following statement should be inserted in place of ??@ to get the re9uired output?
$unction sum,n *f,?? Return 1 lse Return ,n0sum,n1 nd • 7 e9uals 1 • 7+2 • nQ+1 • nQ1 passage
function preordertraverse ,node %rintnode *f ,condition x preordertransverse,node left *f ,condition ! preordertransverse,node right Return
Consider a three binar! implementations . the root address is stored in the variable root . the address of the node and its right and left child nodes can be accessed using the statements given below
7odeQvalue 7ode Qright 7odeQleft
6 programmer writes the function given in the passage to do a preorder transversal of the tree what are the condition x and ! ?
• Condition x(nodeQ left is not e9ual ,ans
Condition !(nodeQ right is not e9ual
• Condition x(nodeQright is not e9ual
Condition !(nodeQleft is not e9ual
• Condition x(nodeQ left is e9ual
Condition !(nodeQ right is e9ual
• Condition x(nodeQright is e9ual
Condition !(nodeQleft is e9ual
What is the output of the program given below? Integer i=0,j While (i<2) { =0! While (j<="#i) { $rint j
$rintblank spaceblank space
&
$rintend-of-lineend-of-line ''taes the ursorto the ne*t line I=i%+ & a 8 8 3 ,ans b 8 3 8 3 H c 8 8 3 H 8 3 H Y d 8 3 H 8 3 H Y 8 3 H Y 12
What will happen if some inentations are mae in some statements of a oe written in %%?
a $aster execution of the code
b lower memor! re9uirement for the code c correction of errors in the code
d better readabilit! of the code ,ans
- programmer mistaenl. writes /gor instea of the e.wor /for use in loops, while writing a program in 1%%what will this result in?
a #he code would not compile. ,ans
b #he code would give an error while execution.
c #he code ma! wor" for some inputs and not for the others. d #he code would not create an! problem.
-n integer /3 is save as an unsigne 45bit number 0000+0++what is 3?
a 22 b 11 ,ans
c 18
d 7one of the above
Whih of the following sorting algorithms .iels appro*imatel. the same worst5ase an average5ase running time behavior in 6 (n logn)?
a Aubble sort and selection sort b )eap sort and ;erge sort ,ans
c 4uic" sort and Radix sort
d #ree sort and ;edianof3 4uic" sort
- programmer writes a sorting algorithm that taes ifferent amount of the time to sort two ifferent lists of e7ual si8e what is the possible
ifferene between the two lists?
a 6ll number in one lists are more than 188 while in the other are less than 188. b #he ordering of numbers with respect to the magnitude in the two lists has
different properties.,ans
c One list has all negative numbers while the other has all positive numbers. d One list contains 8 as an element while the other does not.
What will the output of the following pseuo oe statements be? (9ote: -ssume that when two ata t.pes are proesse through an
operatorthe answer maintains the same ata t.pe as that of the input-lso all the ata t.pes have enough range to aommoate an. numberif two ifferent atat.pes are operate upon,the result assumes the ata t.pe that is more e*pressive) Integer a=;,b,, =+0 b= a' = a5b print a 18 b 18. c 11. d 11,ans
>he funtion given below taes a number /n as the input an alulates the sum of the first /n natural numbers Whih of the following statements shoul be inserte in plae of?? to get the re7uire output?
untion sum (n) { if (??) return + else return (n% sum (n5+)) en
&
a n e9uals 1 ,ans b n e9uals 2
c nQ+1
d nQ1
In whih of the following situations an a onstrutor be invoe?
a When an ob'ect is created,ans
b When an ob'ect is assigned the value 8 c Onl! at the end of the code
d When the scope of the ob'ect is over
- programmer prepares a 7uestionnaire with /true or false t.pe of 7uestions @e wants to efine a ata t.pe that stores the responses of the aniates for the 7uestions Whih of the following is the most suite ata t.pe for this purpose?
a *nteger b Aoolean,ans
c $loat d Character
- sorting mehanism uses the binar. tree onept suh that an. number in the tree is larger than all the numbers in the sub5tree below it What is this metho alle?
a 5election sort b *nsertion sort c )eap sort ,ans d 4uic" sort
- programmer mistaenl. writes /gor instea of the e.wor /for use in loops, while writing a program in 1%%what will this result in?
a #he code would not compile. ,ans
b #he code would give an error while execution.
c #he code ma! wor" for some inputs and not for the others. d #he code would not create an! problem.
- programmer writes a sorting algorithm that taes ifferent amount of the time to sort two ifferent lists of e7ual si8e what is the possible
ifferene between the two lists?
a 6ll number in one lists are more than 188 while in the other are less than 188. b #he ordering of numbers with respect to the magnitude in the two lists has
different properties.,ans
c One list has all negative numbers while the other has all positive numbers. d One list contains 8 as an element while the other does not.
Aefer to the pseuo oe given in the BpassageC >he oe is similar to that in 1%% an is self5e*planator. -n aessible member funtion an a ata member for an objet are aesse b. the statements
objectname.functionname
objectname.functionnameanobjectname.daobjectname.datamembernatamembername, me, respectivelyrespectively Whih statement shoul be elete from the oe to retif. the error in it? 1lass brush { $rivate: Integer si8e, roe funtion getata(){D&''statement + publi:
integer name''statement 2 funtion putata(){D& & untion main { Erush b+, b2
$rint b+ 9ame ''statement " E2getata()''statement ; & a statement 1Z bstatement 2 cstatement 3 d statement ,ans
@ow man. noes oes a full binar. tree with /n leaves ontain?
a 2n01 nodes b Fog2n nodes
c 2n1 nodes ,ans d 2n nodes
Whih of the following ata strutures ma. proue an overflow error even though the urrent number of elements in it is lower than its si8e?
a 6 9ueue implemented in a linear arra! ,ans
b 6 9ueue implemented in a circularl! connected arra! c 6 stac" implemented in a linear arra!
>he funtion given below taes a number /n as the input an alulates the sum of the first /n natural numbers Whih of the following statements shoul be inserte in plae of?? to get the re7uire output?
untion sum (n) { if (??) return + else return (n% sum (n5+)) en &
a n e9uals 1 ,ans b n e9uals 2
c nQ+1
d nQ1
- programmer writes a oe snippet in whih a set of three lines ours ten times in ifferent parts of the program When programming onept shoul be use to shorten the oe length?
a $or loops b $unctions ,ansc 6rra!s
d Classes
Aefer to the pseuo oe given in the BpassageC >he oe is similar to that in 1%% an is self5e*planator. -n aessible member funtion an a ata member for an objet are aesse b. the statements objectname,objectname,
functionnam
functionnameeanobjectname, objectname, datamemberndatamembername,ame, respetivel., what an be inferre from this oe?
{ $ivate:
Integer height,weight $ubli: ''statement +
funtion input(int a , int b) { height=a! weight=b! & & funtion main () { Aoet roet+,roet2 &
a roc"et@ is a class with roc"et 1@ and roc"et 2@as its ob'ects. With height@ and weight@ as its attributes.,ans
b roc"et@ is a class with roc"et 1@ and roc"et 2@as its ob'ects. With height@ and weight@ as its ob'ects.
c roc"et@ is a class with roc"et 1@ and roc"et 2@ height@ and weight@as its attributes. d roc"et@ is a class with roc"et 1@ and roc"et 2@ height@ and weight@
as its ob'ects.
- programmer prepares a 7uestionnaire with /true or false t.pe of 7uestions @e wants to efine a ata t.pe that stores the responses of the aniates for the 7uestions Whih of the following is the most suite ata t.pe for this purpose?
a *nteger b Aoolean,ans
c $loat d Character
>wo programmers inepenentl. write a program to fin the mass of one mole of water that inlues the masses of h.rogen an o*.gen
>he first programmer efines the variables as:
Integer hydr
Integer hydrogen, oxygen, watogen, oxygen, water//code Aer//code A
>he seon programmer efines three 7uantities as:
Integer a, b, c /
Integer a, b, c //code /code
Whih of the two is a better programming pratie an wh.?
a Code A is better because variable names are shorter .
b Code 6 is better because the variables names are understandable and nonconfusing.,ans
c Code 6 would run correctl! while code AZwould give an error. d Code A would run correctl! while Code 6 would give an error.
- sta is implemente as a linear arra. -F0D95+G- programmer writes the funtion given below to pop out an element from the sta untion $6$(top,9) { If(3) { >op=top5+ & else { $rintunerflow
&
Aeturn top &
Whih of the following shoul substitute the onition /3?
a #op-71 b #op-7
c #opQ1 d #opQ+8,ans
- funtion in the base lass is reefine in the inherite lass What is the term use to esribe this situation?
ainheritance boverriding,ans
coverloading d encapsulation
In whih of the following situations an a onstrutor be invoe?
a When an ob'ect is created,ans
b When an ob'ect is assigned the value 8 c Onl! at the end of the code
d When the scope of the ob'ect is over
1onsier a binar. tree implementation >he root aress is store in the variable root >he aress of a noe is given in the variable noe >he value of the noe an its right an left hil notes an be aesse using the statements given below
9oe5Hvalue, 9oe5Hright, 9oe5Hleft
- programmer writes the funtion given in the BpassageC to o a preorer traversal of the tree
What are onition 3 an onition ? untion preorertraverse(noe)
{
$rint noe 5Hvalue If (onition *) {preorertraverse(noe5Hleft)& If (onition ) {preorertraverse(noe5Hright)& Aeturn &
acondition U(nodeQleft is not e9ual condition K(nodeQright is not e9ual,ans b condition U(nodeQ left is not e9ual
condition K(nodeQ right is not e9ual c condition U(nodeQleft is e9ual condition K(nodeQright is e9ual d condition U(nodeQright is e9ual condition K(nodeQleft is e9ual
Whih of the following implies that there are two loops that are neste ?
a #wo loops:one after the other b #wo loops:one inside the other,ans
c One loop with two different iteration counts d #wo loops with the same iteration count
- programmer prepares a 7uestionnaire with /true or false t.pe of 7uestions @e wants to efine a ata t.pe that stores the responses of the
aniates for the 7uestions Whih of the following is the most suite ata t.pe for this purpose?
a *nteger b Aoolean,ans
c $loat d Character
6 programmer wants the program givren below to print the largest number out of three numbers entered b! the user.
int number1: number2: number3: temp= input number1: number2: number3= if,number1Qnumber2 temp+number1 else temp+number2 end if if,??//5tatement 1 temp+number3 end if print temp
Which of the following ashould be substituted in place of ??@ in the ststement 1 in code?
a number3Qnumber2 b number3Qtemp ,ans
c number3-temp d number3Qnumber1
Which of the following statements is #RE about a variable ? a 6 variable cannot be used before it is declared ,ans b 6 variable cannot be used after it is declared
d 6 variable can alwa!s be used
#he programmer mista"enl! writes gor@ instead of the "e!word for@ used in loops: while writing a program in C00. What will this result in?
a #he code would not compile. ,ans
b #he code would give an error while execution.
c #he code ma! wor" for some inputs and for the other . d #he code would not create an! problem.
Wh! is an algorithm designer concered primaril! about the run time and not the compile time while calculating time complexit! of an algorithm?
a Run time is alwa!s more than the compile time. b Compile time is alwa!s more than the run time.
c Compile time is a function of run time.
d 6 program needs to be compiled once but can be run several times. ,ans 6 programmer writes a sorting algorithm that ta"es different amount of time to sort two different lists of e9ual si<e. What is the possible difference between the two lists?
a 6ll numbers in one list are more than 188 while in the other are less than 188
b #he order of numbers with respect to the magnitude in the two lists has different properties. ,ans
c One list has all negative numbers while the other has all positive numbers. d One list contains 8 as an element while the other does not.
6 programmer prepares a 9uestionnaire with true or false@ t!pe of 9uestions. )e wants to define a data t!pe that stores the response of the candidate for the 9uestions. Which of the following is the most suited data t!pe for this purpose?
a *nteger b Aoolean
c $loat d Character
Wh! is an algorithm designer concered primaril! about the run time and not the compile time while calculating time complexit! of an algorithm?
a Run time is alwa!s more than the compile time. b Compile time is alwa!s more than the run time.
c Compile time is a function of run time.
d 6 program needs to be compiled once but can be run several times.
%assage class brush private( integer si<e:c rcode
function getdata, V..//5tatement 1 public( integer name//5tatement 2 function putdata,V. function main brush b1:b2
print b1.name //5tatement 3 b2.getdata, //5tatement
Refer to the pseudocode given in the %assageP. #he code is similar to that in C00 and is selfexplanator!. 6n accessible member function and a data member for an ob'ect are accessed b! the statements ob'ectname.functionname and ob'ectname.datamember name: respectivel!. Which statement should be deleted from the code to rectif! the error in it.
a 5tatement 1 b 5tatement 2
c 5tatement 3 d 5tatement
Which of the following gives the maximum number of the nodes at level *@ of a binar! tree? a 2*1 b 3*1 c 2* d 2* J 1
Which of the following atatements is #RE about a breadth first search? a Aeginning from a node: all the ad 'acent nodes are traversed first. ,ans b Aeginning from a node: each ad'acent node is full! explored before
traversing next ad'acent node.
c Aeginning from a node: the nodes are traversed in c!clic order. d 7one of the above.
#he programmer prepares a 9uestionnaire with true or false@ t!pe of 9uestions. )e wants to define a data t!pe that stores the response of the candidate for the 9uestions. Which of the following is the most suited data t!pe for this purpose?
a *nteger b Aoolean
c $loat d Character
Wh! is an algorithm designer concered primaril! about the run time and not the compile time while calculating time complexit! of an algorithm?
a Run time is alwa!s more than the compile time. b Compile time is alwa!s more than the run time.
c Compile time is a function of run time.
d 6 program needs to be compiled once but can be run several times. ,ans
6 programmer is ma"ing a database of animals in a <oo along with their
herbivorous: color and nocturnal: the programmer uses the ob'ectoriented programming paradigm for this. )ow will the s!stem be conceptuali<ed?
a class( 6nimal= ob'ects( dog:lion and <ebra= data member s( herbivorous: color and nocturnal ,ans
b class( 6nimal= ob'ects( herbivorous: color and nocturnal= data members( dog:lion and <ebra
c classes( dog:lion and <ebra= ob'ects( 6nimal= data members( herbivorous:color and nocturnal
d 7one of the above
*n an implementation of a lin"ed list: each node contains data and address. Which of the following can the address field possibilit! contain?
a 6ddress of the next node in se9uence b *ts own address
c 6ddress of the last node d 6ddress of the first node
6 programmer prepares a 9uestionnaire with @true or false@ t!pe of 9uestions. )e wants to define a data t!pwe that stores the response of the candidates for the 9uestions. Which of the following is the moist suited data t!pe for this
purpose?
a *nteger
b Aoolwan ,ans c $loat
d Character
#wo programmers independentl! write a program to find the mass of one mole of water: that includes the masses of ox!gen and h!drogen.
Integer hydrogen,oxygen,water // Code A
#he second programmer defines three 9uantities as( Integer a,b,c // Code B
Which of the two is a better programming practice and wh!? a Code A is better because variable names are shorter.
b Code 6 is better because the variables names are understandable and non confusing. ,ans
c Code 6 would run correctl! while Code A would give an error. d Code A would run correctl! while Code 6 would give an error.
What is the first step for developing a wor"ing program to solve a problem?
a #o write the program in the programming language. b #o write a stepb!step algorithm to solve the problem.
c #o compile the re9uired libraries. d #o debug the code.
Which of the following algorithm design techni9ues is used in the 9uic" short algorithm?
a D!namic programming b Aac" trac"ing
c Divide and con9uer d Mreed! search
)ow can a call to an overloaded function be ambiguous? a #he name of the function might have been misspelled b #here might be two or more functions with the same name
c #here might be two or more fun ctions with e9uall! appropriate signatures d 7one of the above
#he function given below ta"es a number n@ as the input and calculates the sum of first n@ natural numbers. Which of the following statements should be insertedin place of ??@ to get the re9uired output?
function sum,n if,?? return 1 else return ,n0sum ,n1 end
a n e9uals 1 ,ans b n e9ua=s 2
c nQ+1 d nQ1
6 programmer writes a code snippet in which a set of three lines occurs ten times in different parts of the program. What programming concept should be used to shorten the code length?
a $or loops b $unctions
c 6rra!s d Classes
*n an implementation of a lin"ed list: each node contains data and address: which of the following can the address field possibl! contain?
a 6ddress of the next node in se9uence b *ts own address
d 6ddress of the first node
Which of the following can be inherited b! a derived class from a base class? a Data members
b ;ember functions
c Constructor and destructor
d Data members and member functions
6 programmer tries to debug a code of 18:888 lines. *t is "nown that there is a logical error in the first 2G lines of the code. Which of the following is an efficient wa! to debug the code?
a Compile the entire code and chec" it line b! line. b Ese an interpreter on the first 2G lines of code. ,ans
c Compile the entire code and run it.
d 7one of the above can be used to debug the code.
Whih of the following statements is >AJK about a breath first searh?
a Aeginning from a node: all the ad'acent nodes are traversed first ,ans b Aeginning from a node: each ad'acent node is full! explored before
traversing the next ad'acent node
c Aeginning from a node: the nodes are traversed in c!clic order d 7one of the above
@ow an a largest number in a list of twent. numbers be foun?
a Ese bubble sort to sort the list in a descending order and then print the first number of the series
b Ese selection sort to sort the list in a descending order and then print the first number of the series
c *mplement one iteration of selection sort for descending order and print the first number in the series ,ans
d 7one of the above
What is the output of the program given below? Integer i= 0,j While(i<2) { =0! While(j<="#i) { $rint j
$rint blan spae =j%"
&
$rint en5of5line ''taes the ursor to the ne*t line i= i%+ & a 8 8 3,ans b 8 3 8 3 H c 8 8 3 H 8 3 H Y d 8 3 H 8 3 H Y 8 3 H Y 12
-ssume the following preeene (high to low) 6peraters in the same row have the same preeene
#' % 5 -9L 6A
>he preeene is the from the left to right in the e*pression for the operators with e7ual preeene
Whih of the following statements is >AJK about the output of the oe statements given below?
Integer a = ;0, b = ", = 20, =+0 $rint a#b'5
$rint a#b'(5)
a #he outputs differ b! I8.,ans b #he outputs are the same.
c #he outputs differ b! G8. d #he outputs differ b! 1H8.
In whih of the following situation an a onstrutor be invoe?
a When an ob'ect is created
b When an ob'ect is assigned the value 8 c Onl! at the end of the code
d When the scope of the ob'ect is over ,ans
What will happen if some inentations are mae in some statements of a oe written in 1%%?
a $aster execution of the code
b Fower memor! re9uirement for the code c Correction of errors in the code
Whih of the following an be inherite b. a erive lass from a base lass?
a Data members b ;ember functions
c Constructors and destructors
d Data members and member function ,ans
@ow man. noes oes a full binar. tree with /n leaves ontain?
a 2n01 nodes b Fog2n nodes
c 2n1 nodes ,ans d 2n nodes
- sorting algorithm traverses through a list, omparing ajaent
elements an swithing them uner ertain onitions What is the sorting algorithm alle?
a *nsertion sort b )eap sort
c 4uic" sort d Aubble sort ,ans
- programmer mistaenl. writes /gor instea of the e.wor /for use in loops, while writing a program in 1%%what will this result in?
a #he code would not compile.,ans
b #he code would give an error while execution
c #he code ma! wor" for some inputs and not for the others d #he code would not create an! problem
Whih of the following sorting algorithms .iels appro*imatel. the same worst5ase an average5ase running time behavior in 6 (n logn)?
a Aubble sort and selection sort b )eap sort and merge sort ,ans
c 4uic" sort and radix sort
d #ree sort and medianof3 9uic" sort
- programmer writes a program to fin an element in the arra. -FG with the elements: 4 "0 ;0 ; M0 >he program is run to fin a number /3, that is foun in the first iteration of binar. searh What is the value of /3?
a 8 ,ans b I
c T8 d 38
Whih of the following is the lowest level format to whih the omputer onverts a program in a higher language before e*eution?
a nglish code
b ;achine code ,ans c 6ssembl! language d 5!stem language
What is implie b. the argument of a funtion?
a #he variables passed to the function when it is called ,ans b #he value that the function returns on execution
c #he execution code inside the function d Return t!pe of the function
a 6mount of hard dis" space re9uired to store the program b 6mount of hard dis" space re9uired to compile the program
c 6mount of memor! re9uired for the program to run ,ans d 6mount of memor! re9uired for the program to compile
Whih of the following sorting algorithms .iels appro*imatel. the same worst5ase an average5ase running time behavior in 6 (n logn)?
a Aubble sort and selection sort b )eap sort and merge sort ,ans
c 4uic" sort and radix sort
d #ree sort and medianof3 9uic" sort
or whih of the following is the sta implementation useful?
a Radix search
b Areadth first search c Recursion ,ans d 7one of the above
>he funtion given below taes an even integer /n as the input an alulates the sum of first /n even natural numbers >he funtion is alle b. the statement /sum ("0) @ow man. times will the funtion /sum be alle to ompute the sum?
untion sum(n) { If (n e7uals 2) Aeturn 2 else return (n% sum(n52))
en & a 1 b 38 c 1G ,ans d 1H
- eveloper writes the program given below to print the sum of the first five whole numbers (0D;) Is the program orret? If not, whih statement
shoul be moifie to orret the program? Integer I =0 '' statement +
Integer sum =0 '' statement 2 While (i<) '' statement " {
Num =i#I '' statement ; I=I %+ '' statement &
$rint sum '' statement
a 7o error: the program is correct b 5tatement 1
c 5tatement ,ans d 5tatement H
What will happen if some inentations are mae in some statements of a oe written in 1%%?
a $aster execution of the code
b Fower memor! re9uirement for the code c Correction of errors in the code
d Aetter readabilit! of the code ,ans
• 6n unconnected graph • 6 connected graph
• 6n connected ac!clic graph6 • 6 complete graph
Which of the following can be inherited from derived class to base class?
• Data members • ;ember functions
• Constructors and destructors
• Data members and member functions[6
What does function overloading impl!?
• ;an! function definitions with same name: same arguments and different
return t!pes
• ;an! function definitions with the same name and different arguments6 •;an! functions definitions with the same name and same arguments • 7one of the above.
6 programmer mista"enl! writes got@ instead of the "e!word for@ used in loops: while writing a program in c00 . What will this result in?
1.#he code would not compile.6
2.#he code would giver an error while execution.
3.#he code ma! wor" for some inputs and not for others. .#he code would not create an! problem.
6 librarian has to rearrange the librar! boo"s on a shelf in p8roper order at the end of each da!. Which of the following sorting techni9ues should be the librarianPs ideal choice?
1. Aubble sort 2.*nsertion sort6 3.5election sort .)eap sort
6 programmer is ma"ing a database of animals in <oo along with their
properties. #he possible animals are dog: lion and <ebra. ach one has attributes as herbivores: color and nocturnal. #he programmer uses the ob'ectoriented programming paradigm for this. )ow will the s!stem be conceptuali<ed?
1.Class( 6nimal: ob'ects( dog: lion and <ebra= data members= herbivores: color and nocturnal6
2.Class( 6nimal= ob'ects( herbivorous: color and nocturnal= data members ( dog: lion and <ebra
3.Classes( dog: lion and <ebra= ob'ects( 6nimal= data members( herbivorous: color and nocturnal
.7one of the above
Which of the following implies that there are two loops that are nested? 1.#wo loops: one after the other
2.#wo loops: one inside the other6
3.One loop with two different iterations counts .#wo loops with same iteration count
6 destructor ma! be invo"ed in which of the following situations? 1.When the ob'ect is created
2.When the ob'ect is assigned value 8 3.Onl! at the end of the code
.When the scope of the ob'ect is over6
What is space complexit! of a program?
1.6mount of harddis" re9uired to store the program
2.6mount of hard dis" space re9uired to compile the program 3.6mount of memor! re9uired b! the program to run6 .6mount of memor! re9uired for the program to compile
While calculating time complexit! of an algorithm: the designer concerns himself/herself primaril! with the runtime and not the compile time. Wh!? 1.Run time is alwa!s more than the compile time.
2.Compile time is alwa!s more than run time. 3.Compile time is a function of run time:
.6 program needs to be compiled once but can be run several times.6
Which of the following sorting algorithms !ield approximatel! the same worst case and averagecase running time behavior in 8,n log n?
1.Aubble sort and selection sort. 2.)eap sort and merge sort.6 3.4uic" sort and radix sort.
.#ree sort and median of 3 9uic" sort.
5ru'an writes a sorting algorithm. #he algorithm ta"es different amount to sort two different lists of e9ual si<e. What is the possible difference between the two lists?
1.6ll number in one list are more than 188: while in the other are less than 188. 2.#he ordering of numbers with respect to magnitude in two list has different properties.6
3. One list has all negative numbers: while the other has all positive numbers. .One list contains 8 as an element: while the other does not.
Consider the following pseudo code Class brush
%rivate(
function getdata,V// statement 1 public(
integer name// statement 2 function putdata,V.
$unction main
brush b1:b2
print b1.name //statement 3 b2.getdata , //statement
Deleting which line will correct the error in the code? 1.5tatement 1
2.5tatement 2 3.5tatement 3 .5tatement 6
)ow can a call to an overloaded function be ambiguous? 1.A! misspelling the name
2.#here might be two or more functions with same name6
3.#here might be two or more functions with e9uall! appropriate signatures .7one of these
Which one of the following is the lowest level format to which the computer converts a higher language program before execution?
1.nglish code 2.;achine code6 3.6ssembl! language .5!stem language
#anu' writes the code for a function that ta"es as input n and calculates the sum of first n natural numbers.
$unction sum ,n *f ,?? Return 1 lse Return ,n0sum,n1 nd
$ill in?? *n the code.
n e7uals +55-n e7uals 2 nH=+ n<+
consider the following pseudo code class roc"et
%rivate(
*nteger height: weight %ublic( //statement 1 $unction input ,inta: intb
height +a= weight+b= $unction main,
Roc"et: roc"et 1: roc"et2
What can we infer from this code?
• Roc"et is a class with roc"et 1 and roc"et2 as its ob'ects. )eight and
weight are attributes of roc"ets.6
• Roc"et is a class with roc"et1 and roc"et2 as its attributes. )eight and
weight are ob'ects of the class roc"et.
• Roc"et is a class with roc"et1: roc"et2: height and weight as its attributes: • Roc"et is a class with roc"et1: roc"et2. )eight and weight as its ob'ects.
)imanshu wants to write a program to print the larger of the two inputted number. )e writes the following code(
*nt number1:number2 *nput number1:number 2 *f,?? //statement 1 %rint number 1 lse %rint number 2 nd if
$ill in the ?? in statement 1.
• 7umber 1Q number 26 • 7umber2 Q number 1 • 7umber 2 e9uals number 1 • 7umber 1-+number 2
6 stac" is implemented as a linear arra! 68V71. 7oor writes the following functions for popping an element from the stac".
$unction %O% ,top:7 *f,x #op+top1 lse %rint @underflow@ Return top
$ill in the conditions U
• #op-71
• #op
• #opQ1
5rishti writes a program to find an element in the ara! 6G with the following elements in order( I 38 8 G T8. 5he runs the protam to find a number U. U is found in the first itertation fo binar! search. What is the value of U?
• 86
• I
• T8 • 38
6 variable cannot be usedV
• Aefore it is declared6 • 6fter it is declared
• *n the function it is declared in • Can alwa!s be used
5hashi writes a program in c00 and passes it on to pan"a'. %an"a' does some indentation in some statements of the code. What will this lead to?
• $aster execution
• Fower memor! re9uirement • Correction of errors
• Aetter readabilit!6
5tuti is ma"ing a 9uestionnaire of true false 9uestions. 5he wants to define a datat!pe which stores the response of the candidate for the 9uestion. What is the most suited data t!pe for this purpose?
• *nteger • Aoolean6 • $loat • Character