 Std: X Subject: Computer Max 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)
Q 1. (5×2=10)

a) Write a function prototype of the following:
A function PosChar which takes a string argument and a character argument and returns
an integer value.
b) Give the output of the following string functions :
(i) “MISSISSIPPI”.indexOf(‘S’) + “MISSISSIPPI”.lastIndexOf(‘I’)
c) Analyze the given program segment and answer the following questions :
(i) Write the output of the program segment
(ii) How many times does the body of the loop gets executed?
for(int m=5; m<=20; m+=5) { if(m%3 == 0) break; elseif(m%5 == 0) { System.out.println(m); continue; } } d) Write the java expression for the following. A2+B3 e) Write the return type of the following library functions : (i) isLetterOrDigit(char) (ii) replace(char,char)

Q 2. [5X2=10] a) Explain the term “pass by reference”? b) What is ‘this’ keyword? What is its significance?

c) Differentiate between linear search and binary search techniques?

d) Name the type of error (syntax, runtime or logical error) in each case given below:

a. Math.sqrt (36-45)

(ii) int a;b;c; e;

If int x [ ] = { 4, 3, 7, 8, 9, 10 };

what are the values of p and q? a. p = x.length

(ii) q = x + x * x

Q 3. [10X2=20] a) Differentiate between compareTo() and equals() methods.

b) Differentiate between indexOf() and valueOf() methods.

c) Find the output of z: int y = 14; int z = ++y * (y– + –y);

d) Write the output for the following statements:

String strl =”Java is Fun”;

String str2 = “amytime”; System.out.println(str2.replace(m’,’n’)); System.out.println(strl.concat(str2));

e) Rewrite the program segment using multiple if-construct. if(n%2==0 && n>35 && n<67) {
a=a+4;
n=n/a;
rem=n%10; }
f) Create an object for a class Park named Botanicpark.
g) What is a parameterized constructor?
h) What is the use of static in the main method?
i) State the difference between Constructor and Method.
j) Explain the function prototype and the signature?

Section B (60 marks)

Attempt any 4 programs out of 6

(Each program carries 15 marks)

1. a. WAP to generate all Perfect numbers up to 1000.
b. Write a program to accept a number then print the sum of digits and number of digits present in it. (E.g. If the input number is 225, the sum of digits is 9 and number of digits is 3). (7)
2. WAP to enter any sentence and calculate the following:
a) Total number of digits present in it.
b) Total number of small letters and capital letters present in it.
c) Total number of alphabets used in it.
d) Total number of special character used in it.
e) Total number of vowels presents in it.
f) Total Number words present in that sentence.
3. WAP in Java to accept names of the 10 politicians and their party to which they belong to in two separate arrays. Ask the users to enter the name of the party. Printout all the names of the politicians who belong to that party.
4. Accept the name and total marks of 15 students from user. Then display the list according to their merit. (Use Bubble sort technique)
5. Write a class to display each word of the string in reverse order. e.g. If input is “India is my Country” output is “aidnI si ym yrtnouC”. Use following function in your class:
public String reverse(String word) which will return the reverse word.
6. Define a class named BookFair with the following description:
Class: BookFair
Instance variables/Data members:
String Bname – stores the name of the book.
double price – stores the price of the book.
Member Methods:
(i) BookFair() Default constructor to initialize data members.
(ii) void Input() To input and store the name and the price of the book.
(iii) void calculate() To calculate the price after discount. Discount is calculated based on the following criteria.
Price Discount
Less than or equal to Rs 1000 2% of price
More than Rs 1000 and less than or equal to Rs 3000 10% of price
More than Rs 3000 15% of price
(iv) void display() To display the name and price of the book after discount.
Write a main method to create an object of the class and call the above member methods.