0% found this document useful (0 votes)
97 views6 pages

ICSE Computer Solved Paper 2015

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
97 views6 pages

ICSE Computer Solved Paper 2015

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 6
if(flag == ( System.out printin(c[index] +"-" + wlindex); else ( System.out printin("Sorry NotFound!"); 4 J 1 Name | ‘Type Description wile] | String | To store7 wonders array | and their countries. s String | To store name to be searched. i int | Counter variable. flag int To check the status. index int —_| To store the index | number. COMPUTER APPLICATIONS-2015 SECTION-A (40 Marks) Attempt all questions. Question 1. (a) What are the default values of the primitive data ‘type int and float? [21 (b) Name any too OOP's principles. 121 (oc) What are identifiers ? 21 (a). Identify the literals listed below = el @ 05 ii) “AY Gi) false tiv) “a” (©) Name the wrapper classes of char type and boolean type. BI Answer 1. (a) Default value of int is 0 and float is 0.0f. (b) Encapsulation and Abstraction. (o) Identifiers are a sequence of characters used to name variables, objects, classes, etc. (@ (@ 05isa double/Aoating point literal. Gi) ‘A’ is a character literal. Gii) false is a boolean literal. Giv) “a” is a String literal. (©) For char it is Character and for boolean it is Boolean. Question 2. (@) Evaluate the value of n if value of p = 5, q= 19. intn=(q-p)>(p-9 ? G-P:@- as 2 (o) Arrange the following primitive data types in an ascending order of their size: @ char Gi) byte (ii) double (iv) int [2] (©) What is the value stored in variable res given below : (2) doutle res = Math.pow("345” indexOf’5'), 3); (d) Name the two types of constructors. 2] {e) What are the values of a and b after the following ‘function is executed, if the values passed are 30 and 50; void pauostint a, int b) { gaat; baanb; a=a-bj System.out.prinln(a +“, "+b); } a Answer 2. @) n=14 ) byte, int, © res =8.0 (@) Two types of constructors are (@) Non Parameterized Constructor. Gi) Parameterized Constructor. eg. class Computer (ii) char, (iv) double. String teacher, coaching: public Computer() // Non Para- meterized Constructor t teacher ="Ritu Sharma”; coaching = “Destination Point ‘Computers, MP"; pai Computer(String t, String ¢) // Parameterized Constructor ) (e) Value of a = 50 and b = 30. Question 3. @ ‘e) © &) jure State the data type and value of y after the following is executed : char x = °7", y= Character. isLetter(x); (2) What is the function of catch block in exception handling ? Where does it appear in a progrant ? [2] State the output when the following program segment is executed String a = “Smartphone”, b= "Graphic Art’; String h = a.substring(2, 5); String k= bsubstringt(8).toUpper Caset ); System.out.printin.a); System.out-printin(k.equalsignore Caseth); Q The access specifier that gives ihe most accessibility 5s ssseesestnd the least accessibility is... re) @ Name the mathematical function which is used fo find sine of aa angle given in radians, Gi) Name a string function which removes the, blank spaces provided in the prefix and suffix of astring. [21 (i) What will this code print ? intarr [ ] = new int [5]; System out. printtntarr); @o (b) value stored in arr (0] 0000 (d) garbage value a] Gi) Name the keyword which is used to resolve the conflict between method paremeter and instance variables/felds. a State the package that contains the class : () BufferedReader Gi) Scanner. Write the output of the following prograre code : char che int x= 97; do { ch = (char) x; ‘System out.print(ch + if2%10 = 0) break; +5 J while(x <= 100); Write tie Jour expressions for : a+ 5? Dab [2] If int y= 10 then find int 2 = (44y * (y+ +5); (2) PI Ql An: @ (b) © (ad) te) i) ® @ p Bi swer 3, Data type of y will be boolean and value of y = false. Catch block is a group of Java statements that ate used to handle a raised exception. We can put the code to deal with the execution that might arise, in this block. Catch block appears just after the try block. art true The access specifier that gives che most accessibility is public and the least accessibility is private, () Math.sind Gi) trim, @) @ garbage value Gii) this keyword is used’ to differentiate between local /parameters and global instance variables. (@ Buffered Reader is stored in java.io package. Gi) Scanner is stored in java.util package. abed (atatb*b)/(2*a*b) intz= (Hy * (y++ +5): (1*a1 +5); 17%6 SECTION—B (60 Marks) Attempt any four questions from this Section. The answers in this Section should consist of the Programs in either lue J environment or any program environment ‘with java as the base, Each program should be written using Variable descriptionsiMnemonic Codes 0 that the logic of the program is clearly depicted. Flow-Charts and Algorithms are not required. Question 4. Define a class called ParkingLot with the following description : Instance variables/data members : int uno ~ To store the vehicle number int hours ~To store the number of hours the vehicle és parked in the parking lot double bill - To store the bill mount Member methods + void input )~To input and store the ono and hours. void calculatel )—To compute the parking charge at the rate of €3 for the first hour of part thereof, and © 1.50 for each additional hour of part thereof. void display( )- To display the detail Writea main metitod to create an object of the class sand call the above methods. (a Answer 4. import java.util”; class ParkingLot t int vno, hows; double bill; void input() { Scanner sc= new Scanner(System.in); System.out printin( “Enter vehicle no. and hours"); yno = scnextint(); hows = scnextint(); } void calculate) | if(hours <= 1) ( bill=3; bill =3 + 1.5 * (hours - 1); } } void display) d System.out printin(yno + + hours 4°" + bill); } public static void main(String args[]) { ParkingLot ob = new ParkingLot(); ob.input); ob.calculate(; ob.display; } yno int _| Tostore the vehicle number. hours int To store the number of hours the vehicle is parked. ill double |To store the bill amount. Question 9. Wrile two separate programs to generate the ‘following patterns using iteration (Joop) statements - fa) * “# tee “ay ete (b) 54321 5432 543 54 5 105) Answer 5. (@) class Pattern t intij; void display() t forli= = Spite) forfj= Lj <=i:j++) { if % 2==0) { System.out.print("#"); 1 else { System.out print("*"); } 1 ‘System. out printin(; int | As a loop variable for executing the outer loop int | As a loop variable for executing inner loop} (b) class Pattern { inti, void display() { for(i = 151 <=5;i44) { for()=5;)>=1;j-> namefi] = br.next(); ( mifi} = br.nextDoubleQ; ‘System.out-print(); mQ{i] = br.nextDoubled; | m3fi = br.nextDouble); System.out.printing; } } for(i =O;icnj ity) (l[i] + m2fi] + m3fi]) / 3.0; BE anes Systemout print(mofi] 1" + nameli); int | As a loop variable for avg >= 85 && avg <= 100) ; 4 executing the outer loop. ; mt are ioep vealabte ey System.out printin("EXCELLENT); executing the inner loop. | else iffavg >= 75 &ée avg <= 84) Question 6. { Write « program to input and store rol! numbers, System.out.printin(‘DISTINCTION"); names and marks in 3 subjects of n mumber students } in five single dimensional arrays and display the remark based on average marks as given below : (The else iffavg >= 60 &eée avg <= 74) i { ‘evant ne weer 100) _ System out pinHIRST CLASS); Average marks Remark else avg >= 40 &fe avg <- 59) 85-100 EXCELLENT ( 75-84 DISTINCTION System.outprintin(’PASS"); | 60-74 FIRST CLASS Le 40-59 Pass ( Less thane 40 POOR Us) System.outprintha("POOR’); Answer 6. ! ienport java.util’; class Remark } t - = int n, , mol]; ‘Description: Sng Taal mae double avg, mi(], 20} m3); mof] | int To store roll number of void display() shidents in one array. t mil] int | To store marks of Scanner br = new Scanner(System in}; students in an array. System.out.printin("Enter no. of students" m2] [int |To store marks of n=brnextint(; students in an array. mo = new int{n]: maf] |int [To store marks of name = new String(n]; students in an array ml = new double{n|; name[] | String |To store names of an2= new double[n]; students in an array. an3 = new double{n avg double To aculeuste average ford Oh ewviee) i int__| Asa loop variable. { em in, Question 7. System.out println("Enter the Details’); Design a class to overload a function Joystring() as ‘mofi] = br.nextint(); ‘follows (i) void joystring (String s, char chi, char ch2) with one string argument and two character arguments that replaces the character argument ch1 with the character argument ch2 in the given strings and prints the new string. Example : Input value ofs = “TECHNALAGY” chi ='A’, ch2 =O" Output : “TECHNOLOGY” (ii) void Joystring (String 5) with one string argument that prints the position of the first space and the last space of the given string s. Example: Input value of ="Cloud computing means Internet based computing” Output : First index :5 Last index : 36 Git) void Joystring (String sl, String s2) with two string arguments that combines the two strings with a space between them and prints Answer 7. the resultant string. Example + Input value of s1 = “COMMONWEALTH” Input value of s2="GAMES” Output : “COMMONWEALTH GAMES” (use library functions) sl class Overload { void joystring(String s, char cht, char ch2) { s=s.replace(ch1, ch2); ‘System.out println(s); } void joystring(String s) { int£ Ly f=s.indexOf{’ '); L=sllastindexO1( 9}; Systern.out.printhn("First index "+0); System.out printin("Last index "+); ! void joystring(String sl, String s2) { Strings =s1+""+ Systern out printin(s); 1 public static void main(String args{)) 4 Overload obj = new Overload(); bj joystring("TECHNALAG ; obj,joystring(’Cloud computing means Internet based computing"); obj joystring(COMMONWEALTH", "GAMES'), tion | Type | Description | String |To store a string} a ‘cht char |To store a character) argument. i ch? char |To store another ‘character argument, | f int To find the position of! first space in the string. , 1 | int To find position of last” | i } space in the string. sl String |To store a string| | argument, s2 String [ze store another string! a Question 8. Write a program to input twenty names in a array. Arrange these names in descending order of alphabets, using the bubble sort teckarique. (35) Answer 8. import java.util; class BSort t inti, j; String namef] = new String{20[ String t; void display() t Scanner br = new Scanner(System.in); forli = 0; i < 20; i++) tl System out printin("Enter a Name"); name[i] = br.next(); H for(i =0;1< 20-1; i++) ( for(j =0;) <19-i;je4) { if{name[j].compareTo (namefj + 1)< { t=namefj}; name[j} = namefj + 1); namelj +1} = t 1 1 for(i = 0; i < 20; i++) { System.outprintIn(nameli]); Deseription int | As a loop variable for onter loop. i int | As a loop variable for inner loop. namel] | String | To store 20 names in an array. + | String |Used to store a temporary variable. Question 9. Using the switch statement, write a menu driven program to: Gi) To find and display all the factors of a number input by the user (including 1 and excluding nuraber itself). Example : Sample Input : Sample Output : 1, 3, 5 i) To find and display the factorial of a number input by the user (the factorial of a non-negative integer n, denoted by nl, is the product of all System.outprintin(’L. Factors"); ‘System.out printin("2. Factorial"); ‘System.cut printin(‘Enter Your Choice"); ch=senextint(); System.cut printin("Enter a no."); n=senextint(); switch(ch) { case 1:for(i= 1; i

You might also like