Home Programming Java ICSE computer application sample paper 6

ICSE computer application sample paper 6

0
241

This paper is divided into two sections. You are to answer all the questions from section A, and any four from section B.

Section A (40 marks)

1.
a. What is the difference between local variable and instance variable? [2]
b. Write an expression in java for Cos x + 2AB/y [2]
c. What is the difference between a static member function and a member function                   which is not static? [2]
d. What is a Wrapper class? Give 2 examples. [2]
e. How many times does the loop iterate? Also give the output for the following code            snippet.
int x;
for(x = 1; x< =10; x + +)
{
x + +;
System.out.println(x + +);
} [2]

2.
a. Rewrite the following if-else statement in terms of switch-case statements? [2]
char code;
if(code==’A’)
System.out.println(“Excellent”);
else if(code ==’B’ || code ==’C’)
System.out.println(“Good”);
else if(code ==’D’)
System.out.println(“Poor”);
b. What is the difference between ‘= =’ and ‘equalsIgnoreCase( )’ [2]
c. Write the output of the following code. [2]
String str=”International”;
System.out.println(str.charAt(4));
System.out.println(str.lastIndexOf(‘a’));
d. Write the output of the following. [4]
String s1 = “INFORMATION”;
String s2 = “TECHNOLOGY”;
i. System.out.println(s1.substring(0,4).concat(s2.substring(6,10))
ii. System.out.println(s1.substring(2));
iii. System.out.println(s1.charAt(s1.indexOf(‘R’) + s2.indexOf(‘C’)));
iv. System.out.println(s2.replace(‘T’ , ‘F’));

3.
a. What will be the output for the following program segment? [2]
int a = 10,b=30,c=40;
a= –b + c * a / 2;
System.out.print(“a” + a);
System.out.print(“b ” +b );
b. Give the difference between actual parameter and formal parameter. [2]
c. Differentiate between equals() and compareTo() functions. [2]
d. State the purpose and return data type of the following String functions :- [2]
i) trim()
ii) charAt( )
e. What is the value stored in variable val given below: [2]
double val= Math.pow(“137”.indexOf(‘7’),3);

4.
a. Define the integer data members numl and num2 in the class. Initialize them with the values in a default constructor and parameterized constructor. [2]
b. State the difference between method and constructor. [2]
c. Differentiate between isUpperCase(char) and toLowerCase(char) [2]
d. What will be the output of the following program segments? [2]
String s = “application”;
int p = s.indexOf(‘a’);
System.out.println(p);
System.out.println(p+s);
e. Write a statement to create an object of a class Student that invokes a parameterized constructor that accepts one String and one int type values. [2]

Section B (60 marks)
Attempt any 4 questions out of 6

5. Write a program to generate the following pattern [15]

a)
C
C O
C O M
C O M P
C O M P A
C O M P A N
C O M P A N Y

b)
&
# #
& & &
# # # #
& & & & &

6. Write a program in java to accept a string and find [15]
a. number of blank spaces in the string
b. number of words in the string
c. number of consonants present in the string
d. number of vowels present in the string

7. Write a program to accept a sentence and print only the first letter of each word of the
sentence in capital letters separated by a full stop.
Example :
INPUT SENTENCE: “Kapil Kumar Thakur”
OUTPUT: K.P.T

8. Write a Menu driven Program to do the following
a) Write a class to print the following series:
S=a/x1+a/x2+a/x3+a/x4……. a/xn [8]
b) Write a class to display prime numbers between 1 to 100 [7]

9. Define a class BILL that calculates telephone bill of a consumer having the following description:
Data members/instance variables
int billno – bill number
String name – name of consumer
int unit – no. of units consumed in a month
double amount – bill amount to be paid by the person
Member functions:
BILL () – constructor to initialize data members with default initial value
BILL(…) – parameterized constructor to accept billno, name and no. of units consumed .
calculate() – to calculate the monthly telephone bill for a consumer as per following condition
No. of Units consumed Rate in Rs.
First 100 Units Only monthly rental (Rs. 200)
Next 100 units Rs. 0.60/ Unit
Next 100 units Rs. 1.0/Unit
Above 300 Rs 1.5/Unit

display()- To display the details.
Create an object in the main() method and invoke the above function to perform the desired task. [15]

10. Overload a function check() to perform the following task [15]
i) check(int a) to check if a number is Armstrong. A number is said to be Armstrong if the sum of cubes of its digits is equal to the number.
ii) check(String str)To check if given string is palindrome

NO COMMENTS

LEAVE A REPLY

Please enter your comment!
Please enter your name here