0% found this document useful (0 votes)
62 views4 pages

SXCS Computer Applications 2024 Rehearsals

Uploaded by

swarnima0310
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
62 views4 pages

SXCS Computer Applications 2024 Rehearsals

Uploaded by

swarnima0310
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

ST.

XAVIER'S COLLEGIATE SCHOOL, 30 MOTHER TERESA SARANI, KOLKATA-16


Class:X SECOND SEMESTER BLOCK TEST Date: 11/12/2024
Duration: Two hours COMPUTER APPLICATIONS FullMarks: 100
Section A
Answer all questions
Question 1
Choose the correct answers to the questions from the given options [20]
i)

Name the feature of java depicted in the above picture.


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

i) Parameters which receive the values from the calling method are termed as parameters.
(a) actual (b) formal (c) reference (d)class

ii) Ternary operator is a:


(a) logical operator (b) arithmetic operator (c) relational operator (d) conditional operator

iv) The method to convert a String to double is:


(a) String. toDouble() (b) Double. Parsedouble()
(c) Double. parseDouble(String) (d) Double.parseDouble( )

v) When String m is compared to n, the resuit obtained is greater than zero. Which of the following is true?
(a) m comes before n in the dictionary. (b) n comes before m in the dictionary.
(c) m and n are equal. (d)m and n have the same length.

vi) Arrange the following in the descending order of number of bytes occupied.
I. char x[20]
II. int af4](2]
III. double b[6}
(a) II, II, I (b) II, I, I (c) II, III, I (d) I, I, III

vii) Which of the following statement is an example for explicit typecasting?


(a) int amount 45; (b) int amount = 24*24;;
(c) int amount Integer.parselnt (“45*); (d) int amounttin)4s.75):

viiWhich of the following statements are valid for static membe methods of a class?
as
I. They can access static as well non-static data members
N, They can call non-static megber methods.
II\An object is required to invoNe the methods.
(a) Iand I (b) II and III (c) I and I (a) Only
Nane the vevidle
I het u
4 olass
ix)What is the outcome of the following code snippet:
public class Test

public static void main( ) a inbsane

char ( 1] matrix ={{'a', b','c'},('p''q',r}, {'x,y,z} };


for( int i=0; iK3; it+)
System.out.print( matrix[i] [1] +"");

(a) a bc (b) a p x (c) pqr (d) bqy

x) Which of the following is NOT true for polymorphism?


(a) All methods have the samne name.
(b)Methods are invoked based on the argumnents.
have
the same number and the same type of arguments.
(c) Methods should OOPs.
(d) It is a principle of

xi) Name the package that contains wrapper classes:


(a) java.lang (b) java.util (c) java .io (d) java.awt

xi) Invoking a method by passing the array is termed as


a)Call by value b) Call by reference c) Call by method d) Call by function

xiii) A function that changes or modifies the state


of received argument.
a) Pure function b) Function overloading c) Impure function d) Local function

xiv) Which access specifier allows accessibility by all classes in the same package, but only by subclasses in a
different package?
(a) public (b) private (c) protected (d) default

xv) Which of the following String methods has integer argument?


I. length II. substring II. indexOf IV. charAt
(a) Only II (b) I and IV (c) IIand IV (d) Iand III

xvi)Which of the following keyword is used to create an instance of a class?


(a) new (b) public (c) class (d) None of the above

xvii) Which of the following is a valid statement to print the following sentence:
Raj said “Good morning"
(a) System. out. printin("Raj said “Good morning");
(b) System. out. println("Raj said \Good morningl);
(c) System. out. printin("Raj said \"Good morning|" ");
(d) System. out. printin("Raj said Good morning");

xviii) Assertion:A class can have multiple constructors


Reason: Multiple constructors are defined with same set of arguments.
(a) Assertion is true, Reason is false.
(b) Both assertion and Reason are false.
(c) Both assertion and Reason are true.
(d) Assertion is false, Reason is true.

xix) Assertion: The switch..case statement must have a default case.


Reason: The default case is executed when no case matches the value of the variable.
(a) Assertion is true, Reason is false.
(b) Both assertion and Reason are false.
(c) Both assertion and Reason are true.
(d) Assertion is alse, Reason is true.

Xx) Give the output:


