ICSE Class 10 Computer Applications

November 28, 2017 | Author: satnamghai | Category: Control Flow, Data Type, Variable (Computer Science), C (Programming Language), Boolean Data Type
Share Embed Donate


Short Description

class 10 computer application solved paper...

Description

ICSE Class 10 Computer Applications ( Java ) 2012 Solved Question Paper 2 Replies

COMPUTER APPLICATIONS (Theory) (Two Hours) Answers to this Paper must be written on the paper provided separately. You will not be allowed to write during the first 15 minutes. This time is to be spent in reading the question 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 Section B. The intended marks for questions or parts of questions are given in brackets [ ]. SECTION A (40 Marks) Attempt all questions. Question 1 (a) Give one example each of a primitive data type and a composite data type. [2] Ans. Primitive Data Types – byte, short, int, long, float, double, char, boolean Composite Data Type – Class, Array, Interface (b) Give one point of difference between unary and binary operators. [2] Ans. A unary operator requires a single operand whereas a binary operator requires two operands. Examples of Unary Operators – Increment ( ++ ) and Decrement ( — ) Operators Examples of Binary Operators – +, -, *, /, % (c) Differentiate between call by value or pass by value and call by reference or pass by reference. [2] Ans. In call by value, a copy of the data item is passed to the method which is called whereas in call by reference, a reference to the original data item is passed. No copy is made. Primitive types are passed by value whereas reference types are passed by reference. (d) Write a Java expression for (under root of 2as+u2) [2] Ans. Math.sqrt ( 2 * a * s + Math.pow ( u, 2 ) ) ( or ) Math.sqrt ( 2 * a * s + u * u ) (e) Name the types of error (syntax, runtime or logical error) in each case given below: (i) Division by a variable that contains a value of zero. (ii) Multiplication operator used when the operation should be division. (iii) Missing semicolon. [2] Ans. (i) Runtime Error (ii) Logical Error (iii) Syntax Error

Question 2 (a)Create a class with one integer instance variable. Initialize the variable using: (i) default constructor (ii) parameterized constructor. [2] Ans. 1 public class Integer { 2 3

int x;

4 5 6

public Integer() { x = 0;

7

}

8 9 10

public Integer(int num) { x = num;

11 12 }

}

(b)Complete the code below to create an object of Scanner class. Scanner sc = ___________ Scanner( ___________ ) [2] Ans. Scanner sc = new Scanner ( System.in ) (c) What is an array? Write a statement to declare an integer array of 10 elements. [2] Ans. An array is a reference data used to hold a set of data of the same data type. The following statement declares an integer array of 10 elements int arr[] = new int[10]; (d) Name the search or sort algorithm that: (i) Makes several passes through the array, selecting the next smallest item in the array each time and placing it where it belongs in the array. (ii) At each stage, compares the sought key value with the key value of the middle element of the array. [2] Ans. (i) Selection Sort (ii) Binary Search (e) Differentiate between public and private modifiers for members of a class. [2] Ans. Variables and Methods whwith the public access modie the class also. Question 3 (a) What are the values of x and y when the following statements are executed? [2] 1 int a = 63, b = 36; 2 boolean x = (a < b ) ? true : false; int y= (a > b ) ? a : b ;

Ans. x = false y = 63 (b) State the values of n and ch [2] 1 char c = 'A': 2 int n = c + 1;

Ans. The ASCII value for ‗A‘ is 65. Therefore, n will be 66. (c) What will be the result stored in x after evaluating the following expression? [2] 1 int x=4; 2 x += (x++) + (++x) + x;

Ans. x = x + (x++) + (++x) + x x=4+4+6+6 x = 20 (d) Give the output of the following program segment: [2] 1 double x = 2.9, y = 2.5; 2 System.out.println(Math.min(Math.floor(x), y)); 3 System.out.println(Math.max(Math.ceil(x), y));

Ans. 2.0 3.0 Explanation : Math.min(Math.floor(x), y) = Math.min ( 2.0, 2.5 ) = 2.0 Math.max(Math.ceil(x), y)) = Math.max ( 3.0, 2.5 ) = 3.0 (e) State the output of the following program segment. [2] 1 String s = "Examination"; 2 int n = s.length(); 3 System.out.println(s.startsWith(s.substring(5, n))); 4 System.out.println(s.charAt(2) == s.charAt(6));

Ans. false true Explanation : n = 11 s.startsWith(s.substring(5, n)) = s.startsWith ( ―nation‖ ) = false ( s.charAt(2) == s.charAt(6) ) = ( ‗a‘== ‗a‘ ) = true (f) State the method that: (i) Converts a string to a primitive float data type

(ii) Determines if the specified character is an uppercase character [2] Ans. (i) Float.parseFloat(String) (ii) Character.isUpperCase(char) (g) State the data type and values of a and b after the following segment is executed.[2] 1 String s1 = "Computer", s2 = "Applications"; 2 a = (s1.compareTo(s2)); 3 b = (s1.equals(s2));

Ans. Data type of a is int and b is boolean. ASCII value of ‗C‘ is 67 and ‗A‘ is 65. So compare gives 67-65 = 2. Therefore a = 2 b = false (h) What will the following code output? [2] 1 String s = "malayalam"; 2 System.out.println(s.indexOf('m')); 3 System.out.println(s.lastIndexOf('m'));

Ans. 0 8 (i) Rewrite the following program segment using while instead of for statement [2] 1 int f = 1, i; 2 for (i = 1; i
View more...

Comments

Copyright ©2017 KUPDF Inc.
SUPPORT KUPDF