ICSE Board

ICSE Computer Applications Solved Competency Questions Solutions Class 10 Chapter 2 Very Short Answer Questions

This collection of ICSE Class 10 Computer 2 Mark Questions is an essential resource for mastering the core concepts of Java programming. Taken from the Class 10 – ICSE Computer Applications Solved Competency Questions textbook, this chapter on Very Short Answer Questions focuses on quick, precise application of your knowledge. You will find questions that test your understanding of Java syntax, keywords like import, standard library methods from the Math and Character classes, and the fundamental differences between various programming constructs. These short-form questions are designed to build a strong foundation for the more complex problems you will face in your board exams.

If you are looking for clear and accurate solutions for specific short-answer questions, you have come to the right place. This page provides verified solutions for all 24 questions in the Very Short Answer Questions chapter. We understand that for 2-mark questions, precision is key, so our solutions follow the exact method and terminology that the ICSE board expects. Here you will find direct, easy-to-understand answers to help you check your work, clarify doubts, and prepare effectively for your Computer Applications exam.

Short Answer Questions (2 Marks Each)

Question 48

Write the java statement for:

Sum of a raised to b and cuberoot of c

Answer:

Let’s translate this English phrase into a proper Java statement, piece by piece.

The first part is ‘a raised to b’. For any power or exponent calculation, we use the pow() method from Java’s built-in Math library. This gives us Math.pow(a, b).

The second part is finding the ‘cuberoot of c’. The Math library has a specific method for this too, which is cbrt(). So, this becomes Math.cbrt(c).

The problem asks for the sum of these two values, so we’ll connect them with the + operator. And of course, we must finish any complete Java statement with a semicolon.

This brings us to the final line of code:
Math.pow(a, b) + Math.cbrt(c);


Question 49

Name the following:

(a) Method with the same name as of the class and is invoked every time an object is created.
(b) Keyword to access the classes of a package.

Answer:

(a) Remember that special method that gets called automatically the very instant an object is created? It has a very specific rule: its name must be an exact match for the class name. Its whole job is to initialize the new object. This is known as a Constructor.

(b) When we want to use classes from Java’s extensive library, like the Scanner class which is in the java.util package, we have to explicitly tell our program. The keyword that allows us to access and use the classes contained within a package is import.


Question 50

Name the following:

(a) A Character method that checks whether a character is an alphabet or a number.
(b) A Math method that does not have an argument.

Answer:

(a) When you’re working with characters in Java, the Character wrapper class has a whole library of useful tools. For checking if a character is either an alphabet (like ‘a’ through ‘z’) or a number (like ‘0’ through ‘9’), there’s a specific method whose name tells you exactly what it does: Character.isLetterOrDigit().

(b) Think about the common Math methods you use, like Math.sqrt(x) or Math.pow(a, b). They all need you to provide some value inside the parenthesesβ€”that’s the argument. The question is asking for a method that doesn’t need any input to do its job. The most common one is Math.random(), which generates a random double value between 0.0 and 1.0 all on its own, without needing any argument.


Question 51

Cyber police wanted to investigate a case; they wanted to check a list of phone numbers that had 945 anywhere in the phone number. Example: 7394567938, 7685483945.., a method was created to convert the phone number in long data type to a string and check for the existence of the number 945. Fill in the blanks (a) and (b) in the given method with appropriate Java statements:

void check(long pno) 
{ String s = _______(a)_________; 
if(______(b)_______) 
    System.out.println(pno); 
}                                    
Answer:

Let’s take a close look at how to complete this method. The goal is to find the sequence of digits “945” inside a phone number that’s given as a long.

The completed code looks like this:

void check(long pno) 
{ 
    String s = String.valueOf(pno); 
    if(s.indexOf("945") >= 0) 
        System.out.println(pno); 
}

