ICSE 2006 Computer Application


Answer to this ICSE 2006 Computer Application ICSE Board 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 is the time allowed for writing the answer.
——– ——– ——– ——– ——- ——- ——– ——- ——-
This paper is divided into two Sections. Answer all Questions from Section A and any four questions from Section B. The intended marks for questions or parts of questions are given in [].
——– ——– ——– ——– ——- ——- ——– ——- ——-

SECTION A(40 Marks)
Attempt all questions.

Question 1.                                 [10]
(a) Define encapsulation.
Ans: The wrapping up to data and methods into a single units (called class) is known as encapsulation. For example an engine of car or any vehicle contains many small parts, which enables the entire machinery system to work. Encapsulation property hides the inner working of objects from the real world.
(b) Explain the term object using an example.
Ans: An Object is an identifiable entity with some characteristics and behavior. E.g. take a class ‘Car’. A car class has characteristics like colour, gears, power, length etc. now we create the object of that class ‘Car’ namely ‘Indica’.
(c) Define a variable.
Ans: A variable is a named memory location, which holds a data value of a particular data types. E.g. double p;
(d) What is a wrapper class? Give an example.
Ans: Wrapper classes are the part or Java’s standard library java.lang and these convert primitive datatypes into an object. to be more specific, a wrapper class wraps a value of primitive types in an object. Java provides the following wrapper classes: Boolean Integer, Float, Double, Character etc.
(e) What is the purpose of the new operator?
Ans: We can use new operator to create a new objects or new array.Ex. myClass obj = new myClass();int arr[] = new int[5];

Question 2.                               [10]
(a) State the two kinds of data types.
Ans: The two types of data types are: Primitive and non-primitive/composite/user define data types. The primitive data types are: byte, short, int, long, float, double, char and Boolean. The non-primitive/reference data types are: class, array and interface.
(b) Write the corresponding expressions for the following mathematical
(i) a2 + b2
(ii) z = x3 + y3 – xy/z
Ans: (i)  Math.pow(a,2) + Math.pow(b,2);       (ii) z = Math.pow(x,3) + Math.pow(y,3) – x*y/z;
(c) Define an impure function.
Ans: Impure Function change the state of the object arguments they have received and then return. The following functions is the example of an impure function:public static void increment(Time obj, double secs){  time.seconds+=secs;  return(Time);}
(d) Differentiate between if and switch statements.
Ans: Both are used as a selection statements, there are some difference in their operations. (i) switch can only test for equality, where as if can evaluate a relational or logical expression. (ii) it statement can handle ranges , where as switch case level must be a single value. (iii) if statement can handle floating point test also, where as the switch case labels must be an integer or character.
(e) What will be the output for the following program segment:-
String s=new String(“abc”);
Ans: ABC

Question 3.
(a) What is meant by private visibility of a method? [2]
Ans: PRIVATE visibility of a Method means that only the methods in the same class are permitted to use this method.
(b) Find and correct the errors in the following program segment:-[2]
int n[]=(2,4,6,8,10);
for (int i=0;i<=5;i++)
Ans: (i) one syntax error at first line i.e. values are must be putted on {}       i.e. int n[]={2,4,6,8,10};(ii) second is one logical error, i.e. array out of bounds. The for loop must be like this     for(int i=0;i<5;i++)
(c) Explain function overloading with an example. [4]
Ans:- A function name having several definitions that are differentiable by the numbers or types of their arguments is known as function overloading. For example following code overloads a function area to computer areas of circle rectangle and triangle.float area (float radius) //circle {  return (3.14 * radius * radius);}float area (float length, float breadth) //rectangle{  return (length*breadth);}float area (float side1, float side2, float side3) //area of triangle{  float s = (side1 + side2 + side3)/2;  float ar = Math.sqrt(s * (s- side1)*(s-side2) *(s-side3));  return (ar);}
(d) Find the output of the following program segment, when: [2]
(i)  val = 500
(ii) val = 1600
int val,sum,n = 550;
sum = n + val > 1750 ? 400 : 200;
Ans: (i) 200  (ii) 400
(e) What is a default constructor?        [2]
Ans: The constructor that accepts no parameter is called the default constructor. If we do not explicitly define a constructor for a class, then java creates a default constructor for the class.Example:class ant{  int i;  public static void main()  ant nc=new ant();}the line new ant() creates an object and calls the default constructor.
(f) What will be the output for the following program segment? [2]
int a=0,b=30,c=40;
a = –b + c++ + b;
Ans: a=98
(g) Differentiate between compareTo() and equals() methods. [2]
Ans: Both the functions is used to comparing two strings, the difference being that (i) equals() method only comparing two string and gives they are equal or not, where as compareTo() methods also gives whether first string is greater or smaller then second one. (ii) equals() methods returns a boolean value, where as compareTo() methods return integer value.
(h) What is a package? Give an example. [2]
Ans: Java contains extensive library of pre-written classes we can use in our programs. These classes are divided into groups called packages. Various packages in Java are: java.applet, java.awt, java.io, java.lang, java.new, java.util etc.
(i) Explain the function of a return statement. [2]
Ans: The return statement is useful in two ways. First an immediately exit from the function is caused as soon as a return statement is encountered and the control back to the main caller. Second use of return statement is that it is used a value to the calling code.

Leave a Comment