Computer Applications
Computer Applications
Std. X Date : 13/10/2023 Sub : Computer Applications Time : 2 hours Marks : 100
Answer to this paper must be written on the paper provided separately.
You will NOT be allowed to write during the first 10 minutes.
This time is to be spent in reading the question paper.
The time given at the head of this paper is the time allowed for writing the answer.
Attempt all questions from Section A and any four questions from Section B.
The intended marks for questions or parts of questions, are given in brackets [ ]
SECTION A
(Attempt all questions from this Section.)
Question 1
Choose the correct answers to the questions from the given options.
(Do not copy the question, write the correct answers only.) [1x20=20]
1) Identify the OOP principle depicted in the below image
4) Which function returns a double object holding the value given by the specified string
a) ToString(double) b) valueOf(String)
c) parseDouble(String) d) None of the above
6) A constructor
a) is always public
b) never has the same name as class name
c) never returns a value
d) both a & c
9) Within a string x, and suffix , what is the way to call the endsWith() method?
a) endsWith(x, suffix) b) endsWith(suffix , x)
c) X. endsWith(suffix) d) None of these
10) In Java, how do you check if two strings have the same content?
a) Using == operator b) Using equals() method
c) Using compareTo() method d) Using equalsIgnoreCase() method
:3:
16) Out of the following option given which is the reference data type
a) Object b) Character c) String d) Float
Question 2 [2x10=20]
1) Give the output of the following code:
a) “Examination”. compareToIgnoreCase(“EXAMINATION”);
b) “Kaizad”.lastIndexOf(‘a’);
2) Write the output of the following code
String s= “Arnav Ashar”;
for(int i=0;s.charAt(i) !=’ ‘; i++)
System.out.println(s.charAt(i));
3) State two characteristics of a constructor
4) What is the output of the following Math functions:
a) Math.round(2.7);
b) Math. ceil(-3.4);
5) State the difference between entry control and exit control loops
6) If int n[] ={1,4,6,8.4,3,4,2,9.2}, what are the values of x and y?
a) x= Math.pow(n[2], n[6]);
b) y= Math.ceil(n[3] +n[7]);
7) Name any 2 wrapper classes.
8) Write a non-return type method prototype with the name Nikhilesh which accepts a boolean
and a character value.
9) Convert the following for loop into a while loop
for(int i=0, j=4;i<5;i++)
{ j+=i;
System.out.println(j);
}
10) Write a string function in Java checking two strings lexicographically and ignoring the case .
Contd..4
:4:
SECTION B
(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]
Define a class to accept 10 names of students in an array . Sort them alphabetically in
an ascending order using selection sort technique. Display the sorted array.
Question 4: [15]
Define a class to overload the method “pattern” as follows:
void pattern(): To print the following format using nested loop
5
54
543
5432
54321
void pattern(int n): To accept a 3 digit number and print the square of first digit
, to print the cube root of second digit and print the ASCII value of third digit
after add 64 to it
Example: n = 462
output – 4 =16
3√6 =1.817
2 +64 =66 = B
Question 5: [15]
Create 2 String 1D Arrays and combine the two array in the following format given in the
example below:
Example:Input
String Arr[]= {“ Two”, “seven”, “twenty”, “nine”};
int num[]={ 4,8,1,5};
Output: Two 4 , Seven 8, twenty 1, nine 5
Question 6: [15]
Create a Java program to check if the given number is a fascinating number or not.
Fascinating Number Example
Let's take any number (n) say 327 and check whether the given number is fascinating or not.
On multiplying the given number (n) by 2 and 3, we get:
327×2=654
327×3=981
Now, concatenate the above results to the given number (n).
"327"+"654"+ "981"= 327654981
We observe that the resultant () contains all the digits from 1 to 9, exactly once.
Hence, the given number 327 is a fascinating number.
Contd..5
:5:
Question 7: [15]
Define a class called with the following specifications:
Class name: NamanK
Member variables:
String name: name of the item purchased
double price: Price of the item purchased
Member methods:
void accept(): Accept the name and the price of the item using the methods of Scanner
class.
void calculate(): To calculate the net amount to be paid by a customer, based on the
following criteria:
Price Discount
void display(): To display the name of the item and the net amount to be paid.
Write the main method to create an object and call the above methods.
Question 8: [15]
Define a class to accept values into a 4x3 2D array and check if it is a special array.
An array is a special array if the sum of the even elements = sum of the odd elements.
Example:
A[][]={{ 4 ,5, 6}, { 5 ,3, 2}, { 4, 2, 5}, {6,2,9}};
Sum of even elements = 4+6+2+4+2+6+2 =26
Sum of odd elements= 5+5+3+5+9= 27
Not a Special array
*************