Preview

Java Model Test Papers for Icse

Good Essays
Open Document
Open Document
22711 Words
Grammar
Grammar
Plagiarism
Plagiarism
Writing
Writing
Score
Score
Java Model Test Papers for Icse
Test Paper ONE
SECTION A (40 MARKS)

Question 1.
(a) Name two types of programming technique with examples. [4]
Ans. Structured Programming (eg, C, BASIC); Object Oriented Programming (eg, C++, JAVA)

(b) Explain type casting with an example. [2]

Ans.The explicit conversion of a wider data-type into a narrower data-type is called type-casting.

Example: double a = 3.567; int b = (int) a / 10; //typecast double to int

(c) Evaluate a – (b++) * (--c), given a=2, b=3, c=9 [2]

Ans. 2 – 3 * 8 = -22 (d) Write the following expressions in Java: [2] square toot of the sum of squares of a and b

Ans. Math.pow ( (a*a + b*b) , 0.5)

Question 2.
(a) Give an example of local, of instance and of static variable [3]
Ans. Static variable: Math.PI Instance variable: b1.mks (where b1 is an object of class Boy) Local Variable: integer I in the loop: for (int I = 0; I < 5; I++)

(b) Mention two points of differences between binary and linear search. [4] Ans. (i) Binary Search is faster, since the number of iterations is halved at each pass. Linear Search is slower, since the number of iteration is equal to the array length.

(ii) Binary Search does pre-supposes the array to be sorted. Linear Search does not suffer from this limitation.

(c) What does the keyword this mean in Java? Give an example. [3]

Ans.The keyword this refers to the current object. It may be used to reference instance variables thus: this-dot-variable (e. g. this.mks)

Example: class Boy { int m1, m2; Boy(int m1, int m2) {this.m1 = m1; this.m2 = m2;} }

Question

You May Also Find These Documents Helpful

Related Topics