SUB:
COMPUTER FOR CLASS X MARKS: 100
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. Write
an expression in java for cosx+√ a3+b3 [2]
b. What
is the difference between if ...else...if ladder and Switch....case. [2]
c. What
is the use of default in a switch? [2]
d. What
is an infinite loop? Write an infinite loop statement. [2]
e. Name
the looping statement most commonly used when the no. of iteration is fixed and
known before setting up the loop. [2]
2.
a. Write
a main difference between while loop & do while loop [2]
b. Write
the output of the following code. [1]
String
str=”COMPUTER”;
System.out.println(str.charAt(2));
c. Write
the output of the following code. [2]
Sting
str1=”cat”;
String
str2=”cat”;
1.
str1==str2;
2. str1.equals(str2);
d. Read
the following program and answer the questions
class program{
public
void main(){
int
a, b , i, j;
for(i=1;i<4;i=i+1){
for(j=1;j<=i;
j=j+1){
System.out.print(“”+j);
}
System.out.println();
}}}
I. how
many times the first loop of “i” will perform? [1]
II. how
many times the first print statement work? [1]
III. what
will be the output of the program?
[3]
3.
3. a.
Rewrite the following set of if-else
statements in terms of switch case statements. [2]
class Demo
{
public void main()
{
int
num, calc;
System.out.println(“Enter
a number”);
if(num==15)
{
calc=num*25-20;
System.out.println(num+calc);
}
else
if(num==20)
{
calc=num*25-15;
System.out.println(calc-num);
}
}
}
b. Rewrite
the following using if....else [2]
double
comm=(sale>2000)?sale*5/100 : 25;
c. Explain
the relationship between class and objects. [2]
d. Explain
any two types of access specifiers. [2]
e. In
which package are the wrapper classes contained? [2]
4.
a. Write
the difference between actual and formal parameters. [2]
b. What
is an identifier in java? [2]
c. Differentiate
between isUpperCase(char) and isLowerCase(char) [2]
d. Write
a statement to create an object of a class Rectangle that invokes a parameterized constructor that accepts two int type values. [2]
e. Explain
Encapsulation. [2]
Section
B(60 marks)
Attempt
any 4 questions out of 6
5. 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 characters present in the string
6. Write
a program to print these series.
a. 1 [7]
2 2
3 3 3
4 4 4 4
5 5 5 5 5
b. 1 [8] 2 3
4
5 6
7
8 9 10
11
12 13 14 15
7.
A
factory has different categories of workers as given below, who are paid
different hourly rates(R). Wages are determined after accepting the number of
hours (H) he works during the week. The different classes are paid as follows. [15]
Category
|
Hourly Rate
|
Unskilled
|
Rs. 20.00
|
Semi-skilled
|
Rs. 30.00
|
Skilled
|
Rs. 40.00
|
Write a program in java (Create a class)
which takes in the category of the worker, his name and the number of hours
that he works during the week and displays his name and weekly wages.
8. Write a class in java to enter any number and print if it is a perfect number.[Hint: a number is said to be perfect if it is equal to sum of all its factors ex, 6=1+2+3, hence 6 is perfect number] [15]
9. Write a program to accept a string. Convert the string to uppercase. Count and output the number of double letter sequences that exist in the string.
Sample Input: Aarti bought a cotton shirt
and butter from mall
output: 4 [15]
10. Write a manu driven program to perform the following(use switch case statement)
a.
S=1/2 + 3/4 - 5/6 +
7/8-------19/20 [7]
b.
To print the series 0, 3,
8, 15, 24,......n terms(value of n is to be an input by the user) [8]
No comments:
Post a Comment