[go: up one dir, main page]

0% found this document useful (0 votes)
223 views9 pages

Pre 10

Download as docx, pdf, or txt
Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1/ 9

SNV INTERNATIONAL SCHOOL – BHUMEL

Pre Board Examination


Class-X Date- 29/12/23
Marks 100 Subject-Computer Time : 2 hours
_____________________________________________________________________________
Section A (40 Marks)
(Attempt all questions from this Section.)
Question 1 [20]

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.

(a) Data Abstraction (b) Encapsulation (c) Inheritance (d) Polymorphism


(ii) The method of Scanner class to accept a 64-bit floating point number is:
(a) nextInt() (b) nextLong() (c) nextFloat() (d) nextDouble()
(iii) Classes, interfaces, methods, packages and variables are together called:
(a) Keywords (b) Identifiers (c) User defined words (d) None of the these
(iv) The keyword that makes a variable constant is:
(a) int (b) switch (c) final (d) All of these
(v) A loop programmed within another loop is known as:
(a) Null loop (b) Nested loop (c) Void body loop (d) All of these
(vi) Identify the valid keyword:
(a) For (b) INTEGER (c) case (d) elseif
(vii) Predict the output:
System.out.println(‘B’ + 2);

(a) 100 (b) B2 (c) 1002 (d) 68


Page 1 of 9
(viii) The feature of OOP implemented by Method overloading is:

(a) Inheritance (b) Polymorphism (c) Encapsulation (d) Data abstraction


(ix) Identify the output of code:
int j = 5;
for(; j <= 8;)
{ System.out.print(j + “ # ”);
j++; }
(a) Syntax error (c) A=1 B = 2
(b) # 5 # 6 # 7 # 8 (d) A = 1 B = 1
(x) The function used to convert a String value to double data type is :
a. Double.toDouble() c. Double.parseDouble()
b. Double.toString() d. String.parseDouble()

(xi) What will be the data type of variable s in the following statement?

_______ s = “Major”. starts With(“M”);

(a) int (b) char (c) String (d) boolean


(xii) The number of bytes occupied by an array of double type
with 5 elements is:
(a) 10 (b) 20 (c) 40 (d)
50
(xiii) What value will be returned by compareTo( ) method if the invoking string is
smaller than the compared string?
a. A positive number c. The invoking string
b. A negative number d. Zero
(xiv) How many times will the following loop be executed and what will be the
output?
int i;
for ( i=5 ; i>10 ; i++ )
System.out.print(i);
System.out.println(i * 4);
a) 5 times, o/p 5678940 b) 0 times, o/p 20
Page 2 of 9
c) 1 time, o/p 524 d) 5 times, o/p 5678910

(xv) Assertion (A): To call abs() method no object or class name is required.

Reason (R): All methods of Math class are class methods.

(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

(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.

Selection statements are used to:

(a) Check conditions (b) take decision

(c) Select an alternative of many statements (d) All of these

(xvii) Assertion (A): An array variable is also known as subscripted variable.


Reason (R): In arrays, every element is represented with the help of its
individual index. (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 true and Reason (R) is false
(d) Assertion (A) is false and Reason (R) is true

Page 3 of 9
(xviii) The value of variable r in the following statement will be:
double r = Math.ceil (28.5);

(a) 28 (b) 28.0 (c) 29 (d) 29.0

(xix) The variable to access the 10th element of an array a[ ] is:

(a) a[9] (b) a[10] (c) a[11] (d) a[0]

(xx) boolean b[ ] = {true, false};

System.out.println (b[1] * 2);

What will be the output of the above code fragment ?


(a) 2 (b) 0 (c) true * false (d) Syntax error

Question 2 [10X2=20]
(i) Write a Java statement for the following mathematical expression:
a2 +b2 x (a+b)8
|a + b|

(ii) Evaluate the following expression when a = 4:

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

(iv) State the purpose of continue statement.

(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) How many times will the loop get executed ?

(b) What will be the output ?


(vii) int x [ ] = { 8 , 5 , 2 , 9 , 4};
int k = x.length;
int la=x[0],lo=x[0];
for( int j = 0;j < k ; j++)
{ if(la> x[ j ] )
la = x[ j ];
if(lo < x[ j ] )
lo = x[ j ];
} System.out.println(“ values are ” + la + ‘ ’ + ‘ ’+ lo);
(viii) State the output of following code:
String a =“Smartphone” , b=“Graphic Art”;
String h = a.substring(2,5);
String k = b.substring(8),toUpperCase( );
System.out.println(h);
System.out.println(k.equalsIgnoreCase(h));

(ix) Predict the output:

(a) “ARTIFICIAL”.endsWith(“AL”);
(b) “Java_Basics”.trim().length();

(x) int a [ ]={ 1, 5, 6, 8, 5 };

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) What will be the size of the array c ?


(b) Find the output: System.out.println(Math.pow(c[6], c[0]));

Section B (60 Marks)


(Answer any four questions from this Section.)
The answers in this section should consist of the programs in either
BlueJ environment or any program 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 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:

Class name : Library

Member variables / Data members:

bname - to store the name of the book issued.

days - to store the number of days taken to return the book.

extra - to store the extra days after the specified days.

fine_amount - to store the amount to be paid as fine.

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]

void show() : To print the following pattern using nested loop.


12345
2345
345
45
5
Page 7 of 9
void show(int r) : – to accept a two digit number and check whether it is special 2 digit
number or not. A special two digit number is such that when the sum of its digits is added to
the product of its digits the result is a equal to the original two digit number. Example:
consider the number 59. Sum of digits = 5 + 9 = 14 and Product of its
digits = 5 x 9 = 45
Sum of the sum of digits and product of digits = 14 + 45 =59
Question 7
An array is referred to as a ‘Special array’ if it has equal number of 0s and 1s in it. Write
a program to accept some positive integers in a DDA (double dimensional array) of size
4x4 and check whether it is a special array or not. Display an error message if the array
does not contain any ‘zero’ and ‘one’.
[15]
Example:
n[ ][ ] = { { 1,3,1,0 }, { 2,4,5,6 }, { 2,0,8,0 }, { 1,7,5,9 } } ;

Total number of 0s = 3

Total number of 1s = 3

Hence, the array n[ ][ ] is a Special array.

Question 8

An ‘EMRIP’ number is a natural number that must satisfy the criteria as follows:
[15]

(i) It is a prime number


(ii) Its reversal is a prime number

(iii) It is not a Palindrome number

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

• Its reversal (31) is a Prime number


Page 8 of 9
• It’s not equal to its reversal i.e. it’s not a Palindrome number

Therefore, 13 is an EMRIP number.

Page 9 of 9

You might also like