Formatting page ...
\ ST. XAVIER'S INSTIJUTION PANIHATI REHARSAL EXAMINATION 2024-25 COMPUTER APPLICATIONS Maximum Marks: 100 Time Allowed: 2 hours 1 Answer:s to this paper must be written on the paper provided separate~- the question You will not be allowed to write during the first 15 minutes. This time is to be spent rea mg paper. The time given at the head of this paper is the time allowed for writing the answers. This paper is divided into two Sections. . Attempt all questions from Section A and any four questions from Sectwn B. The intended marks for questions or parts of questions are given in brackets f J. SECTION A (Attempt all questions) (20 marks) Question 1 1. Identify the character literals from the following: (a) 0.5 (b) 'a' (c) "A (d) false 2. If int a = 27, int b = 4, then the result of int c =a% bis: (a) 6 (b) 3 / (c) 5 (d) 2 3. Java Virtual Machine is a/an: (a) Interpreter (b} Compiler (c) Machine code ( d) Byte code 4. Which of the following is a Java access specifier? (a) static (b) void (c) private (d) main 5. Output of the statement "TRANSPARENT".compareTo("TRANSITION") is: (a) 11 (b) 9 (c) 19 (d) 7 ----c~ - ~ 0.14 M.nnkn - - - - M n l , o Jt /4 ~ Name the feature in JAVA depicted in the above picture : a) Encapsulation b) Data abstraction c) Polymorphism d) Inheritance What is the Java expression for the formula? ax4 y + bxz + d (a) (a Math.pow(x, 4)) + (b x y) + d (b) (a Math.pow(4,x) y) + (b + x + y) + d 1 I 1' t r) l,1 M,\lh .pow {x, 4 y)) lb x 7.) 1 d lll) No rw ot lht'S( ' t~ . Wh irh of lht' lollt)Wll\fl ,ll'l' Inv alld varl.,bl c 11 ;11m s? la) N lb) (hHth\(' le) \ 1., lll) N \ \\lhk h func tion fi nds thl' num ber ot clem ents in an a rray t ln) l~ngth() (b) leng th le) m untO (d) lc nQ 1 " 0. Whi ch tech niqu e divid es an array into two halve s"/ (a) Linear searc h (b) Bubble sort (c) Bina ry search (d) Selec tion sort " l 1. Whi ch of the following is the corre ct array declaration? (a) al401 int (b) int a[401 (c) [40lf loat a[] (d) None of these '-- 12. Wha t is the defa ult retur n type of the function Math .randomQ? (a) int (b) float (c) doub le (d) char 13. Pa rame ters used in function call state men ts are known as: (a) Defined para mete rs (b) Pass ed para mete rs (c) Actual para mete rs (d) Formal para mete rs 14. A pack age in Java is: (a) A collection of data (b) A collection of functions (c) A collection of class es (d) Nested class 15. A class obje ct is also known as: (a) Iden tifier ( b) Insta nce varia ble (c) Specifier ( d) Modifier " 16. Assertion(A) : ln Java, state men ts writt en in lowe rcase or uppe rcase are treat ed the same. Reason(R) : Java is case -sens itive . (a) Both A a nd R are tru e, a nd R is the corre ct expla nation of A. . (b) Both A and R a re tru e, but R is not the correct expla nation of A. (c) A is true, and R is false. (d) A is false, a nd R is true . 17. Which of the following is not a n Obje ct-Or iente d Prog ramm ing la ngu age , (a) Java (b) Simula (c) Fort ran (d) C -- rs. Consider the following program segmen1 in whi ch the statemen ts are jumb led . Choose the correct 0rd er of statements to swap two variabl es using a third variabl e: void swap (int a, int b) a b = b; = t; int t (1) (2) = (3) O; (4) t = a; (a) (1)(2) (3 ) (4) . (b)(3) (4) (1)(2) (c) (I) (3) (4) (2) (d) (2 ) ( I) (4) (3) , 19. The output of the following code is: char a= 'D'; char b = 'd'; int c =a+ b; System.out.println(c); (a) 168 (b) 186 (c) Dd (d) 681 \ 20. Assertion(A) : Call by value is known as a pure method. Reason(R): The original value of a variable does not change, as operations are performed on copied values. -(a) Both A and Rare true, and R is the correct explanation of A (b) Both A and Rare true, but R is not the correct explanation of A (c) A is true, and R is false. (d) A is false, and R is true. Question 2 (10 x 2=20 marksJ 1. Convert the following mathematical expression into a Java expression : X 2. How many bytes are occupied by the two-dimensional array? 12 2 -3 -4 I 45 34 56 5 7 44 32 23 -9 -5 23 8 3. Give the output of the following method definition: void test( String x, Stringy) { if(x.compareTo(y) > 0) System . out.println(x); else System . out.println(y); lf "URJA" and "UJAN" are passed to the method. 4. Consider the following String array and give the output: String arr(] a: ("NOKIA" , "Cffi:NNAI" , "MUMBAI" , "LUCKNOW" , "JAIPUR"} ; Syatam.out.println(arr(4J . length() > arr[2J .length()) ; System.out.println(arr[2) .aubstrinq(0,3)); 5. Write the output for the following : String sl="Myanmar"; String s2="Malayasia"; String s3="Myami"; ~Systam.out.println(s2. substring(s1.indexOf('m ')+l)); This pap~r consists of 5 orinti::>rf "'"'~-- ~\1~\ l'\\\,,,\1\,\)f\ \\\ \l\ l S \ .l,m1\1~1rt: Tu l:-:.l)); t,. \\ ' ~~,. y- l \ ' y I I 4 t I y S\ ,1\\' t\w ,,~ '. 1\u1J of x ""' y- aly\, - - ; r tlw ,,hov, sl,1 \c,men\ Is t:xcc u\ cd. 7. S\ ,1\C t\w 1m l\l \l\ : S t: d nq 11 ''3 45 "; S tr il\Q a2 " 6'7 " ; Sy a t e a . ou t. .p Sy at ell\ . OUt. ri n tl n (1 1+ 1 2) ; p r in tl n (I n ubl te 9 er .v a lu eO rs aD o u b l (s :i, Rl w ril\' f( sl )+ D o t\w fo \\,)w\n~ l:0 2 )) ; e .p a 1\c usin g the do -while \oop : i11\ s ,,t; for ls \ , a = l 'l. ; :1 > = 3 ; n - "' 2) ~ lem.out.prlnt l11t"Res11I\ =u +s ): ll. If ch,\I' x\ l:,, {'a ' , ' 1.' , '9 ' , .'} ; Wh:\l ,11 -c \ he vu \ucs of p and q'? l:,) inl p==x.\cngth ; (b) int q=x[1)+x \ 2J+x[3) \0 . /\ stud ent ls trying to conver t tl1 e string pres the cube of the ent in st r to an in converted value. teger value, so However, th e co that they can ca logi ca l/ runtim de contains an er lculate e) . Com~ct the ror. Name the er code so that it co S tr in g st r ror (s yn ta x/ mpiles and runs " 8" ; correctly. d ou b le num ~ In te g er .p a r se in t c u b e = in t( st r ); M at h. po w (n um , 3 ); Sy tem . out. println( ouba); SECT ION B (Answer any fo ur questions from this section sh this Section.) ould consist of the programs in ei th er Blue) program enviro Each pr og ra m en vi ro nm en t or nm en t with java sh ou ld be w ri any as the base. tten usi119 vari able desc ri pt io n/ m ne m on ic code pr og ra m is cl ea s so th at th e lo r(y depleted. 9ic o f th e Flowcharts an d al go rit hm s ar Buffered R ea de e no t re r/ quired. Dato Input Stre ...... Q.uest\on 3 am should no t be used in the \) efine a c\ as s programs. Secut'lty w it h th e fo \\o w in \) ata M em be rs g sp ec if ic at io ns: : [1SJ Th e an sw er~ in \.. n - 'To st or e th e na m e of th e se cm it y pe 'l. . h - 'To st or rs on ne l. e th e nu m be r of ho ur s for w hi 3. r - io st or ch w ag es ar e e th e ho ur \y ra to be paid . te . 4. W -T o ca \r n\ at e th e w ag es . Mem be r Fu nc tio ns l . void ge tl) : . To ac ce pt th e na me, hourly 2. void ca\w ag rate, and nu m be eO . To ca lc ul r of ho ur s w or at e th e w ages ke d. of th e securit co nd iti on s: . y pe rs on nel ba se d on th e followm o For th e fir g st 40 ho ur s: ~ r pe r ho ur. For th e ne xt 20 0 ho ur s: t 1.Sr pe r ho ur. For an J . vo id0 di spla y ad di tio na l ho ur s: i( 2r pe r yO _To displa y th e de ta ils of ho ur. . . th e security pe . Output Format: .. . . rs on ne l m th e lollowmg fo1 m Name at . \l ou rs Wage ----- ----- ----- ------ -W ri te a pr og ra ut e th e w . . I I n cond m to ages ac rn rd m itions and di sp . spec ifi ed fonm1t co m p . lay th e output ti d t g to. ttc,e g ve . Also w ri te th in the an object and e mam m e ,o invoke th e fun o cr ctions . -ca ~-- - - - - - - - - - -- - -- - -- - - .. -- \ I Th is pager co nsists of 5 pr in 41 I' :i g (' \ ,v 1ot1 /' ( I151 . roatc 1 Single Oimcnslon cil /\rray wllh tht! gi ven valu es and scMch for an user grven S (I ) C ' , r ,y. If the clement Is found, display th e message "Sea r ch succcssful", with the position of II c display the m essage "Sea rch c le m en t not found" using Binary search techniqu e. ~~,,,.,,rI n I ieotherwise ,, ,1r 11 cla~,- r[Tlent, Jl'e l ients: 12.6, 23.5, 34 .7, 38.0, 45 .2. 56.8. 67. 1, 78 .9, 89.3, 9 1.4 !Jfff)' eIi.111 --~- Question 5 Special words arc those words which start and end with the same letter. l. I Example: 6XISTENCJ:.: COMIC: WINDOW 2. Palindrome words are those words which read the same from left to right and vice-versa . 3 Example: MAlYALAM, MADAM, Ll::VEI,, ROTATOR, CIVIC All palindromes are special words but all special words a re not palindromes. Write a program to accept a word. Check and display whether the word is a palindrome o~ only a special word or none of them. Question 6 Write a program to accept values in a 4 x 4 array and print the original array and print the sum of the right and left diagonal. 4 3 1 2 8 7 6 Example: Input: ~ 4 10 21 -2 4 3 6 Output: Sum of right diagona/=25 Sum of left diagona/=11 Question 7 A balanced number Is a number whose sum of even digits is equal to the sum of odd digits. Eg: 1254 Sum ofeven digits: 2+4=6 Sum ofodd digits: 1 +5=6 Hence 1254 is a balanced digit Write a program to generate and print all the balanced numbers between 1000 and 2000. ,,.--Question 8 Design a class to overload a function structure() as follows : a)void structureQ: to print the following pattern: 12121 12121 12121 12121 b) void structure(int n): to print the following pattern: # # #*# # # #*# # Where n=S(number of rows) c) void structure(String x) : to print the following pattern B BL BLU BLU E BLUEJ where x="BLIJEJ", . .
|