Icse Sample Paper-5 For Computer Applications
Icse Sample Paper-5 For Computer Applications
Page 1 of 4
3. c=(a>b)?b:a; 4. None of the above
(a) State the value of y after the following is executed:
char x='#';
y= Character.isLetter(x);
1. true 2. # 3. True 4. false
(b) Give the output of the following string methods:
"APPREHENSIVENESS".compareTo ("APPREHENSIVE");
1. 4 2. 32 3. -4 4. 46
(c) if(a<10)
st=“single digit”;
else if(a<100)
st=“double digit”;
else
st=“multiple digit”;
It can be written as:
1. st=(a<100)?(a<10)?”single digit”: “double digit” : “multiple digit”;
2. st= (a<100) :( a<10):”single digit”? “double digit” ? “multiple digit”;
3. st=(a<100)?(a<10): ”single digit”? “double digit” : “multiple digit”;
4. None of the above.
(e). Function overloading does not depend on
1. return type 3. number of parameters
2. type of parameters 4. all of the above
Question 3
Choose the correct option [5 x 1=5]
(a) _________ can be used in between the characters to separate the words of a variable name
1. space 3. underscore
2. comma 4. dollar
(b) The ________sign denotes that all the classes of the concerning package will be made
available for use in your program.
1. + 2. * 3. ^ 4. ~
(c) An if or else if statement accepts ______ as input before branching.
1. int 2. char 3. float 4. boolean
Page 2 of 4
int a=6, b=7;
int sum=a+b; int pr=a*b;
return(sum);
return(pr);
}
1. 13 3. 13,42
2. 42 4. 42,13
(d) Calling a method is also termed as
1. parameter passing 3. method header
2. invoking a method 4. none of the above
(e) Impure method is also known as
1. caller method 3. Mutator
2. operational method 4. none of the above
Question 5 [10 x 2=20]
A. Assume that i=1, j=2, k=3 and m=2. What does each of the following statements print?
a. System.out.println(i+j >=k);
b. System.out.println(!(k>m));
B. What is an infinite loop? Write an infinite loop statement.
C. What are wrapper classes? Give the name of the function that converts a string into int.
D. Write the output for the following:
String s1 = ''phoenix''; String s2 =''island'' ;
a. System.out.println (s1.substring(0).concat (s2.substring(2) ) );
b. System.out.println(s2.toUpperCase());
E. Write an expression in Java for C=A 3+2/|B|
F. What is a constructor? When is it invoked?
G. Write the return data type of the following function.
a. endsWith() b. toLowerCase()
H. Give the output of the following program segment:
double x=6.2, y=4.7;
a. System.out.println(Math.min(Math.floor(x),y));
b. System.out.println(Math.max(Math.ceil(x),y));
I. Give the output of the following.
a. “RABBIT”.replace(“B”,”P”); b. “TEAR”.compareTo(“DEAR”);
J. What will be the output of the following code?
a. System.out.println("FRIDAY". substring (3));
b. System.out.println("WONDERFUL". substring (3,6));
SECTION B (60 Marks)
Attempt any four programs [4X15=60]
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. (Use switch- case statement)
(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 etc.,
(b) Automorphic number: An automorphic number is the number which is contained in the last
Page 3 of 4
digit(s) of its square. Example 25 is an automorphic number as its square is 625 and 25 is
present as the last two digits.
Question 7 Write a menu driven program to print the following patterns.
1. A 2. J J J J
BC AAA
DEF VV
GHIJ A
For incorrect choice, an appropriate message should be displayed. [15]
Question 8 [15]
Design a class to overload a function check ( ) as follows :
(i) void check (String str, char ch) – to find and print the frequency of a character in a string.
Example : Input: str = “success” ch = ‘s’ .
Output: number of s present is = 3
(ii) void check(String si) – to display only vowels from string si, after converting it to lower
case.
Example: Input: s1 = “computer”
Output: o u e
Question 9 Write a program to accept email id from the user and display, username, domain
name and extension
Sample Input: [email protected]
Sample Output: Username: computer
Domain name: gmail
Extension: com
Question 10
Design a class name Purchase with the following description :
Instance variables/ Data members :
String name – To store the name of the customer
long mobno – To store the mobile number of the customer
double cost – To store the cost of the items purchased
double dis – To store the discount amount
double amount – To store the amount to be paid after discount
Member methods: –
Purchase () – default constructor to initialize data members
void input() – To input customer name, mobile number, cost
void calculate() – To calculate discount on the cost of purchased items, based on following criteria.
Cost Discount (in percentage)
Less than or equal to 10000 2%
More than 10000 and less than or equal to 20000 5%
More than 20000 and less than or equal to 35000 7%
More than 35000 10%
void display() – To display customer name, mobile number, amount to be paid after discount
Write a main method to create an object of the class and call the above member methods.
Question 11 Define a class to accept a word in Lowercase and display the new word after
removing all the repeated letters.
Sample Input: applications
Sample output: aplictons [15]
Page 4 of 4