Now, let’s break down the two parts we filled in.

  1. String s = String.valueOf(pno);
    The phone number pno is a long data type, which is great for storing large numbers, but not so good for searching for a pattern of digits within it. To search for a sequence like “945”, we first need to convert the number into a String. The most direct way to do this in Java is with the String.valueOf() method. This line takes the long pno and turns it into its String equivalent, which we store in the variable s.

  2. if(s.indexOf("945") >= 0)
    Now that we have a string s, we can use Java’s powerful built-in string methods. The indexOf() method is perfect for this job. It searches for the substring you provide (in this case, "945") inside the main string (s).

    • If it finds the substring, it returns the starting index (position) where it was found. The first character is at index 0, the second at 1, and so on. So, any found index will be 0 or a positive number.
    • If it does not find the substring, it returns -1.

    Therefore, the condition s.indexOf("945") >= 0 is a clever way to check if the substring “945” exists anywhere in the string. If the result is greater than or equal to 0, it means the number was found, the condition is true, and the program proceeds to System.out.println(pno);.


Question 52

A manager wants to check the number of employees with names ending with KUMAR, and fill in the blanks in the given program segment with appropriate Java statements:

void count(String s[]) 
{ 
    int i, l=_________, c=0; 
    for(i=0;i<l;i++) 
    { 
    if(________________) 
    c++; 
    } 
    System.out.println(c); 
}                       
Answer:

Of course, let’s look at how to complete this little piece of code. The goal is to count names that end in a specific way.

First, we need to tell our for loop how many times to run. It needs to check every single name in the String array s[]. To get the size of any array in Java, we use its length property. So, the first blank, which initializes the variable l, becomes s.length.

Next, inside the loop, we have our if statement. For each element s[i], we need to check if it ends with the word “KUMAR”. Java’s String class has a very handy built-in method just for this, called endsWith(). So, the condition we need to check is s[i].endsWith("KUMAR").

When we put these two parts into the program segment, we get the complete, correct code:

void count(String s[]) 
{ 
    int i, l = s.length, c = 0; 
    for(i = 0; i < l; i++) 
    { 
        if(s[i].endsWith("KUMAR")) 
            c++; 
    }
    System.out.println(c); 
}                   

Question 53

The output of a program which extracts a part of the string “COMPASSION” is as follows:

(a) “PASS”
(b) “PASSION”

Write appropriate Java statements to get the above outputs.

Answer:

This is a great question that tests our understanding of Java’s very useful substring() method. Remember, in Java, we always start counting the position (or index) of characters in a string from 0.

Let’s map out our string “COMPASSION”:

COMPASSION
0123456789

(a) To get the output “PASS”, we can see that the substring starts at index 3 (the first ‘P’) and ends at index 6 (the second ‘S’). When we use the substring() method with a start and end index, it extracts characters from the starting index up to, but not including, the ending index. So, to include the character at index 6, our end index in the method must be 7. This gives us the statement:

"COMPASSION".substring(3, 7);

(b) For the output “PASSION”, the logic is a bit simpler. The substring still begins at index 3, but this time it goes all the way to the end of the original string. Java has a convenient version of substring() for exactly this situation, where you only need to provide the starting index. The statement is therefore:

"COMPASSION".substring(3);


Question 54

Give the output of the following program segment:

for(k=a;k<=a*b;k+=a) 
{ if (k%b==0) 
   break; 
} 
System.out.println(k);

Give the output when a = 6, b = 4.

Answer:

Let’s trace the execution of this for loop together, keeping track of the variables a=6 and b=4.

  1. The loop begins by initializing its counter variable, k, with the value of a. So, we start with k = 6.

  2. Next, we check the loop’s condition: k<=a*b. Plugging in our numbers, this becomes k <= 6 * 4, which simplifies to k <= 24. The loop will continue as long as k is less than or equal to 24.

  3. The update statement, k+=a, tells us that after each cycle, k will increase by the value of a, which is 6.

  4. Inside the loop, there’s a critical check: if (k%b==0). This asks, “Is k perfectly divisible by b?” With our values, it’s k % 4 == 0. If this condition is met, the break; statement will immediately stop the loop.

