SUB: COMPUTER                    FOR CLASS X

 

This paper is divided into two sections. You are to answer all the questions from Part I, and any four from Part II.

SECTION A (40 Marks)

Attempt all questions from this Section

 

Question 1.                                                                                                                                                        [5*2=10]

  1. Give the difference between call by value and call by reference
  2. Explain function overloading with an example.
  3. What is a keyword? Give two examples.
  4. Explain what is the job of return keyword?
  5. Mention two characteristic of java?

 

Question 2.                                                                                                                                                        [5*2=10]

  1. What is the difference between pure and impure function.
  2. What is the purpose of new keyword?
  3. Give the difference between actual parameter and formal parameter.
  4. What is the difference between unary and binary operator?
  5. What is the difference between a static member function and a not static member function?

Question 3.                                                                                                                                                                        [20]

(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) Write an equivalent Java expressions for the following expression :                                                  [2]

(c) What will be the output for the following program segment?                                                                               [4]
(i)   a. System.out.println(10%5)

  1. System.out.println(10/5)

(ii)   if a = 5 then What will be the value of

a- – + ++a%4;

(iii) System.out.println(10<10)

(iv) System.out.println(10==10)

(d) Rewrite the following if-else statement in terms of switch-case statements?                               [3]

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”);

(e) What do you understand by JVM?                                                                                                    [2]

(f)Write output of the following?                                                                                                                             [2]

if x=7,y=2;

x<<=–y;

System.out.println(“value of x=”+x);

System.out.println(“value of y=”+y);

(g) What do you understand by primitive and non-primitive data type?                                                  [2]

(h) Convert the following segment into equivalent for loop and do while loop.                                   [3]

public void display()

{

inti=10;

while ( i !=0)

{

System.out.print(i +” “);

i–  ;

}

}

SECTION B (60 Marks)

Attempt any four questions from this Section.

The answer in the Section should consist of the Program in BlueJ environment with Java. Each program should be written using Variable descriptions/Mnemonic Codes such that the logic of the program is clearly depicted. Flow-Charts and Algorithms are not required.

Question 4.                                                                                                                                                                        [15]

Design a class to overload a function series( ) as follows :

  1. i) double series(double n) with one double argument and returns the sum of the series,

sum= 1/1 + 1/2 +1/3 + …. 1/n

  1. ii) double series(double a, double n) with 2 double arguments and returns the sum of the series,

sum = 1/a2  + 4/a5  + 7/a8 + 10/a11+…… to n terms

 Question 5.                                                                                                                                                                        [15]

Given below is a hypothetical table showing the rates of income tax for male citizens below the age of 65 years:

Taxable Income (TI) in Rs. Income Tax in Rs.
Does not  exceed Rs.1,60,000 Nil
Is greater than Rs. 1,60,000 & less than or

equal to Rs. 5,00,000

(TI- 1,60,000) x 10%
Is greater than Rs. 5,00,000 & less than or

equal to Rs. 8,00,000

[(TI-5,00,000) x 20%] + 34,000
Is greater than Rs. 8,00,000 [(TI-8,00,000) x 30%] + 94,000

 

Write a program to input the age, gender (male or female) and Taxable Income of a person. If the age is less than 65 years and the gender is male, compute and display the income tax payable as per the table given above.

Question 6.                                                                                                                                                                        [15]

Write a menu driven program to :

i) To find and display all the factors of a number input by the user (including 1and excluding the number itself).

Example:

Sampleinput:                n =15

Sampleoutput:             1,3,5

ii) To find and display the factorial of a number input by the user (the factorial of a non-negative integer n , denoted by n!,is the product of all integers less than or equal to n.

Example:

Sampleinput:                n =5

Sampleoutput:             5!=1x2x3x4x5=120

For an incorrect choice an appropriate error message should be displayed.

Question 7.                                                                                                                                                                        [15]

Write a menu driven program:

i) To check and display whether a number input by the user is a composite number or not (A number is said to be composite, if it has one or more than one factor excluding 1 and the number itself).

Example 4, 6, 8,9…..

ii) To find the smallest digit of an integer that is input.

Sample input : 6524

Sample output : Smallest digit is 2

For an incorrect choice, an appropriate error should be displayed.

Question 8.                                                                                                                                                                        [15]

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

  1. 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.
  2. 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 error message should be displayed.

Question 9.                                                                                                                                                                        [15]

Define a class taximeter having the following description:

Data members/instance variables

int taxino             – to store taxi number

String name        – to store passenger’s name

int km                   – to store number of kilometers travelled

Member functions:

input () – to store taxino,name,km

calculate() – to calculate bill for a customer according to given conditions

Kilometers travelled(km)                             Rate/km

1 km                                                                  Rs 25

1 < km  6                                                            Rs 10

6  km  12                                                       Rs 15

12  km  18                                                      Rs 20

18 km                                                Rs 25

display()- To display the details in the following format

Taxino                                   Name                   Kilometres travelled                       Bill amount

–                                           –                                            –                                              –

Create an object in the main method and call all the above methods in it.

 

LEAVE A REPLY

Please enter your comment!
Please enter your name here