Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

X_comp_EVII_24_25

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 7

SNV International School, Nadiad

Class: X Evaluation II Date: 11 /09/24


Max Marks: 100 Subject: Computer application Time: 2 hours
Section I (Theory- 20 marks)
Question 1.
Choose the correct answers to the questions from the given options. [20X1=20]
(i) Name the feature of Java that is depicted in the following picture.

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


(ii) What will be the output of Math.abs(Math.floor(-10.23))
(a)10.0 (b)11 (c) -11.0 (d) 11.0
(iii) Which of the following expressions is illegal?
(a) true && false (b) int j = 5 > 0 (c) char s = ‘\0’; (d) All of these
(iv) Which operator among the following is binary in nature ?
(a) %= (b) ++ (c) ?: (d) !
(v) Which among the following is a non-primitive data type ?
(a) int (b) short (c) Math (d) long
(vi) The return data type of trim() method of String class is:
(a) int (b) boolean (c) char (d) String
(vii) What will be the result produced by the following statement?
Math.round(8.4) + Math.abs(-5);
(a) 13.0 (b) 13 (c) 3 (d) 3.0
(viii) A valid function name is:
(a) function() (b) 3method() (c) function@() (d) None of these

(ix) Name the package that contains the ‘String’ class.


(a) java.lang (b) java.awt (c) java.io (d) java.util
SNV/24-25/EVII/COMP/TT

Page 1 of 7
(x) Which of the following is an invalid literal?
1. “899” 2. 24D 3. ‘CHALK’ 4. ‘\u0000’
(a) 1 and 2 (b) Only 2 (c) Only 3 (d) 3 and 4
(xi) Which among the following is not a component of a method?
(a) Method name (b) Data members (c) return statement (d) Parameters
(xii) Once a function is defined, it can be invoked repeatedly. What is this feature
called?
(a) Reusability (b) Restructuring (c) Interface (d) All of
these
(xiii) Which of the following is not a jump statement?
(a) return (b) continue (c) break (d) None of these
(xiv) Predict the output:
System.out.println("MS EXCELSPREADSHEET".substring(3,8).toLowerCase());
(a) ms (b) excel (c) ms excel (d) sheet

(xv) Assertion (A): No side effect occurs in pure function.


Reason (R): In pure function, attributes of the passed objects remain unchanged.
(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) Identify the operator that gets the lowest precedence among the following:
?: , * , ==, =
(a) = (b) * (c) ?: (d) ==
(xvii) Assertion (A): We always specify the class-name as the return type of a function.
Reason (R): A function can return an object as well.
(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
Page 2 of 7
(d) Assertion (A) is false and Reason (R) is true
(xviii) The first line of the method definition is termed as:
(a) Method prototype (b) Method signature (c) None of these (d) Both a and b
(xix) String s = “@snvinternational”; then s.lastIndexOf(‘P’) results in:

(a) 20 (b) 21 (c) -1 (d) Syntax error


(xx) public int change (int x, int y)
{
System.out.println(x+y);
return(x+y);
}
The above method is a _____ method.
(a) Impure (b) Pure (c) Simple (d) static
Question 2. [10X2=20]
i. What is the data type returned by the following library functions?
a. compareTo() b. equals()
ii. Write a statement each to perform the following task on a string:
a. Extract the second last character of a word in the variable text.
b. Check if the second character of the string str is in uppercase or not.
iii. State two features of the constructors in java.
iv. Give the output of the following.
System.out.println(“PANDEMIC.toLowerCase());
System.out.println(“TRANSPLANT”.compareTo(“TRANSITION “));
v. What are the final values stored in x and y below?
double x=Math.abs(Math.min(-2.53,-5.75));
double y=Math.sqrt(Math.floor(16.2));
vi. Evaluate the given expression when the value of a=4 and b=8
b*=a++ - - - a+ b- -
vii. Write a java expression for the given mathematical expression.
3
A+0.5B
viii. Rewrite the following code segment using while loop:
int f = 5;
for (int c = 40; c>=20; c –=3)

Page 3 of 7
{
System.out.println(c*f);
f = f + 2;
}
ix. Analyze the following iterative structure and answer the questions with working:
int a = 10, b = 20;
while(++a<=20 || ++b<=30)
{
if(a%7==0 && b%8==0)
break;
System.out.println(a + " " + b);
}
(a) How many times will the loop get executed ?
(b) What will be the output ?
x. State the output of the following code if the input value of x is (i) 10 (ii)11
if(x++==11)
System.out.println(“Result is 11”);
else if(++x==10)
System.out.println(“Result is 10”);
else if(--x==10)
System.out.println(“Result is 10”);
else
System.out.println(“Result is neither 10 nor 11”);

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
Design a class ‘Bill_Generation’ according to the following specifications: [15]
Class name : Bill_Generation
Member variables / Data members:
long cnum - to store the consumer number
Page 4 of 7
long pno - to store the contact number of the consumer
int unit - to store number of units consumed
double amount - to store the amount to be paid as bill by the consumer
Member methods:
void accept() - to input the consumer number, consumer contact number and
number of units consumed
void calculate() - to compute the amount to be paid as bill as per the given slabs:
Units consumed Charge per unit(in Rupees)
Up to 100 5.5
Next 200 6.5
Next 400 7.5
Above 700 9.5
void show() - to display the consumer number, contact number, number of units
consumed and the amount to be paid as bill
Now define a main() method to create an object and invoke the above member
methods for obtaining the desired output.

Question 4 [15]
Define a class to accept a string in uppercase. Now create and display a new string
by replacing each vowel by the immediate next letter and every consonant by the
immediate previous letter while the other characters remain the same.
Example:
Input: ROYAL@ATS21
Output: QPXBK@BSR21

Question 5 [15]
Write a program to overload a method NewString( ) as follows :
(i) void NewString( String s1, char ch1, char ch2) with one string argument and two-
character arguments, it replaces the character argument ch1 with the character
argument ch2 of the string s1 and prints the new string.
Example
Sample Input : Input value string s1 as : “PROGRAM”
Input ch1 as : ‘R’
Input ch2 as : ‘S’
Sample Output : PSOGSAM

Page 5 of 7
(ii) void NewString(String s2) with one string argument, method prints the position of
the first space and the position of last space of the given string s2
Sample Input :
Enter the string as: “Artificial Intelligence is everywhere”
Sample Output :
First space : 10
Last Space : 27
(iii) void NewString(String s1, String s2) : To verify and display whether the two
strings
given as arguments are identical or not.

Question 6
Write a program to generate the following patterns [15]

a) C * * * * *
CL # # # #
CLA ***
CLAS # #
CLASS *

Question 7 Define a class to overload a function sum() as follows: [15]


I. int sum(int a, int b): With two integer variables (a and b)calculate and return
the sum of all the even numbers in the range between a and b.
Sample input: a=2 and b=12
Output: sum=2+4+6+8+10+12=42
II. double sum(double n): With one double argument calculate and return the
product of the following series: sum=1.0*2.0*3.0*4.0*..........*n
III. int sum(int n): With one integer as an argument and return the product of only
the odd digits in the number. Sample input: n=32541
Output: product=3*5*1=15
Question 8 [15]
A number is termed as Jupiter number if it is perfectly divisible by the sum of its
first and last digits. Now design a class to accept a number, verify whether it is a
Jupiter number or not and display the result accordingly with an appropriate
message. Example:
Suppose, a number n = 126
Sum of first digit and last digit = 1 + 6 = 7

Page 6 of 7
The original number 126 is completely divisible by 7. So, 126 is a Jupiter number.

Page 7 of 7

You might also like