ICSE 2010, Computer Application, Sample Question Paper 9, Class X
http://www.icseguess.com/-------------------------------------------------------------------------------------------------------www.icseguess.com Other Educational Portals www.cbseguess.com | www.ignouguess.com | www.dulife.com | www.magicsense.com Sample Paper – 2010 Class – X Subject – Computer Applications Question 1. (a) A class is called a factory of objects as it accepts data required to create an object and returns an object. It contains the information required to create objects as well as statements that describe their behaviour. It is considered as a factory because it creates objects having similar structure and behaviour. (b) Boolean literals are those which can have true or false value. A character literal is enclosed in a single quotes and have only one character within it. Example „a‟. (c) Ternary operator is a substitute for if-else statement and also known as conditional operator. It is represented by ?: and the syntax is (condition) ? value if true : value if false ; (d) (i) parseInt() (ii) false (e) Similarity: Both are pre-tested loop. Difference: while loop is used when number of iterations are not known in advance whereas for loop is used for a fix number of iterations. Question 2. (a) float sum(int x) http://www.icseguess.com/-------------------------------------------------------------------------------------------------------www.icseguess.com Other Educational Portals www.cbseguess.com | www.ignouguess.com | www.dulife.com | www.magicsense.com (b) Keyword „this‟ is used to access value of a member data in a method in case of ambiguity. It is used to refer any data or function with current object. class Demo { int x; void sampleMethod() { int x; //local variable x = 10; //local variable this.x = 20 //Member data System.out.println( x + “\t” + this.x ); //will print 10 20 } } (c) A class is known as composite data type as it is based on fundamental data type. Example: class Date { int date, month, year; } So now if we create an object of “Date” type, it will contain all the three integer data i.e. date, month and year. (d) (i) new (ii) return (e) A function which receives an object parameter and modifies state of it, is known as impure function whereas a function which receives an object as parameter and does not modifies its state is known as pure function. http://www.icseguess.com/-------------------------------------------------------------------------------------------------------www.icseguess.com Other Educational Portals www.cbseguess.com | www.ignouguess.com | www.dulife.com | www.magicsense.com Question 3. (a) Java expression is Math.pow(a+b, n)/(Math.sqrt(3)+b) (b) (i) 2, 0 (ii) 1, 1 (c) 10 2 only 2 times the loop will execute (d) When we have multiple functions having same name, function signature differentiates these functions which includes number of arguments, their data types and the sequence of arguments. (e) 3, 6 (f) (i) Object Oriented (ii) Wrong Input (iii) Platform Independent Robust and Secure (g) (i) student (ii) x, y (iii) a, b (iv) type is procedural function Name is access() (h) int x=10, c=20; do{ x++; c = c – 2 ; http://www.icseguess.com/-------------------------------------------------------------------------------------------------------www.icseguess.com Other Educational Portals www.cbseguess.com | www.ignouguess.com | www.dulife.com | www.magicsense.com } while (c>=10); SECTION – B Question 4. import java.io.*; public class Q4 { void input() throws IOException { BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); String name, address; char type; int amt; double net, dis=0.0; System.out.print("Enter name :"); name=br.readLine(); System.out.print("Enter address :"); address=br.readLine(); System.out.print("Enter amount of purchase :"); amt=Integer.parseInt(br.readLine()); System.out.print("Enter type of purchase (L for Laptop and D for Desktop) :"); type=(char)br.read(); if(amt>=0 && amt<=25000) { if(type=='L' || type=='l') dis=0.0; if(type=='D' || type=='d') dis=5.0; } else if(amt>25000 && amt<=57000) { if(type=='L' || type=='l') dis=5.0; if(type=='D' || type=='d') dis=7.5; } else if(amt>57000 && amt<=100000) { if(type=='L' || type=='l') dis=7.5; if(type=='D' || type=='d') dis=10.0; } else { if(type=='L' || type=='l') dis=10.0; http://www.icseguess.com/-------------------------------------------------------------------------------------------------------www.icseguess.com Other Educational Portals www.cbseguess.com | www.ignouguess.com | www.dulife.com | www.magicsense.com if(type=='D' || type=='d') dis=15.0; } net = amt -(dis*amt/100); System.out.println("Name is "+name); //Printing output System.out.println("Address is "+address); System.out.println("Net amount is "+net); } } http://www.icseguess.com/-------------------------------------------------------------------------------------------------------www.icseguess.com Other Educational Portals www.cbseguess.com | www.ignouguess.com | www.dulife.com | www.magicsense.com Question 5. import java.io.*; public class Q5 { void input() throws IOException { BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); int ch, n, i, j; System.out.println("Type 1 for a triangle and"); System.out.println("type 2 for an inverted triangle"); System.out.print("Enter your choice :"); ch=Integer.parseInt(br.readLine()); if(ch==1) { System.out.print("Enter the number of terms "); n=Integer.parseInt(br.readLine()); System.out.println("Output:"); for(i=1; i<=n; i++) { for(j=1; j<=i; j++) { System.out.print(i); } System.out.println(); } } else if(ch==2) { System.out.print("Enter the number of terms "); n=Integer.parseInt(br.readLine()); System.out.println("Output:"); for(i=n; i>=1; i--) { for(j=1; j<=i; j++) { System.out.print(i); } System.out.println(); } } else System.out.println("Wrong input"); http://www.icseguess.com/-------------------------------------------------------------------------------------------------------www.icseguess.com Other Educational Portals www.cbseguess.com | www.ignouguess.com | www.dulife.com | www.magicsense.com } } Question 6. import java.io.*; public class Q6 { void input() throws IOException { BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); String inp, tmp=""; int i, k=0, max=0; System.out.print("Enter a sentence :"); inp=br.readLine(); inp=inp+" "; for(i=0; i max) max=tmp.length(); } } System.out.println("Number of characters in the longest word are "+max); } } http://www.icseguess.com/-------------------------------------------------------------------------------------------------------www.icseguess.com Other Educational Portals www.cbseguess.com | www.ignouguess.com | www.dulife.com | www.magicsense.com Question 7. public class Q7 { void num_calc(int num, char ch) { if(ch=='s' || ch=='S') System.out.println("Square is "+(num*num)); else System.out.println("Cube is "+(num*num*num)); } void num_calc(int a, int b, char ch) { if(ch=='p' || ch=='P') System.out.println("Product is "+(a*b)); else System.out.println("Addition is "+(a+b)); } void num_calc(String s1, String s2) { if(s1.equals(s2)) System.out.println("Strings are equal"); else System.out.println("Strings are not equal"); } } http://www.icseguess.com/-------------------------------------------------------------------------------------------------------www.icseguess.com Other Educational Portals www.cbseguess.com | www.ignouguess.com | www.dulife.com | www.magicsense.com Question 8. import java.io.*; public class Q8 { int findGCD(int x, int y) { int rem, max, min, k; max=(x>y)?x:y; min=(x 80) System.out.println("Roll number "+rno[i]+"\t Average mark "+avg[i]); } System.out.println("List of students whose average mark is below 40 "); for (i=0; i<5; i++) { if(avg[i] < 40) System.out.println("Roll number "+rno[i]+"\t Average mark "+avg[i]); } } } -------End of Solution -------By Pankaj Singh Mobile No : +919450040633; +919455016141
Description
This content is useful for ICSE Students
Presentation Transcript
Your Facebook Friends on WizIQ