Let’s walk through the iterations:

  • First Pass: k starts at 6. The program checks if 6 % 4 == 0. The remainder is 2, not 0, so the condition is false. The loop continues to the next iteration.

  • Second Pass: First, k is updated. It was 6, and we add a (which is 6), so now k = 12. The program checks if 12 % 4 == 0. Yes, the remainder is 0. The condition is true! The break; statement is executed, and the loop terminates immediately.

  • The program now moves to the line after the loop: System.out.println(k);. At the moment the loop was broken, the value of k was 12. So, the final output printed to the screen is 12.


Question 55

Kamal wants to display only the alphabets stored in a character array. While compiling the code, an error was displayed. Check for the statement with the error and write the correct statement.

char arr[]={'4', '&', 'a', 'w', 'd'}; 
int i; 
for(i=0;i<arr.length;i++) 
{ 
if(Character.isLetter(arr)) 
System.out.println(arr); 
}
Answer:

It looks like there are a couple of small mix-ups in the code that are causing the error. Both issues stem from the same common point of confusion: the difference between an entire array and a single element inside it.

Let’s break down the two lines with errors:

if(Character.isLetter(arr)) //Error 1
System.out.println(arr); // Error 2
  1. The first problem is with Character.isLetter(arr). The Character.isLetter() method is built to check one single character at a time (a char type). In the code, it’s being given arr, which is the name of the whole array. The computer doesn’t know which of the five characters to check!

  2. Similarly, the System.out.println(arr) line has the same issue. It’s being told to print the entire array, not the specific character that was just identified as a letter.

To fix this, we need to use the loop’s counter variable, i, to point to the exact character we want to work with in each iteration. The correct way to write this is arr[i].

Here is the corrected code:

char arr[] = {'4', '&', 'a', 'w', 'd'}; 
int i; 
for(i = 0; i < arr.length; i++) 
{ 
    if(Character.isLetter(arr[i]))
        System.out.println(arr[i]);
}

Question 56

Name the type of type casting in the given statements:

(a) double m = ‘b’;
(b) char ch = (char)68;

Answer:

(a) Think about the first statement. A char value is being put into a double variable. Since a double has much more space than a char, Java can make this conversion automatically without any risk of losing data. It happens ‘implicitly’ or behind the scenes. Therefore, this is an example of Implicit type casting.

(b) Now, let’s look at the second statement. Here, an integer, 68, is being forced into a char variable. This is a conversion from a larger data type to a smaller one. Java won’t do this automatically because information could be lost. You, the programmer, have to explicitly tell the compiler to make the conversion by using the (char) cast operator. This direct instruction makes it Explicit type casting.


Question 57

Write Java statements for the following:

(a) To assign the cube root of -343 to a variable with the appropriate datatype.
(b) To assign the position of the last occurrence of @ in the String s with the appropriate datatype.

Answer:

Let’s break down these Java statements one by one.

(a) To find the cube root of a number, we turn to Java’s powerful Math class. It contains a specific method just for this purpose: cbrt(). An important detail is that this method always returns its answer as a double to handle any possible decimal places. So, we must create a double variable to hold the result. To find the cube root of -343 and store it in a variable named cubeRoot, the full statement looks like this:
double cubeRoot = Math.cbrt(-343);

(b) When you need to find the position of a character within a String, you can use methods built right into the String class itself. To find the last time a character appears, we use the lastIndexOf() method. In this case, we are searching for the '@' character inside a String called s. The position, or index, of a character is always a whole number, so the correct datatype for our variable is int. Naming our variable pos, the complete statement is:
int pos = s.lastIndexOf('@');


Question 58

Mention the output of this code snippet:

int lives = 5; 
    System.out.println(lives--); 
    System.out.println(lives);
Answer:

Let’s trace the code step-by-step to see how the output is generated.

  1. First, a variable named lives is created and initialized to the value 5.
  2. The next line, System.out.println(lives--);, is the most important one to understand. The -- here is the postfix decrement operator. ‘Postfix’ means the action happens after the value is used. So, Java first uses the current value of lives, which is 5, for the print statement. Then, after printing, it decrements lives by 1.
  3. Because of that operation, the value of lives is now 4.
  4. The final statement, System.out.println(lives);, is straightforward. It just prints the current value stored in lives, which is now 4.

