You are on page 1of 3

Worksheet for Class 10

1. Choose the correct answer and write the correct option.


i) Identify the identifier
a) break
b) switch
c) void
d) Else
ii) What is the bit size of float data type?
a) 16
b) 32
c) 64
d) 8
iii) Return type of Math.random() is
a) float
b) int
c) double
d) long
iv) Name the type of error in the following statement.
int b=8;
double c=Math.cbrt(b);
System.out.println(“Square Root=”+c);
a) Logical error
b) Runtime error
c) Syntax error
d) Exception
v) Name the construct that has same name as class name.
a) Function
b) Constructor
c) Static Method
d) Instance Method
vi) Name the package imported by default
a) util
b) io
c) lang
d) applet
vii) Identify the incorrect statement where the array a[] is of size 10
a) System.out.print(a[0]);
b) System.out.print(a[5]);
c) System.out.print(a[9]);
d) System.out.print(a[10]);
viii) what will be the output of the following code?
System.out.print(“Application”.substring(2, “Application”.lastIndexOf(‘i’));
a) plicat
b) pplicati
c) plicati
d) pplicat
ix) Function overloading depends on ________
a) Return type
b) Function signature
c) Access specifier
d) Modifier
x) _____ is a binary operator.
a) ++
b) >=
c) ?:
d) --

2) Answer the following questions.


i) Differentiate between pure function and impure function in Java.
ii) Name and explain the feature of OOP which is implemented in method
overloading.
iii) Find out the value of the following expression if x=7,y=10;
x+= ++x % y *10 – y++ / 2
iv) Define two characteristics of constructor.
v) Write down the following code using if else statement :-
z=(x>y)? x+10:(y>10)? y-5: y+5;

3) Write a program read an array and check the array is palindrome or not. E.g,
a={5,8,2,8,5}

4) Write a program to encode a word into Piglatin. To translate word into a


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 being shifted to the end
followed by “AY”.

5) Write a program to input N number of elements into an integer array and


print the smallest prime number in the array.

6) Design a class Check to overload a function number() as follows:


void number(int n) : Check and display if n is a Terminal Number or not. If
the first and last digit of a number are same then it is called a terminal
number. Eg :- 6476
void number(int n, int m) : Accept two numbers and check the numbers are
an Amicable pair or not. [Amicable numbers are two different numbers so
related that the sum of the proper divisors of each is equal to the
other number. Example 220,284.
Sum of divisor of 220=1+2+4+5+10+11+20+22+44+55+110=284.
Sum of divisor of 284=1+2+4+71+142=220]
7) Define a class Employee having the following description:
Data Members: int pan(To store personal account number)
String name (To store name)
double taxincome(To store annual taxable income)
double tax (To store tax that is calculated)
Member Function:
void input() :Accept and Store the pan number, name, taxable income
void cal() :Calculated tax of an employee
void display():Output details of an employee
Total Annual Taxable Tax Rate
Income
Up to Rs.100000 No Tax
From Rs.100001 to 10% of income exceeding
150000 Rs.100000
From Rs.150001 to Rs.5000+20% of income
250000 exceeding Rs.150000
More than Rs.250000 Rs.25000+30% of income
exceeding Rs.250000
Write a program to compute the tax according to the given conditions and
display the output as per given format.
Output
Pan Number Name Tax income Tax
………. ……….. …………….. ……….
Write down the main function to call the mentioned functions to accept
the employee’s details, calculate tax and display employee’s details
according to the given format.

You might also like