10 Computer Application Practice 2
10 Computer Application Practice 2
M 100
V I D Y A P E E T H TIME 2Hrs.
PRACTICE PAPER - 2
SUBJECT: COMPUTER APPLICATION
CLASS: X
SECTION – A
(Attempt all questions from this Section)
Question 1. [20x1=20]
Choose the correct answers to the question from the given options. (Do not copy the question, write
the correct answers only.)
(i)
-1-
(iv) Default constructor requires how many parameters?
(a) 3
(b) 0
(c) 2
(d) 1
(ix) Which part of the class has the same name as the class?
(a) Data
(b) Object
(c) Subclass
(d) Constructor
(x) Given an integer array of size 4, the last index will be:
(a) 0th index
(b) 2nd index
(c) 3rd index
(d) 4th index
(xvii) Assertion (A): In Java, no two identifiers can use the same name.
Reason (R): Identifiers are case-sensitive.
(a) Both Assertion (A) and Reason (R) are true, and Reason (R) is a correct explanation of Assertion
(A)
(b) Both Assertion (A) and Reason (R) are true, and Reason (R) is not a correct explanation of Assertion
(A)
(c) Assertion (A) is false, and Reason (R) is true.
(d) Assertion (A) is true and Reason (R) is false.
-3-
(xix) Assertion (A): Constructors are used to initialize the data members at the time of object creation.
Reason (R): Constructors cannot be called explicitly.
(a) Both Assertion (A) and Reason (R) are true, and Reason (R) is a correct explanation of Assertion (A)
(b) Both Assertion (A) and Reason (R) are true, and Reason (R) is not a correct explanation of Assertion
(A)
(c) Assertion (A) is false, and Reason (R) is true
(d) Assertion (A) is true and Reason (R) is false
Question 2. [10x2=20]
(i) Evaluate the given Java expressions if x = 3.0 and y = 2.0 :
y += ++x - ++x + 0.5;
(ii) Write Java expression for :
(iii) Rewrite the following code snippet using the ternary operator:
if (a > b | | a > c)
System.out.println(a + “largest no.”);
else
System.out.println(a + “not the largest no.”);
(iv) Rewrite the following loop using for loop:
int a=10;
while (a-->1)
System.out.println(“*”);
(v) Give the output of the following code and mention how many times the loop will execute?
for(int i=10; i >= 1; i --)
{
System.out.print(--i+ );
}
(vi) Write down the final value in the following code segments:
(a) TRANSPARENT.replace(‘N’ , ‘u’).toLowerCase();
(b) MISSISSIPPI.indexOf(‘S’) + “MISSISSIPPI”.lastIndexOf(‘I’);
(vii) Identify the loop in the following code segment as empty/non-empty, finite/infinite loop:
for(int i=10; i>1; i++);
(viii) Find out the error in the given code, where the smallest number will be subtracted from the largest
number and if both are equal, it should print zero:
int a=5, b=5;
if( a> b )
{
System.out.println(a-b);
else
System.out.println(b-a);
}
else
System.out.println(0);
(ix) Identify the type of conversion that is taking place here. Also, give the output.
double z=2.143;
-4-
int a=(int) z;
double b = z-a;
System.out.println(a+ + +b+ = +z);
(x) What is the purpose of ‘break’ in the switch case?
SECTION B
The answers in this section should consist of the programs in either the BlueJ environment or any
programming environment with Java as the base.
Each program should be written using variable description / mnemonic codes so that the logic of the
program is clearly depicted.
Flowcharts and algorithms are not required.
Question 3. [15]
A number is called a tech number if the given number has an even number of digits, and the number can be
divided exactly into two parts from the middle. After equally dividing the number, sum up the numbers and
find the square of the sum. For example, if N= 2025, 20+25 = 45, (45)2=2025.
Write a program in Java to accept an even digit number and check and print whether it is a Tech number or
not.
Question 4. [15]
Write a program in Java to accept the employee’s name and annual salary of a person and compute the tax
payable as per the given criteria. The program should print the data in the given format:
Question 5. [15]
Write a program in Java to find and print the sum of the given series:
1 1 1 1
Sum = 𝑥 − 2𝑥 + 3𝑥 − 4𝑥 + ⋯ 𝑢𝑝 𝑡𝑜 𝑁 𝑡𝑒𝑟𝑚𝑠, where x and N are positive integers and the value of x and
N will be entered by the user.
Question 6. [15]
Write a program in Java to print the given pattern where the total number of rows will be entered by the
-5-
user.
For N=3, the pattern will be –
A
BB
CCC
Question 7. [15]
Write a menu-driven program in Java to convert weight in grams to milligrams and vice-versa as per the
user’s choice. Print both the weight.
Option 1: gm to mg
Option 2: mg to gm
Question 8. [15]
Design a class to overload the function named perimeter( ) to compute the perimeter of the given
geometrical shapes.
void perimeter(int, int) - will compute and print the perimeter of a rectangle
void perimeter(int, int, int) - will compute and print the perimeter of a triangle
------x-----
-6-