This gives us the final output:

5
4

Question 59

Convert the following for loop segment to an exit-controlled loop.

for(k = 10;k >= -1;k--) 
System.out.println(k*2); 
System.out.println(k*4); 
Answer:

To convert this for loop into an exit-controlled loop, we’ll use a do-while loop. Remember, the key feature of a do-while loop is that it checks its condition at the end, which guarantees the loop body runs at least once.

Let’s map the parts of the for loop to our new structure:

  1. Initialization: The for loop starts with k = 10. In a do-while loop, this initialization must happen before the loop begins.
  2. Loop Body: The code inside the do { ... } block will be the original loop’s action, System.out.println(k * 2);, followed by the update step, k--;.
  3. Condition: The for loop’s condition, k >= -1, moves to the while statement at the very end.

One very important detail here is the line System.out.println(k * 4);. Because the original for loop did not have curly braces { }, only the first statement after it was part of the loop. This second print statement was always meant to execute only once, after the loop finished. Therefore, it must also be placed after our new do-while loop.

Putting it all together, the correct conversion is:

k = 10;
do {
    System.out.println(k * 2);
    k--;
} while (k >= -1);
System.out.println(k * 4);

Question 60

Give the output of the following program segment:

int x[]={2,45,7,67,12,3}; 
int i, t=0; 
for(i=0, t=5;i<3;i++,t--) 
{ 
System.out.println(x[i]+x[t]); 
}
Answer:

Let’s trace the execution of this code snippet together. It’s a great example of how a for loop can manage multiple variables.

  1. First, we have an integer array declared as x = [2, 45, 7, 67, 12, 3].

  2. The for loop is set up with two variables. The initial values are set to i = 0 and t = 5.

  3. The loop’s condition is i < 3. This means the code inside the loop will run as long as the value of i is 0, 1, and 2. Let’s walk through each pass.

First Iteration:
– At the start, i = 0 and t = 5.
– The program calculates x[i] + x[t], which translates to x[0] + x[5].
– Looking at our array, this is 2 + 3 = 5.
– The first value printed is 5.
– After this, the loop updates the variables: i becomes 1 (i++) and t becomes 4 (t--).

Second Iteration:
– Now, i = 1 and t = 4.
– The calculation is x[1] + x[4], which is 45 + 12 = 57.
– The program prints 57.
– The variables update again to i = 2 and t = 3.

Third Iteration:
– For this pass, i = 2 and t = 3.
– The calculation is x[2] + x[3], which is 7 + 67 = 74.
– The program prints 74.
– The variables are updated one last time to i = 3 and t = 2.

Now, the loop checks the condition i < 3 again. Since i is now 3, the condition is false, and the loop terminates.

  1. Therefore, the complete output you would see on the screen is:
5
57
74

Question 61

Write Java statements for the following:

(a) Initialise the array with the three favourite subjects.
(b) Declare an array to store the marks in 3 subjects of 40 students.

Answer:

(a) When you know the exact values you want to store in an array from the very beginning, you can initialise it directly. Since subject names are text, we’ll use a String array. The Java statement uses curly braces {} to enclose the list of initial values:

String subjects[] = {"Maths", "Science", "English"};

(b) For this situation, we need to store marks for 40 students in 3 subjects. This is a classic case for a two-dimensional array, which you can imagine as a grid or a table. Since marks are usually whole numbers, we’ll use the int data type.

There are two perfectly valid ways to declare this array, depending on how you want to structure your grid (rows vs. columns):

  • You can think of it as 40 rows (one for each student) and 3 columns (one for each subject). The declaration for this is:
    int marks[][] = new int[40][3];

  • Or, you could flip it and think of it as 3 rows (one for each subject) and 40 columns (one for each student). The declaration would then be:
    int marks[][] = new int[3][40];


Question 62

A Student executes the given program segment and it results in 1.0, irrespective of the value of n. State the type of the error, write the correct statement:

