Selection Question 2024
Selection Question 2024
Computer Applications
Maximum marks:100
Time 2 hrs
Preboard Examination 2024
Class X
Question 1
[1*20=20]
i)Wrapper classes are available in __________ package.
a)java.io b)java.util c)java.lang d)java.awt
ii)Inheritance is the basic principle on which we can create new classes from
existing classes by inheriting some of the properties.It is based on the concept of
1
a)data hiding b)reusability c)function overloading d)modularity
2
a)Integer.toString() b)Long.parseLong() c)Integer.parseInt() d)Float.toString()
xiii)Which of the following declaration and initialization in the line given below
is equivalent to
String str=new String();
a)String str= “ ”; b)String str= “0”;c)String str=null;d)String str= “\0”;
3
a)false b)0 c)False d)true
xviii)Assertion(A):The base class and derived class are the terms used in
abstraction.
Reason(R ):The concept of extending a class to obtain another class is called
inheritance.
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 is false and Reason (R) is true.
xix)Give the output and mention how many time the loop will be executed ?
int a,b;
for(a=6,b=4;a<=24;a=a+b)
{
if(a%b==0)
break;
}
System.out.println(a);
a)12,2 b)12,3 c)10,1 d)10,2
xx)Robin wants the members of his class Employee to be accessible only to his
class “Employee”,what access specifier he should use for the members?
a)Public b)Private c)Protected d)default
Question 2
[2*10=20]
i)Rewrite the following using if else statement:
int m=400;
4
double ch=(m>300)?(m/10.0)*2 : (m/20.0)-2;
iii)Identify the errors giving reason and correct the Java statements.
iv)
Write the Java expression.
| |
√
v)
How many times the following loop will execute? Write the output of the code:
char m[]={‘C’, ‘O’, ‘M’, ‘P’, ‘U’, ‘T’, ‘E’, ‘R’};
for (int i=0, j=7;i<4;i++,j--)
{
System.out.println(m[i]+m[j]);
}
vi)
Write the out put of the following String methods:
String a[]={“PHYSICS”, “ENGLISH”, “MATHEMATICS”, “CHEMISTRY”,
“BIOLOGY”};
5
Give the output:
a)System.out.println(a[0].length()==a[4].length());
b)System.out.println(a[1].compareTo(a[3]));
vii)
Predict the output of the following code snippet:
String a[]={“325”, “135”, “345”, “555”};
for(int i=0;i<4;i++)
{int x =Integer.valueOf(a[i]);
if(x%3!=0&&x%5==0)
System.out.println(x);
}
viii)
The following code to compare two strings is compiled,the following syntax
error was displayed “incompatible types-int cannot be converted to
boolean”,Identify the statement which has the error and write the correct
statement.Give the output of the program segment after correcting.
void calculate()
{
String a= “KING”,b= “KINGDOM”;
boolean x=a.compareTo(b);
System.out.println(x);
}
ix)
Create the default and parameterised constructor for the given class definition.
class abc
{
6
double d;
char c;
boolean b;
}
x)
State the output:
int x[]={1,2,3,4,5,6,7,8};
System.out.println(x[3]*2);
System.out.println(x[5]+4);
System.out.println(x[6+1]*2);
Question 3
[15]
Design a class CONVERT that is described as follows:
datamember:
float centigrade;
default constructor:To initialize centigrade to its default value.
parameterised constructor:To assign the temperature in centrigrade scale to its
data member.
7
method:
CentiToFaren():To compute the farenheit equivalent of the centigrade
temperature and return its result.
main() :to compute farenheit equivalents of centrigrade temperatures from 10 °C
to 100°C in steps of 5°C.
Question 4
[15]
Write a program to initialize two arrays with name of country and its currency
given below.Sort array B in ascending order using bubble sort and sort A
accordingly.
Input:
A[]:The list of countries B[]:The list of currencies
Afghanistan Afghani
Albania Lek
Algeria Dinar
Andorra Euro
Angola New Kwanza
Antigua and Barbuda East Caribbean dollar
Argentina Peso
Australia Australian dollar
Output:
A: array with respect to sorted array B
Afghanistan Afghani
Algeria Dinar
Andorra Euro
Albania Lek
8
Angola New Kwanza
Argentina Peso
Question 5
[15]
Special words are the words which starts and ends with the same letter.
Examples
Existence
Comic
window
Palindrome words are those words which read the same from left to right and
vice-versa.Examples:-MALAYALAM
MADAM
LEVEL
ROTATOR
CIVIC
All palindrome words are special words but all special words are not
pallindrome.Write a program to accept a word ,check and print whether the
word is a palindrome or only special word.
Question 6
[15]
Write a program to accept the year of birth of students as integer value from the
user. Using binary search technique on the sorted array of integers given below,
output the message "Record exists" if the value of the input is located in the
array.If not output the message "Record does not exist"
The given array is {1982,1985,1988,1999,2001,2005,2015}
Question 7
9
[15]
Print the following patterns using a menu driven class.
i) ESCIICSE ii) *
ESCCSE ***
ESSE *****
EE *******
*********
Question 8
[15]
Define a class to declare a character array of size ten, accept the characters into
the array, sort the array using selection sort and display the sorted array, the
character with highest and lowest ASCII value.
Example:
Input : ‘r’, ‘z’, ‘P’ , ‘a’ , ‘n’, ‘p’, ‘m’, ‘U’, ‘Q’, ‘F’.
Output:FPQUamnprz.
Highest: z
Lowest: F
******************xxxxxxxxxxxxxxxxxxxxxxxxxxxxx***********
10