(a) Give the output of the following string functions:

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

31 Mark · 2016 · Section A · 2016 Paper

(a) Give the output of the following string functions:

Show SolutionHide Solution↓
  1. 2 + 10 = 12
  2. ASCII Code of B - ASCII Code of D
    ⇒ 66 - 68
    ⇒ -2

(b) Give the output of the following Math functions:

  1. Math.ceil(4.2)
  2. Math.abs(-4)
  1. 5.0
  2. 4

(c) What is a parameterized constructor ?

A Parameterised constructor receives parameters at the time of creating an object and initializes the object with the received values.

(d) Write down java expression for:

$T = \sqrt{A^2 + B^2 + C^2}$

T = Math.sqrt(a*a + b*b + c*c)

(e) Rewrite the following using ternary operator:

if (x%2 == 0)
System.out.print("EVEN");
else
System.out.print("ODD");
System.out.print(x%2 == 0 ? "EVEN" : "ODD");

(f) Convert the following while loop to the corresponding for loop:

int m = 5, n = 10;
while (n>=1)
{
    System.out.println(m*n);
    n--;
}
int m = 5;
for (int n = 10; n >= 1; n--) {
    System.out.println(m*n);
}

(g) Write one difference between primitive data types and composite data types.

Primitive Data Types are built-in data types defined by Java language specification whereas Composite Data Types are defined by the programmer.

(h) Analyze the given program segment and answer the following questions:

  1. Write the output of the program segment.
  2. How many times does the body of the loop gets executed ?
for(int m = 5; m <= 20; m += 5)
{    if(m % 3 == 0)
        break;
    else
        if(m % 5 == 0)
            System.out.println(m);
    continue;
}
5
10

Loop executes 3 times.

Below dry run of the loop explains its working.

mOutputRemarks
551st Iteration
105
10
2nd Iteration
155
10
3rd Iteration — As m % 3 becomes true, break statement exists the loop.

(i) Give the output of the following expression:

a+= a++ + ++a + --a + a-- ; when a = 7

    a+= a++ + ++a + --a + a--
⇒ a = a + (a++ + ++a + --a + a--)
⇒ a = 7 + (7 + 9 + 8 + 8)
⇒ a = 7 + 32
⇒ a = 39

(j) Write the return type of the following library functions:

  1. isLetterOrDigit(char)
  2. replace(char, char)
  1. boolean
  2. String
← Previous questionNext question →

Browse the free Computer Applications sample bank