For more programs

Standard: X                            Subject: Computer              Max Marks: 100

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

Section A(40 marks)

Attempt all questions

 Question 1.                                                                                                   [2X5=10]

  1. What is the purpose of this keyword?
  2. Write an expression in Java for                C=A5 + sin B
  3. What are library classes? Give an example.4.
  4. What is an exception? Name 2 exception handling blocks.
  5. What is a constructor and what is its use?

 Question 2.                                                                                             [2X5=10]

  1. Write a java statement to check if the fourth element of an array arr[10] is divisible by 2
  2. State the output when number=123 and also state what the method is doing?

void main(int number)

{         int a, b=number, c=0, d, s=0;

         while (b!=0)  {







3. Differentiate between Binary Search and Linear Search.

4.  Name the search or sort algorithm that:

i) Makes several passes through the array, selecting the next smallest item in the array each time and placing it where it belongs in the array.

ii) At each stage, compares the sought key value with the key value of the middle element of the array.

5.What do you understand by bitwise operator? Give example.

Question 3.                                                                                [2X5=10]

a) Differentiate between Instance variable and Local variable.

b) What are the final values stored in x and y below?

double a= -46.55;

double b= 15.94;

double x=Math.abs(Math.floor(a));

double y=Math.rint(Math.min(a,b));

c)String s = “Mechanical”;

int p = s.indexOf(‘h’);



d)State the total size in bytes, of the arrays a[8] of int data type and p[2] of float datatype.

e) Name 2 OOP’s principles

 Question 4.                                                                                [2X5=10]

 a)What is the result stored in x, after evaluating the following expression

int x=3; x=++x + 3 * x–

b)Write the difference between length and .length() function.

c) Differentiate between user defined and primitive data type

d) If int n[ ] = { 6,4,3,2,7,9,15,19}, what are the values of x and y?

x = Math.pow(n[4], n[2]);

y= Math.sqrt(n[5]+n[7]);

e) What is the difference between public and private access modifier.

Section B (60 marks)

Attempt any 4 questions from this section

Each program should be written using a variable list so that the logic of the program is clearly depicted.

Question 5.                                                                                            [15]

Write two separate programs to generate the following patterns using iteration(loop)statements:

a)                                                                                      b)

&                                                                                     54321

&#                                                                                  5432

&#&                                                                              543

&#&#                                                                             54

&#&#&                                                                          5

Question 6.

A company has employees, who are divided into four grades depending on their Basic pay per month as follows,

Basic(Rs./month)     Grade             DA         HRA

10,001 or more             1                  40%        30%
5,001 to 10,000           2                   40%        25%
2001 to 5,000              3                   30%        20%
2,000 or less                4                  30%         15%

If the Net salary which is the total of Basic, DA, and HRA, is above Rs.50, 000 per month then Income Tax at the rate of 30% of the annual salary exceeding 50,000 is deducted on monthly basis.

Taking name of the employee and the Basic (monthly) pay as inputs, prepare & print a pay slip, which contains Name, Grade, Basic monthly pay, DA, HRA, Monthly Income Tax and Net Monthly Salary, for employee.     [15]

 Question 7.

Write a program to perform linear search on a list of integers given below, to search for an element input by the user, if it is found display the element along with its position, otherwise display the message “Search element not found”

5, 7,9,11,15,20,30,45,89,97                                                                                    [15]

Question 8.

Write a program to input a number and print whether the number is a special number or not.  (A number is said to be a special number, if the sum of the factorial of the digits of the number is same as the original number).

Example: 145 is a special number, because 1! + 4! + 5! = 1 + 24 + 120 =145

(where ! stands for the factorial of the number and the factorial value of a number is the product of all integers from 1 to that number, example 5! = 1*2*3*4*5 = 120).                                                                                     [15]

Question 9.

Using the switch statement, write a menu driven program to :

i) Generate and display the first 10 terms of the Fibonacci series 0,1,1,2,3,5….The first two Fibonacci numbers are 0 and 1, and each subsequent  number is the sum of the previous two.

ii) Find the sum of the digits of an integer that is input.

Sample Input :                         15390

Sample Output:           Sum of the digits = 18

For an incorrect choice, an appropriate  message should be displayed.   [15]

Question 10.

Write a program that encodes a word into Piglatin. To translate word into piglatin word, convert the word into uppercase 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 ebing shifted towards the end followed by “AY”.

Sample Input (1) :           London,

Sample Output (1) :        ONDONLAY

Sample Input (2) :           Olympics,

Sample Output (1) :       OLYMPICSAY

To learn more basic java concepts watch the video.


Please enter your comment!
Please enter your name here