SUNDAY, 12 JULY 2026
Guide For School logo Guide For SchoolStudy Guide For Students On Java Programming
Physics | Chemistry | Mathematics
ICSE | ISC | CBSE
Guide For School logo Guide For SchoolICSE and ISC Resources

[Week 2] Weekly Important Practice Questions for ICSE Computer Applications

28 October 2012

This week we have a few questions which deals with finding the output of certain given programming codes for the ICSE students preparing for their 2013 Computer Applications Examination.

This week we have a few questions which deals with finding the output of certain given programming codes for the ICSE students preparing for their 2013 Computer Applications Examination.

[To know more about these weekly practice questions, Click Here]

You need to answer the given questions, and reply it as comments by filling the "Leave a Reply" section below this post.

The correct answers will be posted next week.

Questions:

1. What will be the output of the below code when n=145

int number(int n) { int s=0; while(n>0) { s=s+n%10; n/=10; } return n; }

2. Give the output of the below code:

public static void main() { String s1="Java For", s2="School Students"; System.out.println("L"+s1.substring(1,4)); System.out.println(s2.indexOf(s1.charAt(6))); System.out.println(s1.concat(s2)); System.out.println(s1.compareTo(s2)); System.out.println(s2.equals(s1)); }

3. Give the output of the below code:

public static void main() { int c=900,n=2000; int x=0,y=0; x=n+(c>2550?1350:1500); y=n+c>2550?1350:1500; System.out.println("x = "+x); System.out.println("y = "+y); }

Answers:

Answer 1.

0 [because, the function number ( ) is returning the value of ‘n’, and as we know that after the execution of the given while loop, the value of ‘n’ becomes 0. Hence, the answer will be 0.]

Answer 2.

Lava [because, s1.substring(1,4) gives, “ava”. Hence, “L”+”ava” = Lava] 3 [because, s1.charAt(6) will give ‘o’ and hence, s2.indexOf(‘o’) will give 3.] Java forSchool students [Note: There will be no space between “Java for” and “School students”] -9 [because, the (ASCII value of J – ASCII value of S) = 74-83 = -9] false [because, “Java for” and “School students” are not equal.] Answer 3. x=3500 [because, first (c>2550?1350:1500) is calculated and then the result is added to the value of ‘n’. Since, 900 is not greater than 2550, so the result of (c>2550?1350:1500) is 1500, which is then added to the value of ‘n’ i.e. 2000, and we get the answer as 3500.]

y=1350 [because, in this case, first the value of n+c is calculated and then (n+c>2550?1350:1500) is calculated. Since, n + c = 2000 + 900 = 2900 which is greater than 2550, so the result of (n+c>2550?1350:1500) is 1350.]

Leave a Reply

Your email address will not be published. Comments are reviewed before appearing publicly.

Send a comment or correction

Study smarter

Everything you need for ICSE and ISC Computer

Programs, revision notes, solved papers and practical guidance—organized for quick study.

Browse all resources →