CLASS 10 EXAM
F.M 20 + 15 + 45 = 75
QUESTION 1 (10 x 2 = 20 )
1. int a=5,b=11; (a) What is the size of the array?
while(a++<=--b) (b) What is the position of 89?
System.out.print(a+"*"+b+"*");
8. Give the output of the following:
2. String p="Microsoft", q="Micro"; System.out.println (q. String n = "Computer Knowledge";
compareTo (p)); String m = "Computer Applications";
System.out.println(n.substring(0,8).concat(m.substring(9)));
3. A student is trying to convert the given string to a numerical System.out.println(n.endsWith("e"));
value, but gets an error in the following code. Name the error
(syntax/logical/runtime). Give the reason for the error. 9. With reference to the program code given below, answer the
String s="356.A8"; questions that follow:
double p-Double.parseDouble(s); void fun(int n)
char ch-s.charAt(4); {
System.out.println(p+ch); int i,f,n;
for( i=1,f=1;i<=n;i++,f*=i);
4. A student when executes the following code, gets the output System.out.print(f);
as 0 1, whereas, he desires to get the output as 0 1 4 9. }
Identify the statement which has an error, correct the same to What is the output of the method fun() when the value of n=4?
get the desired output
void main() { 10. What will be the output of the following Java program?
int sum=0;
for(int i=1;i<=5;i++) { class A
if(i%2==0) {
break; int i;
System.out.print(sum+"\t"); void display()
sum=sum+i; {
} System.out.println(i);
System.out.print(sum); }
} }
5. int x=1, i=2; class B extends A
do {
{ int j;
x*=i++; void display()
}while(++i<=5); {
System.out.println(x); System.out.println(j);
}
6. int a[]={5,1,15,20,25}; }
int i,j; int m; class inheritance_demo
i=++a[1]; {
j=a[2]++; public static void main(String args[])
m=a[i++]; {
System.out.print(i+“ ”+j+“ ”+m); B obj = new B();
} obj.i=1;
} obj.j=2;
obj.display();
7. Consider the following array and answer the questions given }
below: }
int x [ ] = (23, 45, 67, 12, 45, 89, 24, 12, 9, 7}
QUESTION 2 ( 1 x 15 = 15 )
1. What happens if two case values are identical in a switch statement?
a) Compilation error occurs b) Only the first case will execute c) Both cases will execute d) Default case is executed
2. Which keyword is used to define a constant value in Java?
a) const b) final c) static d) constant
3. Which one of the following is not a character set used in Java :-
a) Letters b) Digits c) Operator d) Separators
4. Which one of the following is not a binary operator?
a. and b. % c. && d.!
5. An element of java program that is used to identify a class, function or value is called as............
a. identifier b. Literal c. Operator d. Static
6. Name a function applied for checking whether a token obtained from a scanner object is a Boolean type or not
a. hasnextBoolean() b) nextBoolean() c) Boolean() d) none
7. Which of these keywords is used to refer to member of base class from a subclass?
a) super b) supper c) this d) none of the mentioned
8. What is a Singleton class?
a. A Singleton class is such a class, whose just one and only one instance can be created.
b. A Singleton class is such a class, whose multiple instances can be created.
c. A Singleton class is such a class, whose instance can’t be created.
d. All of the above
9. An object is represented by two attributes, out of which one is characteristics and the other one is ___________.
a) Behaviour b) Situation c) Abstraction d) Encapsulation
10. Name the characteristics of Object-Oriented Programming that hides the complexity and provides a simple interface.
a) Encapsulation b) Polymorphism c) Abstraction d) Inheritance
11. Which among the following allows global accessibility?
a) public b) private c) protected d) All of these
12. Which operator is used to import all classes within a package?
a) * b) all c) + d) None of these
13. The _____ keyword refers to the current object.
a. this b. static c. const d. None
14. The constructor generated by the compiler is known as ______ constructor.
a. default b. copy c. parameterized d. non parameterized
15. a[16] is the ________element of the array declared as char a[20];
a. 16th b. 15th c. 17th d. none of the above
PROGRAM (ANY 2 ) 15 x 3 = 30
1. Write a program to accept the year of graduation from school as an integer value from the user. Using the Binary Search
technique on the sorted array of integers given below, output the message ‘Record exists’ if the value input is located in the array. If
not, output the message Record does not exist”.
(1982, 1987, 1993. 1996, 1999, 2003, 2006, 2007, 2009, 2010)
2. Define a class city and store the given city name in a single dimensional array. Sort these city names in alphabetical order using
bubble sort technique only, then print the sorted list.
Sample Input: Mumbai, Kolkata, Agra, Delhi, Bangalore
Sample Output: Agra, Bangalore, Delhi, Kolkata, Mumbai
3. Write a program that encodes a word into Piglatin. To translate word into Piglatin word, convert the word into uppercase and
then place the first vowel of the original word as the start of the new word along with the remaining alphabets. The alphabets
present before the vowel being shifted towards the end followed by “AY”.
Sample Input(1): London Sample Output(1): ONDONLAY
Sample Input(2): Olympics Sample Output(2): OLYMPICSAY
4. Write a program to accept a string. Convert the string to uppercase. Count and output the number of double letter sequences
that exist in the string.
Sample Input: “SHE WAS FEEDING THE LITTLE RABBIT WITH AN APPLE
Sample Output: 4