ICSE Computer Applications Model Questions
ICSE Computer Applications Model Questions
for(x=10, c=20;c>=20;c=c-2)
x++:
4. What is the final value of ctr when the iteration process given below,
executes?
int ctr=0;
for(int j=1;j<=5;j+=2)
++ctr;
Question
2
[10]
1. Which keyword used to acquire the properties of one class to another class?
2. Here is a skeleton definition of a class
class Sample {
int i;
char c;
float f;
} Implement the constructor.
3. Write a program to check whether the given number is palindrome or not.
4. Differentiate between public and private modifiers for members of a class.
5. What type of inheritance does Java here?
Question
3
[10]
int n=15;
for(int i=1;i<5;i++)
m++;
–n;
System.out.println(“m=”+m);
System.out.println(“n=”+n);
4. 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-40;
System.out.println(p);
5. The following is a segment of a program
x=1; y=1;
if(n>0) {
x=x+1;
y=y+1;}
Question
4
[10]
1. Give two differences between the switch statement and if else statement.
2. Write two difference between linear search and binary search.
3. Given that in x[][]={{2,4,6},{3,5,7}}, what will be the value of x[1][1] and
x[0][2]?
4. State the total size in bytes, of the arrays a[4] of char data type and p[6] of
float data type.
5. If int x[]={4,3,7,8,9,10}; What are the values of p and q?
i) p= x.length ii) q=x[2] +x[5] * x[1]
Section B (60 Marks)
Attempt any four questions from this Section.
The answers in this Section should consist of the Programs in either BlueJ
environment or any program environment with Java as the base.
Each program should be written using Variable descriptions/Mnemonic Codes
such that the logic of the program is clearly depicted.
Flow-Charts and Algorithms are not required.
Question 5
[15]
Designa class to overload a function polygon() as follows:
i) void polygon(int n, char ch) : with one integer argument and one
character type argument that draws a filled square of side n using the character
stored in ch.
1. ii) void polygon(int x, int y) : with two integer arguments that draws a filled
rectangle of length x and breadth y using the symbol ‘@’.
iii) void polygon() : with no argument that draws a filled triangle
shown below.
Example:
@@@@@
@@@@@
iii) Output
**
***
Question
6
[15]
Write a menu driven program to accept a number and check and display whether
it is a prime number or not OR an automorphic number or not.
13.a) Prime number : A number is said to be a prime number if it is divisible
only by 1 and itself and not by any other number. Example; 3,5,7,11,13..
14.b) Automorphic number : An automorphic is the number which is contained
in the last digit of the square. Example : 25 is an automorphic number as its
square is 625 and 25 is present as the last two digits.
Question
7
[15]
Special words are those words which start and end with the same letter.
Examples: EXISTENCE, COMIC, WINDOW
Palindrome words are those words which read the same from left to right and vice-
versa.
All palindromes are special words, but all special words are not palindromes.
Write a program to accept a word check and print whether the word is a
palindrome or only special word.
Question
8
[15]
Write a program that encodes a word into Piglatin. To translate a word into a
Piglatin word, convert the word into upper case and then place the first vowel of
the original word as the start of the new word along with the remaining alphabets.
The alphabets present before the vowel being shifted towards the end following by
“YZ”.
Sample input : Flowers Sample Output: OWERSFLYZ
Sample input : Olympics Sample Output : OLYMPICSYZ
Question
9
1) Write a program to initialize the given data in an array and find the minimum
and maximum values along with the sum of the given
elements.
[5]
Numbers: 2 5 4 1 3
Output: Minimum value : 1
Maximum value=5
Question
10
[15] Define a class and store the given city names in a single dimensional array.
Sort these names in alphabetical order using the bubble sort technique only.
Input: Calcutta, Agra, Mumbai, Bangalore, Delhi
1. Define abstraction.
2. Define escape sequence with examples.
3. Write a difference between the functions isUpperCase( ) and
toUpperCase( ).
4. How are private members of a class different from public members?
5. Classify the following as primitive or non-primitive datatypes:
(i) char(ii) arrays(iii) int(iv) classes
Question
1
[10]
1. What is dynamic initialization, with an example?
2. How are the following passed in Java? i) primitive types ii) reference types
3. Consider the following class:
public class myClass {
public static int x=3, y=5;
public int a=2, b=3; }
i) Name the variables for which each object of the class will have its
own
distinct copy.
4. ii) Name the variables that are common to all objects of the class.
5. Create a class with one integer instance variable and one class variable.
Initialize the variable using i) default constructor (ii) parameterized
constructor
6. Write a java statement to create an object mp4 of class digital.
Question
2
[10]
1. What are the values of x and y when the following statements are executed?
int a=63, b=36;
boolean x=(a>b) ?a:b;
int y=(a<b)?a:b;
2. What will be the result stored in x after evaluating the following expression?
int x =4;
x+ = (x++ ) + (++x) +x;
3. State the method that:
i) Converts a string to a primitive float data type.
4. ii) Determines if the specified character is an uppercase characters.
5. Write the Identifier Naming Rules. (All rules)
6. Rewrite the following program segment using the if –else statements instead
of the ternary operator.
String grade= (mark >= 90)?”A”: (mark >=80)? “B”: “C”;
Question
4
[10]
Write a program to input that age, gender (male or female) and taxable income of a
person. If the age is more than 65 years or the gender is female, display “Wrong
category”. If the age is less than or equal to 65 years and the gender is male,
compute and display the income tax payable as per the table given above.
Question
6
[15]
Member Methods:
1. void input() – to input and store accession number, title and author.
2. void compute() – to accept the number of days late, calculate and
display the fine charge at the rate Rs. 2 per day.
void display() – to display the details in the following format:
Question
7
[15]
Write a program to accept a word and convert it into lower case if its in uppercase
and display the new word by replacing only the vowels with the preceeding
characters.
Question
8
[15]
Write a program that encodes a word into Piglatin. To translate a word into a
Piglatin word, convert the word into upper case and then place the first vowel of
the original word as the start of the new word along with the remaining alphabets.
The alphabets present before the vowel being shifted towards the end following by
“YZ”.
String flavor – stores the flavor of the juice (eg: orange, apple etc.)
String pack_Type – stores the type oif packaging (eg:tetra-pack, PET
bottle etc.)
int pack_size – stores package size(eg: 200mL, 400 mL, etc.)
Member Methods:
1. FruitJuice() – deault constructor to initialize integer data members to 0
and String data members to “”
2. void input() – to input and store the product code, flavor, pack type,
pack size and product price.
void discount() – to reduce the product price by 10%.
1. void display() – to display the product code, flavor, pack type, pack
size and product price.
Write a main method to create an object of the class and call the above member
methods.
Question
10
[15]
Design a class to overload a function JoyString() as follows:
1. void JoyString(String s, char c1, char c2) : with one string argument and
two character arguments that replaces the character argument c1 with the
character argument c2 in the given string s and prints the new string with
first character as uppercase.
Example: s=”technology”
c1=’a’, c2=’o’
Output: “Technology”
1. void JoyString(String s1, String s2) : check and print string having more
characters compared to the other one.
void JoyString(String s) : prints the position of the first space and last space
of the given string s.
Example : Input value of= “Cloud computing means Internet based
computing”
Output: First index= 5, Last index = 36
Write the main() and call the above member methods.