System.out.printin(“but".compareTo("butter");
(a) O (b) -3 (c) 3 (d) 6

Question 2
i)) Convert the following while loop to the corresponding for loop: {2]

int m =5, n= 10;


while (n>=1)

System.out.println(m*n);
n--;

[2]
i) What will be the output of the following code?
int m=2; int n=15;
for(int i= 1; i<5; it+);
mt+; --n;
System.out.println("m=" +m):
System.out.printIn(“n= n);
ii) Consider the following code and answer the questions that follow:
(2]
class academic

int x,y;
void access()

int a,b;
academic student-new acadenic();
System.out.printin(Object Created");
}}
a. Name the instance variables used in the class.
b. Write the name of local variables used in the program.

iv) Write the prototype of a function which takes in 2 integers and 1


String arguments and returns a value (2]
which is either true or false.

v) Correct the error(s), if any, in the following program. [2]


class First

public static void main(String args))

int i;
int a[6]-{0,1,8,7,6,4};
for(i-0;i<=a.length0;it+)
System.out.printin(a[i);
}}
vi)Predict the output (show working):
int i-5;
do
System.out.printIn(+-+it5);

}while(+-+i<ll);
System.out.println(i);

viil) Predict the output (show working): [2]


int p=1, i-2;
do

p*=i;
}while
(tti<s);
System.out.println(p);

vii) Using Java library functions, write statements with appropriate datatypes for the following: [2)
i) To extract “SP" from "MISSISSIPP!".
ii) Toremove all leading and trailing spaces froma string str.
ix) Replace the following set of if-else statements with switch-case statements: {2]
void work(char code)

if(code-=A')
System.out.println(“Well Done");
else if(code-=
B
|| code== 'C)
System.out.println(“Satisfactory");
else if(code= D'
jlcode-= *E')
System.out.println(More effort required"):

the expression mon when m=-14 and n=-3? [2]


If and n are int type variables, what will be the result
m of
x)
SECTION B
(Answer any four questions from this Section.)
Each program should be written using variable description / mnemonic codes so that the logic
of the
program is clearly depicted.
Question 3 [15!
Detine aclass called Mobike with the following description:
instance variables/ Data members:
bno : to store the bike's number
phno : to store the phone number of the customer
name: to store the name of the customer
days : to store the number of days the bike is taken on rent
charge : to calculate and store the rental charge
Member methods:
void input () :to input and store the details of the customer
void compute () : to compute the rental charge. The rent for a Mobike is charged on the following basis
First five days : Rs.500 per day
Next five days: Rs.400 per day
Rest of the days: Rs.200 per day
void display () :to display the details in the following format:
Bike No. Phone No. Name No. of days Charge

Question 4 [15]
Write a program to input 10 numbers into an integer array and store only the numbers occurring once into another
array and display it.
For example, if the given array contains 99, 12, 34, 7, 99, 36, 12, l6, 14, 123
The resultant array should be: 34, 7, 36, 16, 14, 123

Question5 [15]
Design a program to check the strength of a password. A strong password should satisfy the following conditions:
-length of the password should be at least 12 characters
shoulda at least have 4 upper case letters, 4 lower case letters, 2 digits, 2 special characters
Define class to accept the password and check and print whether the password is strong or not.

Question 6 [1S]
Define a class to overload the method that performs as follows
:

void perform(int x]) - to display the largest element of the array.


Example: (4, 5, 16, 6, 12, 9}
Largest: 16
void perform (String s, char ch)
If ch is F print the first S characters, if ch is 'L print the last Scharacters
Example: s= “CARPENTER"
ch = F
Output: CARPE
ch =L
Output: ENTER
void perform(int n) : to print the Product of the first and last digits of the number
Example: if n = 45326
Output: 4x6-24

Question 7
Define a class to accept values into a 3x3 array and check and print if it is a special array or not. An array
is a special array if the sum of the even elements = sum of the odd elements.
Example: AJ0-{{4,5, 6}, { 5,3, 2}, {4, 2, 5}};
Sum of even elements = 4+6+2-+4+2 =18
Sun of odd elements= 5+5+3+5=18

Question 8 [15)
Input an integer and form a new number by removing allodd digits fron it. Print the new number.
For example,
Input: 123456
Output: 246

You might also like