void solve(int n) 
{ double power=Math.pow(n, 2/3); 
System.out.println(power); 
}
Answer:

The problem you’re seeing is a classic logical error. The program runs without crashing, but it doesn’t produce the correct result, which is a very common type of bug.

The correct statement should be:

double power = Math.pow(n, 2.0 / 3);

Let’s break down why the original code always gives 1.0. The heart of the issue lies in the expression 2/3. In Java, when you divide an integer by another integer, it performs something called integer division. This means the result will also be an integer, and any fractional part is simply discarded. So, 2/3 evaluates to 0.

Because of this, your code is actually calculating Math.pow(n, 0). As you know from mathematics, any number raised to the power of 0 is 1. Since the power variable is a double, the final result is 1.0, which explains the output you’re getting for any value of n.

To fix this, we need to tell Java to perform a floating-point division. You can do this by making at least one of the numbers a decimal. For example, writing 2.0/3, 2/3.0, or even 2.0/3.0 will force the division to produce the decimal value 0.666…. This is the correct exponent needed to calculate n^{2/3}.

The corrected code segment would look like this:

void solve(int n) 
{ double power = Math.pow(n, 2.0 / 3);
System.out.println(power); 
}

Question 63

Consider the following program segment and answer the questions given:

for(int k=1;k<=5;k++) 
System.out.println(k); 
System.out.println(k);

(a) Will the program segment get executed successfully?
(b) If not, state the type of error?
(c) How do you correct the program if it has any error?

Answer:

(a) This is a classic question that tests a very important concept! The simple answer is: No, the program segment will not execute successfully.

(b) The issue here is what we call a syntax error. Think of the for loop as a temporary little world. When you declare int k inside the parentheses of the loop, you are creating a variable k that only exists inside that world. As soon as the loop finishes its job, that world disappears, and so does the variable k. The final line of code, System.out.println(k);, is outside that loop, trying to talk to a variable that it doesn’t recognize anymore. This is why the error occurs: the variable k is not known outside the loop.

(c) The fix is quite straightforward! We just need to give k a life outside the loop. We can do this by declaring it before the loop begins. That way, it’s known both inside the loop and after it finishes. Here’s how you correct the program:

int k;
for (k = 1; k <= 5; k++)
System.out.println(k);
System.out.println(k);

By declaring int k; first, the variable is available to the entire program segment, solving the error.


Question 64

Consider the array:

int a[]={12, 35, 40, 22, 56, 9, 70};

(a) In the above given array, using linear search, how many iterations are required to check for the existence of the value 56?

(b) If the array is arranged in descending order, how many iterations are required to check for the existence of 56 using linear search?

Answer:

(a) Remember how a linear search works? It’s our most straightforward search method: we simply start at the beginning of the array and check each element, one by one, until we find our target. Here, we’re looking for the value 56. The search will check 12, then 35, then 40, then 22, and on the fifth check, it finds 56. Since 56 is the fifth element, it takes 5 iterations to find it.

(b) Now, the game changes slightly. First, the array is sorted in descending order, which gives us: {70, 56, 40, 35, 22, 12, 9}. The linear search logic, however, stays the same – we still start from the very first element. The search will check 70, and then right away, it checks 56. We’ve found it! In this re-arranged array, it takes only 2 iterations to find 56.


Question 65

Evaluate the expression:

3 * 6 % 5 * 4 / 2 * 7 % 5

Answer:

When you see an expression like this, the first thing to think about is operator precedence. In Java, the operators for multiplication (*), division (/), and modulus (%) all share the same level of precedence. So, how do we decide which one to do first? We simply evaluate the expression from left to right.

Let’s walk through it together.

  1. We’ll start at the very beginning of the expression. The first two operations are 3 * 6 and then % 5.
  2. First, 3 * 6 equals 18.
  3. Now we use that result for the next part: 18 % 5. Remember, the modulus operator gives you the remainder of a division. When 18 is divided by 5, the remainder is 3.
    After this first step, our expression has simplified to: 3 * 4 / 2 * 7 % 5.

  4. We just continue the same processβ€”working from left to right, because all the remaining operators have the same precedence.

  5. 3 * 4 gives us 12.
  6. Next, 12 / 2 results in 6.
  7. Then, 6 * 7 is 42.
  8. Finally, we have 42 % 5. The remainder when 42 is divided by 5 is 2.

