Pre 10
Pre 10
Pre 10
Choose the correct answers to the questions from the given options. (Do not copy the
question, Write the correct answer only.)
(i) Name the feature of Java depicted in the following picture.
(xi) What will be the data type of variable s in the following statement?
(xv) Assertion (A): To call abs() method no object or class name is required.
(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
(xvi) Go through the following text and choose the correct answer:
Selection statements help in selecting one alternative out of more than one option.
They are also called decision-making statements as the computer needs to take a
decision while executing these statements as per the conditions provided. The
output of the program depends upon the statement selected by the computer based
on the validity of the condition.
Page 3 of 9
(xviii) The value of variable r in the following statement will be:
double r = Math.ceil (28.5);
Question 2 [10X2=20]
(i) Write a Java statement for the following mathematical expression:
a2 +b2 x (a+b)8
|a + b|
a = – –a + a++ * a– – ;
(iii) Identify the syntax error in the following code fragment and rewrite its rectified
form:
for(int i=2; i++;)
{
System.out.println(i);
(v) Write down the return data type of nextLong() and Math.random() methods.
(vi) Study the following iterative structure and answer the questions with working:
int k = 3;
while(++k<=10)
Page 4 of 9
{
if((k+5) % 5==0)
break;
System.out.println(k+5);
(a) “ARTIFICIAL”.endsWith(“AL”);
(b) “Java_Basics”.trim().length();
int b[ ]={ 0, 3, 7, 3 };
Place all the elements of array b and a in another array c one after the other and
Page 5 of 9
answer the questions:
A public library issues books, which a student can use for 7 days without any fine, while
returning the book a fine will be charged only for excess days, if returned after specified
days. Design a class Library with the following specifications:
Member methods:
void input() - to input the name of the book and the number of days taken to return the
book.
void computeFine() - to compute the extra days taken to return the book and calculate
the fine amount only for extra days as per the given slabs:
Page 6 of 9
Extra days Charge per day(in rupees)
Up to 5 days 5
6 to 15 days 10
Above 15 days 20
void display() - to display the name of the book, extra days taken to return and the
fine amount.
Now define a main() method to create an object and invoke the above member methods
for obtaining the desired output.
Question 4
Write a program to accept a word and convert its all characters into lower case form. Now
count and display the total number of consonants in it.
[15]
Question 5
Write a program to accept some integers in an array of size 15. Now arrange those
elements in descending order using the technique of Bubble Sort. Display the sorted array
with a proper message.
[15]
Question 6
Design a class to overload a method show() as follows:
[15]
Total number of 0s = 3
Total number of 1s = 3
Question 8
An ‘EMRIP’ number is a natural number that must satisfy the criteria as follows:
[15]
Write a program to accept a natural number from the user and check if it is an
EMRIP number or not. Example:
Input number: 13
• It is a Prime number
Page 9 of 9