(a) State the data type and value of y after the following is executed:

ICSE Class 10 Computer Applications PYQ · 2015 Paper · Section A

31 Mark · 2015 · Section A · 2015 Paper

(a) State the data type and value of y after the following is executed:

char x='7';
y=Character.isLetter(x);
Show SolutionHide Solution↓

Data type of y is boolean and value is false. Character.isLetter() method checks if its argument is a letter or not and as 7 is a number not a letter hence it returns false.

(b) What is the function of catch block in exception handling ? Where does it appear in a program ?

Catch block contains statements that we want to execute in case an exception is thrown in the try block. Catch block appears immediately after the try block in a program.

(c) State the output when the following program segment is executed:

String a ="Smartphone", b="Graphic Art";
String h=a.substring(2, 5);
String k=b.substring(8).toUpperCase();
System.out.println(h);
System.out.println(k.equalsIgnoreCase(h));

The output of the above code is:

art
true

a.substring(2, 5) extracts the characters of string a starting from index 2 till index 4. So h contains the string "art". b.substring(8) extracts characters of b from index 8 till the end so it returns "Art". toUpperCase() converts it into uppercase. Thus string "ART" gets assigned to k. Values of h and k are "art" and "ART", respectively. As both h and k differ in case only hence equalsIgnoreCase returns true.

(d) The access specifier that gives the most accessibility is ________ and the least accessibility is ________.

The access specifier that gives the most accessibility is public and the least accessibility is private.

(e) (i) Name the mathematical function which is used to find sine of an angle given in radians.
(ii) Name a string function which removes the blank spaces provided in the prefix and suffix of a string.

(i) Math.sin() (ii) trim()

(f) (i) What will this code print ?

int arr[]=new int[5];
System.out.println(arr);
  1. 0
  2. value stored in arr[0]
  3. 0000
  4. garbage value

This code will print garbage value

(ii) Name the keyword which is used- to resolve the conflict between method parameter and instance variables/fields.

this keyword

(g) State the package that contains the class:

  1. BufferedReader
  2. Scanner
  1. java.io
  2. java.util

(h) Write the output of the following program code:

char ch ;
int x=97;
do
{
    ch=(char)x;
    System.out.print(ch + " " );
    if(x%10 == 0)
    break;
    ++x;
} while(x<=100);

Answer
The output of the above code is:

a b c d

The below table shows the dry run of the program:

xchOutputRemarks
97aa1st Iteration
98ba b2nd Iteration
99ca b c3rd Iteration
100da b c d4th Iteration — As x%10 becomes true, break statement is executed and exists the loop.

(i) Write the Java expressions for:

$\frac{a^2+b^2}{2ab}$

(a * a + b * b) / (2 * a * b)

(j) If int y = 10 then find int z = (++y * (y++ + 5));

    z = (++y * (y++ + 5))
⇒ z = (11 * (11 + 5))
⇒ z = (11 * 16)
⇒ z = 176

← Previous questionNext question →

Browse the free Computer Applications sample bank