Trending ▼   ResFinder  

ICSE 2014 FULL SOLVED PAPER...

12 pages, 0 questions, 0 questions with responses, 0 total responses,    0    0
Umang Bhargava
St. Joseph's Boys' School (SJBS), Jalandhar
X Student
+Fave Message
 Home > jattji >

Formatting page ...

By Teja ICSE Question Paper 2014 (Solved) Computer Applications Class X SECTION A (40 Marks) Answer all questions from this Section Question 1. (a) Which of the following are valid comments? [2] (i) /* comment */ (ii) /*comment (iii) //comment (iv) */ comment */ Ans. (i) /* comment */ and (iii) //comment (b) What is meant by a package? Name any two Java Application Programming Interface packages. [2] Ans. A Package is a collection of classes which contains some inbuilt features , those can be used in a Java Program Two Java Application Programming Interface packages are : java.io and java.util (c) Name the primitive data type in Java that is: (i) (ii) a 64-bit integer and is used when you need a range of values wider than those provided by int. a single 16-bit Unicode character whose default value is \u0000 [2] Ans. (i) long (ii) char (d) State one difference between floating point literals float and double. [2] Ans. float is a single-precision 32-bit floating point literal whereas, double is a double-precision 64-bit floating point literal. Or, float can handle about 7 decimal places whereas a double can handle about 16 decimal places. (e) Find the errors in the given program segment and re-write the statements correctly to assign values to an integer array. [2] int a = new int( 5 ); for( int i=0; i<=5; i++ ) a[i]=i; Ans. Statement 1 has two errors: the [] is required as int[] a or int a[] . Also, the 5 should be inside [ ] bracket instead of ( ). Statement 2 has one error. The condition check should not include the = sign, since the element index should go from 0 to 4 only. Correct code: int a[ ] = new int[ 5 ]; for( int i=0; i < 5; i++ ) a[i] = i; Question 2. (a) Operators with higher precedence are evaluated before operators with relatively lower precedence. Arrange the operators given below in order of higher precedence to lower precedence. [2] (i) && (ii) % (iii) >= (iv) ++ Ans. (iv) ++ , (ii) % , (iii) >= , (i) && (b) Identify the statements listed below as assignment, increment, method invocation or object creation statements. [2] (i) (ii) (iii) (iv) Ans. System.out.println( Java ); costPrice = 457.50; Car hybrid = new Car(); petrolPrice++; (i) (ii) System.out.println( Java );------- method invocation statement. costPrice = 457.50; - assignment statement. (iii) (iv) Car hybrid = new Car(); - objet creation statement petrolPrice++; - increment statement (c) Give two differences between switch statement and if-else statement. [2] Ans. (i) if-else returns in a boolean data type valu i.e., either true or false whereas switch....case returns in int/char type values (ii)if-else can also be performed on Logical operations whereas switch...case can only perform test for equality. (iii) In switch...case , a default statement is applied whereas in if-else , no default statement is applied. (d) What is an infinite loop? Write an infinite loop statement. [2] Ans.An infinite loop is a loop which has no end , and does not yield meaningful results. Examples: for(int i = ;i<=10;)//here there is no statement to update the value of i System.out.println("Infinite "); The output of the above statement will be : Infinite Infinite Infinite..............................endless (e) What is a constructor? When is it invoked? [2] Ans. A constructor is a member function with the same name as that of a class and has no return type, not even void. It is invoked whenever an object is created using the new reserved word. Example : Fruit Mango = new Mango(); Question 3. (a) List the variables from those given below that are composite data types. [2] (i) static int x; (ii) arr[i]=10; (iii) obj.display(); (iv) boolean b; (v) private char chr; (vi) String str; Ans. (ii) arr[], (iii) obj (vi) str (b) State the output of the following program segment: [2] String str1 = great ; String str2 = minds ; System.out.println(strl.substring(0,2).concat(str2.substring(l))); System.out.println(( WH + (strl.substring(2).toUpperCase()))); Ans. strl.substring(0,2) gives gr and str2.substring(l) gives inds . So, strl.substring(0,2).concat(str2.substring(l)) gives grinds strl.substring(2).toUpperCase() gives EAT So, WH + (strl.substring(2).toUpperCase()) gives WHEAT Hence the output of the given program segment will be: grinds WHEAT (c) What are the final values stored in variables x and y below? [2] double a = - 6.35; double b = 14.74; double x = Math.abs(Math.ceil(a)); double y = Math.rint(Math.max(a,b)); Ans. x = 5.0 , y = 15.0 (d) Rewrite the following program segment using the if-else statements instead of the ternary operator. [2] String grade = (mark>=90) ? A : (mark>=80) ? B : C ; Ans. if( marks >= 90 ) { grade = A ; } else if( marks >= 80 ) { grade = B ; } else { grade = C ; } (e) Give output of the following method: [2] public static void main(String[] args) { int a = 5; a++; System.out.println(a); a - = (a -) - (- a); System.out.println(a); } Ans. 6 4 (f) What is the data type returned by the library functions: [2] (i) compareTo() (ii) equals() Ans. (i) int (ii) boolean or String (g) State the value of characteristic and mantissa when the following code is executed. [2] String s = 4.3756 ; int n = s.indexOf( . ); int characteristic = Integer.parseInt(s.substring(0,n)); int mantissa = Integer.valueOf(s.substring(n+1)); Ans. value of characteristic = 4 value of mantissa = 3756 (h) Study the method and answer the given questions. [2] public void sampleMethod() { for( int i=0; i<3; i++ ) { for( int j=0; j<2; j++) { int number = (int)(Math.random() * 10); System.out.println(number); } } } (i) (ii) How many times does the loop execute? What is the range of possible values stored in the variable number? Ans. (i) The outer loop executes 3 times (for i = 0, 1, 2) and for every execution of the outer loop, the inner loop executes 2 times (for j = 0, 1). Hence, the total number of times the statements in the loop executes = 3 *2=6 (ii) The range of possible values stored in the variable number is from 0 9 [Note: Math.random() generates random decimal point numbers between 0 and 1 like 0.4, 0.1, 0.9 etc. Math.random() * 10 gives you these decimal numbers multiplied with 10, so, you get decimal point numbers between 0 and 10 (10 is exclusive). So, the (int)(Math.random() * 10) will give you random integer numbers from 0-9.] (i) Consider the following class: [2] public class myClass { public static int x = 3, y = 4; public int a = 2, b = 3; } (i) (ii) Name the variables for which each object of the class will have its own distinct copy. Name the variables that are common to all objects of the class. Ans. (i) (ii) a and b since these are non-static (instance variables) x and y since these are static variables. (j) What will be the output when the following code segments are executed? [2] (i) (ii) String s = 1001 ; int x = Integer.valueOf(s); double y = Double.valueOf(s); System.out.println( x= +x); System.out.println( y= +y); System.out.println( The King said \ Begin at the beginning!\ to me. ); Ans. (i) x=1001 y=1001.0 (ii) The King said Begin at the beginning! to me. [ Note: \" is an escape character and prints " ] SECTION B (60 Marks) Attempt any four questions from this Section. Question 4. Define a class named movieMagic with the following description: Instance variables/data members: int year to store the year of release of a movie String title to store the title of the movie. float rating to store the popularity rating of the movie. (minimum rating = 0.0 and maximum rating = 5.0) Member Methods: (i) movieMagic() member to . Default constructor to initialize numeric data members to 0 and String data (ii) void accept() (iii) void display() table below. To input and store year, title and rating. To display the title of a movie and a message based on the rating as per the Rating Message to be displayed 0.0 to 2.0 Flop 2.1 to 3.4 Semi-hit 3.5 to 4.5 Hit 4.6 to 5.0 Super Hit Question 5. A special two-digit number is such that when the sum of its digits is added to the product of its digits, the result is equal to the original two-digit number. Example: Consider the number 59. Sum of digits = 5 + 9 = 14 Product of its digits = 5 x 9 = 45 Sum of the sum of digits and product of digits= 14 + 45 = 59 Write a program to accept a two-digit number. Add the sum of its digits to the product of its digits. If the value is equal to the number input, output the message Special 2-digit number otherwise, output the message Not a Special 2-digit number . Ans. class SpecialTwoDigNumber { static void test(int num)//user inputs a two-digit number { int m = num; int product = 1; int sum = 0; while(m>0) { int dig = m%10; sum = sum+dig; product = product*dig; m/=10; } int finalsum = sum+product; if(finalsum==num) System.out.println(num+ is a special two digit number ); else System.out.println(num+ is not a special two digit number ); } } Question 6. Write a program to assign a full path and file name as given below. Using library functions, extract and output the file path, file name and file extension separately as shown. Input Output File name: Extension: C:\Users\admin\Pictures\flower.jpg Path: C:\Users\admin\Pictures\ flower jpg Ans. 1 2 3 4 5 6 7 8 9 1 0 1 1 1 2 1 3 1 4 /** * The class File_Q6_ICSE2014 inputs a full path of a file name and * outputs the file path, file name and file extension separately * @author : www.javaforschool.com * @Program Type : BlueJ Program - Java * @Question Year : ICSE 2014 Question 6 */ import java.io.*; class File_Q6_ICSE2014 { public static void main(String args[])throws IOException { BufferedReader br=new BufferedReader (new InputStreamReader(System.in)); System.out.print("Enter the full path of the file : "); String s = br.readLine(); int x = s.lastIndexOf('\\'); // Finding position of last backward slash 1 5 1 6 1 7 1 8 1 9 2 0 2 1 2 2 2 3 2 4 2 5 2 6 2 7 2 8 2 9 3 0 int y = s.lastIndexOf('.'); // Finding position of last '.' String path = s.substring(0,(x+1)); String file = s.substring((x+1),y); String extn = s.substring((y+1)); System.out.println("Output :"); System.out.println("Path : "+path); System.out.println("File Name : "+file); System.out.println("Extension : "+extn); } } Note: For extracting the position of backslash, \ is not valid as \ is an escape character in java and is treated differently. So in order to override this we are have to use \\ instead of \ Question - 7 will be coming soon..... Question - 8 Using the switch statement,write a menu driven program : [15] To calculate the maturity amount of a bank deposit. The user is given following options: (i) Term Deposit (ii)Recurring Deposit For option(i)accept principle(P),rate of interest(r) and time period years(n). Calclate and output the maturity amount(A) receivable using the formula: A = P[1+r/100]power n For option (ii) accept monthly installment(P) rate of interest(r) and time period(n) in months and Calculate and output the maturity value(A) receivable using formula : A=P*n+P*n(n+1)/2*r/100*1/12 For an incorrect option an appropriate message should be displayed. Ans import java.util.*; class ICSE2014_Prog { static void test() { Scanner in = new Scanner(System.in); System.out.println("Enter 1 or 2"); int choice = in.nextInt(); int p,r,n; double a; switch(choice) { case 1: System.out.println("Enter Principle "); p = in.nextInt(); System.out.println("Enter rate of Interest "); r = in.nextInt(); System.out.println("Enter the time period "); n = in.nextInt(); a = Math.pow((p*(1+r/100)),n); System.out.println("Maturity amount is "+a); break; case 2: System.out.println("Enter Monthly installment"); p=in.nextInt(); System.out.println("Enter rate of interest"); r = in.nextInt(); System.out.print("Enter time period "); n=in.nextInt(); a=p*n+p*n*(n+1)/2*(r/100)*(1/12); System.out.println("Maturity amount is "+a); break; default: System.out.println("Wrong Choice "); } } } Question - 9 will be coming soon...

Formatting page ...

Formatting page ...

Formatting page ...

Formatting page ...

Formatting page ...

Formatting page ...

Formatting page ...

Formatting page ...

Formatting page ...

Formatting page ...

Formatting page ...

 

  Print intermediate debugging step

Show debugging info


 


Tags : ICSE, COMPUTER, PDF, DOC, SOLVED PAPER, BOARD PAPER,  


© 2010 - 2025 ResPaper. Terms of ServiceContact Us Advertise with us

 

jattji chat