So, the final result of the entire expression is 2.


Question 66

Consider the following program which calculates the Norm of a matrix. Norm is square root of sum of squares of all elements.

Fill in the blanks (a) and (b) with appropriate java statements:

double norm() 
{ int x[][]={{1,5,6},{4,2,9},{6,1,3}}; 
int r, c, sum=0; 
for(r=0;r<3;r++) 
{ for(c=0;c<3;c++) 
   sum=sum+_____(a)_____; 
} 
____(b)________; 
}
Answer:

Let’s carefully read the definition of a Norm provided in the question: it’s the square root of the sum of squares of all elements.

We can break this down into two main tasks for our code.

  1. Calculate the ‘sum of squares of all elements’: The nested for loops are designed to visit every single element in the x[][] array, one by one. For each element, which we access using x[r][c], we need to find its square. To square a number, you just multiply it by itself. So, the expression for this is x[r][c] * x[r][c]. We then need to add this squared value to our running total, which is stored in the sum variable. This gives us the complete statement for blank (a).

  2. Find the ‘square root’ of that sum and return it: After the loops have finished, sum holds the total sum of all the squared elements. The problem definition says the Norm is the square root of this value. Java’s Math library has a ready-made function for this: Math.sqrt(). Since the norm() method must return the final calculated value (notice its return type is double), the statement for blank (b) must calculate this square root and return it.

With these two pieces of logic, the completed function is as follows:

double norm() 
{ int x[][]={{1,5,6},{4,2,9},{6,1,3}}; 
int r, c, sum=0; 
for(r=0;r<3;r++) 
{ for(c=0;c<3;c++) 
   sum=sum+x[r][c] * x[r][c];
} 
return Math.sqrt(sum);
}

Question 67

Give the output of the following program segment:

for(r=1;r<=3;r++) 
{ for(c=1;c<r;c++) 
   { System.out.println(r); 
    } 
}
Answer:

Let’s trace this nested loop together. The key is to watch how the inner loop’s condition, c < r, behaves as the outer loop’s variable, r, changes.

Output

2
3
3

Explanation

  • When r = 1:
  • The inner loop checks its condition, c < r. Since c starts at 1, the check is 1 < 1. This is false right away, so the inner loop has no iterations.
  • Because of this, there is no output for r=1.
  • When r = 2:
  • The outer loop moves on, and the inner loop’s condition becomes c < 2. It runs for c = 1 because 1 < 2 is true.
  • This prints the current value of r, which is 2, once.
  • When r = 3:
  • In the final pass of the outer loop, the condition is c < 3. The inner loop runs for c = 1 and c = 2.
  • This results in printing the value of r, which is 3, twice.

Question 68

Give the output of the following program segment:

void encode() 
{ 
    String s= "DICe"; 
    char ch; 
    for(i=0;i<4;i++) 
    {  ch=s.charAt(i); 
        if("AEIOUaeiou".indexOf(ch)>=0) 
        System.out.println("@"); 
else 
System.out.println(ch); 
}   
Answer:

Right away, you might notice a tiny syntax error in the code provided – the method encode() is missing its final closing curly brace }. It’s a common mistake, so let’s add it in to see how the program is meant to run.

The corrected code looks like this:

void encode() 
{ 
    String s= "DICe"; 
    char ch; 
    for(i=0;i<4;i++) 
    {  ch=s.charAt(i); 
        if("AEIOUaeiou".indexOf(ch)>=0) 
        System.out.println("@"); 
else 
System.out.println(ch); 
}  
}

Output

D
@
C
@

Explanation

