ICSE Computer Applications 2011 Question Paper Solved
admin
4 months ago
Section A (40 Marks)
Question 1
(a) What is the difference between an object and a class?
Object is an identifiable entity with some characteristics and behavior.
Class is a group of objects that share common properties and relationships.
(b) What does the token ‘keyword’ refer to in the context of Java? Give an
example for keyword.
Keywords are the words that convey a special meaning to the language compiler.
Example: ‘new’ keyword.
(c) State the difference between entry controlled loop and exit controlled loop.
In entry-controlled loop, condition is checked before the loop body gets executed.
Example: for loop, while loop.
In exit-controlled loop, at first the loop body gets executed, then the condition is
checked. Example: do-while loop.
(d) What are the two ways of invoking functions?
The two ways of invoking functions are:
1. Call by value
2. Call by reference
(e) What is the difference between / and % operators?
The / operator is used to get the quotient after dividing two numbers, whereas the %
operator gives the remainder after dividing two numbers.
Question 2
(a) State the total size in bytes, of the arrays a[4] of char data type
and p[4] of float data type.
a[4] will occupy 8 bytes.
p[4] will occupy 16 bytes.
(b) (i)Name the package that contains Scanner class.
java.util package.
(ii) Which unit of the class gets called, when the object of the class is created?
Constructor
(c) Give the output of the following:
String n = "Computer Knowledge";
String m = "Computer Applications";
System.out.println(n.substring(0, 8).concat(m.substring(9)));
System.out.println(n.endsWith("e"));
ComputerApplications
true
(d) Write the output of the following:
(i) System.out.println(Character.isUpperCase('R'));
true
(ii) System.out.println(Character.toUpperCase('j'));
J
Question 3
(a) Analyze the following program segment and determine how many times the
loop will be executed and what will be the output of the program segment?
int p = 200;
while(true){
if(p < 100)
break;
p = p - 20;
}
System.out.println(p);
The loop executes 6 times.
OUTPUT: 80
(b) What will be the output of the following code?
(i) int k = 5, j = 9;
k += k++ - ++j + k;
System.out.println("k = " + k);
System.out.println("j = " + j);
k=6
j = 10
(ii) double b = -15.6;
double a = Math.rint(Math.abs(b));
System.out.println("a = " + a);
a = 16.0
(c) Explain the concept of constructor overloading with an example.
Using constructor overloading, we can create multiple constructors for a class with
different function signatures.
Example:
class Square{
int side;
public Square(){
side = 0;
}
public Square(int s){
side = s;
}
}
(d) Give the prototype of a function search which receives a sentence ‘sent’ and
word ‘w’ and returns 1 or 0.
int search(String sent, String w)
(e) Write an expression in Java for z = (5x 3 + 2y) / (x + y).
z = (5 * Math.pow(x, 3) + 2 * y) / (x + y)
(f) Write a statement each to perform the following tasks on a string:
(i) Find and display the position of the last space in a string s.
System.out.println(s.lastIndexOf(' '));
(ii) Convert a number stored in a string variable x to double data type.
Double.parseDouble(x)
(g) Name the keyword that:
(i) informs that an error has occurred in an input/output operation.
throws
(ii) distinguishes between instance variable and class variable.
static
(h) What are library classes? Give an example.
Library classes are the predefined classes provided by Java in the form of packages.
Example: Integer class.
(i) Write one difference between Linear Search and Binary Search.
Linear Search can work on both sorted and unsorted lists, whereas binary search
works only on sorted lists.