Std. 10 - Computer Applications
Std. 10 - Computer Applications
Page 1 of 6
case 9 : System.out.println( “ Excellent”); break;
case 10: System.out.println( “ Outstanding”); break;
default: System.out.println( “ Fail”); break;
}
(a) Pass (b) Excellent
(c) Outstanding (d) Fail
(ix) A girl wanted to calculate the sum of two numbers stored as a and b multiplied by 7. Select the
appropriate java expression.
(a) a+ b*7 (b) 7*a+b
(c) (a+b)*7 (d) a+7*b
(x) What is the output of the following program code?
int i=70;
for( ;i>60; )
{
System.out.print(“ ”+i);
i--;
}
(a) Run time error (b) Compile time error
(c) 70 69 68 67 66 65 64 63 62 61 (d) 70 69 68 67 66 65 64 63 62
(xi) Sam performs bubble sort on the following array to organize the elements in ascending order.
int a[]={5,1,2,3};
After the first comparison the array is {1,5,2,3}
What would be the array after the next comparison?
(a) {1,2,5,3} (b) {1,5,3,2}
(c) {1,3,5,2} (d) {1,3,2,5}
(xii) Method prototype for the method max which accepts a double argument and an integer
argument and has a double return type is
(a) double max(double a, int b) (b) Double max(int a, double b)
(c) void max(int a, double b) (d) void max(int a, double b)
(xiii) What will be the output of the following java statement?
System.out.println(“Baby”.compareTo(“Bad”));
(a) false (b) -1
(c) 2 (d) -2
(xiv) A single dimensional array contains N elements. What will be the last subscript?
(a) N+1 (b) N
(c) N-1 (d) N+2
(xv) The______ keyword that signifies that the function does not return a value.
(a) void (b) Null
(c) empty (d) blank
(xvi) Assertion(A): Java statements written in lowercase or uppercase letters are treated as the same.
Reason: (R) Java is case sensitive language.
Based on the above discussion choose an appropriate statement for the options given below.
(a) Both Assertion (A) and Reason (R) are true and reason R is the correct explanation of Assertion (A)
(b) Both Assertion(A) and Reason(R) are true, and Reason(R) is not the correct explanation of Assertion(A)
(c) Assertion (A) is true and Reason R is false.
(d) Assertion (A) is false, and Reason R is true.
(xvii) Akash wants the members of his class Employee to be accessible only to his class “Employee”.
What access specifier he should use for the members
(a) private (b) protected
(c) public (d) default
Page 2 of 6
(xviii) What will be the output of the following?
System.out.println(“SUNDAY”.substring(3));
(a) NDA (b) DAY
(c) SUN (d)N
(xix) If the name of the class is “Green” , what can be the possible name for the constructor?
(a) green (b) Green
(c) GrEEN (d) gReen
(xx) Assertion(A): Character.isLetter() function is used to check whether a given argument is a letter
or not.
Reason: (R): It always returns a boolean type value, either true or false.
Based on the above discussion choose an appropriate statement for the options given below.
(a) Both Assertion (A) and Reason (R) are true and reason R is the correct explanation of Assertion (A)
(b) Both Assertion(A) and Reason(R) are true, and Reason(R) is not the correct explanation of
Assertion(A)
(c) Assertion (A) is true and Reason R is false.
(d) Assertion (A) is false, and Reason R is true.
Question 2 [2x10]
(i) Rewrite the following program statement using logical operators:
if(x>5)
if(x>y)
System.out.println(x+y);
(ii) Evaluate the expression:
x+=x++ + ++x + --x +x; when x=7;
(iii) Consider the following program statement and answer the question given.
for(int k=1;k<=5;k++)
System.out.println(k);
System.out.println(k);
Will the above program statements get executed successfully? If not, then identify the error and
correct the error.
(iv) Write the java expression for | x 2 +2xy|
(v) The output of a program which executes a part of string “COMPASSION” is as
(a) “PASS” (b) “PASSION”
Write appropriate Java statements to get the above output.
(vi) Write the return datatype returned by the library function
(a) indexOf() (b) charAt()
Page 3 of 6
}
(ix) Consider the following class:
public class myClass
{
static int x=3,y=4;
int a=2,b=3;
}
(a) Name the variables for which each object of the class will have its own distinct copy.
(b) Name the variables that are common to all the objects of the class.
(x) Give the output of the following
int a, b=0;
int c[]={1,2,3,4,5,6,7,8,9,10};
for(a=0;a<10;a++)
{
if(a%2==0)
b+=c[a];
}
System.out.print(b);
Question3 [15]
Define a class named BookFair with the following description:
Instance variables/Data members:
String Bname — stores the name of the book
double price — stores the price of the book
double disc— stores the discount
double amt— stores the price of the book after discount
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.
Question 4 [15]
Define a class to search for a value input by the user from the list of values given below. If it is found then
display the element along with its position, otherwise display the message “Search element not found” using
Binary search technique.
Page 4 of 6
15, 21, 28, 35, 53, 62, 76, 88, 90, 98
Question 5 [15]
Write a program to input a string in uppercase and print the frequency of each character in the string.
Sample Input: COMPUTER HARDWARE
Sample Output
CharacterFrequency
A 2
C 1
D 1
E 2
H 1
M 1
O 1
P 1
R 3
T 1
U 1
W 1
Question 6 [15]
Define a class to accept values into a 4x4 arrayandcalculate and print the sum of each column. Also print
the array in matrix form.
Example:
A[][]={{1,2,3,4},{5,6,7,8},{9,10,11,12},{13,14,15,16}}
Output:
Sum column 1=1+5+9+13=28
Sum column 2=2+6+10+14=32
Sum column 3=3+7+11+15=36
Sum column 4=4+8+12+16=40
1 2 3 4
5 6 7 8
9 10 11 12
13 14 1516
Question 7 [15]
Define a class to accept a number and check whether it is a SuperSpy number or not. A number is called
SuperSpy if the sum of the digits is equal to the number of digits.
Example:
Input: 1021
Output: SuperSpy number [Sum of the digits=1+0+2+1=4, Number of digits=4]
Question 8 [15]
Define a class to overload a function print() as follows:
void print(): To display the following format using nested loop
99999
77777
55555
33333
11111
void print(intnum, char ch) with one integer argument and one character argument, computes and prints the
square of integer argument if choice ch is ‘s’ otherwise find its cube.
Page 5 of 6
***************All the best ***************
Page 6 of 6