Let’s trace the logic step-by-step to understand how we get this output.

  1. The method starts with void encode(), which simply means we’re defining a block of code named encode that won’t return any specific value.

  2. Inside, String s = "DICe"; creates a string variable s and stores the word "DICe" in it.

  3. Then, char ch; declares a character variable ch. We’ll use this to hold one letter from our string at a time.

  4. The heart of the program is the for(i=0;i<4;i++) loop. This loop is set to run 4 times, with the variable i taking on the values 0, 1, 2, and 3. This is perfect for accessing each of the four characters in our string s.

  5. On each pass of the loop, ch = s.charAt(i); pulls out the character at the current index i from the string s and places it into our ch variable.

  6. The crucial check is if("AEIOUaeiou".indexOf(ch) >= 0). This is a clever way to see if ch is a vowel. The indexOf() method searches for the character ch inside the string of vowels "AEIOUaeiou". If it finds the character, it returns its position (an index from 0 upwards). If the character is not found, it returns -1. So, if the result is greater than or equal to 0, we know we have a vowel!

  7. If the if condition is true (meaning ch is a vowel), System.out.println("@"); prints the @ symbol on a new line.

  8. If the if condition is false (meaning ch is a consonant), the else part runs, and System.out.println(ch); prints the original character ch itself on a new line.


Question 69

Name the following:

(a) What is the main condition to perform binary search on an array?

(b) A sort method in which consecutive elements are NOT compared.

Answer:

(a) Think about how you find a word in a dictionary. You don’t start from the first page, do you? You jump to the middle because you know it’s in alphabetical order. Binary search works the same way, by repeatedly dividing the search area in half. This powerful technique only works if one main condition is met: The array must be sorted.

(b) Remember Bubble Sort? It’s all about comparing adjacent, or consecutive, elements. The method you’re thinking of here is different. It scans the entire unsorted part of the array to find the smallest element and then swaps it into the correct position. It doesn’t just look at its next-door neighbour. This method is Selection sort.


Question 70

Answer the following:

(a) Scanner class method to accept a character.

(b) Jump statement which stops the execution of a construct.

Answer:

(a) It’s a common point of confusion, but the Scanner class doesn’t have a direct method to accept just a single character. We handle it with a clever two-step combination. First, we use <Scanner object>.next() to read the input as a String. Then, from that String, we pull out the very first character at index 0 using .charAt(0). So, the full method to accept a character is <Scanner object>.next().charAt(0).

(b) Think about when you’re inside a loop or a switch case and you need to get out immediately. You don’t want the rest of the code in that block to run. The jump statement that stops the execution of a construct right then and there is break.


Question 71

How many times the given loop is executed? Give the output of the same.

for(k=10;k<=20;k+=4) 
{ 
   System.out.println(k); 
   if(k%3==0) continue; 
}       
Answer:

This loop will run a total of 3 times.

Output

10
14
18

Explanation

Let’s trace the journey of the variable k. The loop starts from an initial value of k = 10. It’s designed to continue running as long as the condition k <= 20 holds true, and with each pass, the value of k increases by 4.

So, the sequence of values for k that the loop will actually process are: 10, 14, and 18. After the loop runs for k=18, the next value for k would become 22. When the condition is checked for k = 22, k <= 20 becomes false, and the loop immediately stops. For this reason, we can see that the loop runs 3 times, printing the value of k on each pass.

Frequently Asked Questions


These questions are designed to test your core understanding of fundamental Java concepts, syntax, and standard library methods. They assess your ability to recall and apply knowledge quickly and accurately, which is a key skill for the ICSE board exam's Section A.


First, try to answer each question on your own without looking at the solution. Then, compare your answer with our provided solution to identify any gaps in your knowledge. This practice helps reinforce concepts and familiarises you with the precise terminology expected by ICSE examiners.


Yes, questions of this format (2 marks each) are a significant part of Section A in the ICSE Computer Applications theory paper. Mastering them is crucial for building a strong score, as they cover a wide range of topics from the syllabus in a direct, knowledge-based format.


This chapter provides detailed, step-by-step solutions for all 24 Very Short Answer Questions. Each solution is crafted to meet the specific requirements of the ICSE marking scheme, ensuring you understand how to score full marks.