Model Test Paper 8 (Unsolved)
Maximum Marks: 100
Time allowed: Two hours
Answers to this Paper must be written on the paper provided separulely.
You will not be allowed to write during the first 15 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 answers.
This Paper is divided into two Sections.
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
20
Choose the correct answers and write the correct
option.
) How do you access the length of a String str?
(a) str.len (b) str.length (c) str. length () (d) str.size ()
(ii) What does the ++ operator do in Java'?
(a) Increments value by 1 (b) Decrements value by 1
(c) Inverts the value of a Boolean (d) Inverts the sign of an expression
(ii) In the case that a derived class exists, the property of OOP at work is:
(a) Polymorphism (b) Encapsulation (c) Inheritance (d) Modularity
(iv) Which type of cast is being shown below?
(typename) value
(a) Implicit cast (b) Explicit cast
(c) Simple cast (d) Complex cast
(v) What will be the output due to the below code snippet?
String str =
I am good'"
System.out.println (str.charAt (3) ) ;
(a) m (b) g (c) o (d) d
(vi) What is printed out from the below code?
String str =
Abhiram Kripal Singh"
System. out.println str. indexOf (Singh"))
(a) 14 (b) 15 (c) 16 (d) 17
(vii) Just-in-time is a kind of
(a) Software methodology (b) interpreter (c) compiler (d) type of Java IDE
(vii) What are the signs for bitwise NOT and logical NOT in Java?
(a),! (b) %, (c)!, (d) None of these
80 Goval's ICSF Coputer Applicatione Saooina as, . . n
á) Give the output of the following:
Math.sqrt (Math.min (18, 9))
(a) 2.0 (b) 3.0 (c) 4.0 (d) 5.0
()What docs the given array denoted?
String| ) names ew S t r i n g l 10];
slots
(a) An array is ereated with 10 slots (b) An array is crcated with 10 string
(c) This will ercate an error (d) None of these
is the return type of random() method.
(i)
(d) char
(a)int (b) double (c) boolecan
of the last space string str.
in a
(ni) Name a Java statement to find and display the position
(b) System.out.println(str.lastIndex(" *):
(a) System.out.println(lastlndexOf"str "): (d) System.out.println(str.lastlndexOf( *):
(c) Systenm.out.println(str.lastOf(" "):
(si) Give the output of the
following Java statement:
TRANSPARENT".compareTo("TRANSITION"):
(a) A positive integer greater than zero (b) A negative integer
(c) Zero (d) None of these
(xiv) A class is the:
Variables allocated to an object
(a) Memory allocated to an object (b)
(c) Methods allocated to an object
of a certain kind
methods to all objects
blueprint that defines the variables and the
common
(d) A
classes
(xv) Nanme the package that contains wrapper (d) java.wrap
(a) java.util (b) java.lang (c) java.io
(xvi) You cannot call this() from methods, only from:
(b) Classes
(a) Interfaces
(d) Constructors
(c) Main program
incorrect regarding constructors?
(xvii) Which of the following is
when the object of the class is created
invoked automatically
(a) It is a specific function which gets
does not return any value
(b) It is always of "void" type, i.e. it
be the same as the name of the class in which it is defined
of the constructor must
(c) The name
the definition for this
(d) It is necessary to write
definition. If you now initialize the first element of the array, it
as a part of class
(xvii) Suppose there is an array
will give error. Why?
cannot be initialized. They take default value.
(a) As array elements
Boolean values. You did not use Boolean.
(b) As array elements only take
initialized using new, before initializing subscripted variable.
(c) As aray has to be
(d) None of these
sort terminate in only one iteration?
(xix) In which case will the bubble
(a) If the array is already sorted the required way (b) If the array is sorted in the opposite way
i.e. all elements are the same
(c) If the array is constant,
(d) Both (a) and (c)
is the way to give the object its "black box" behavior.
(xx)
(a) Implementation hiding (b) Access control
(c) Access specifiers (d) Encapsulation
ad's1GSE Ceuer Applications Specimen Duesion Paper with MTP Class 10 81
Question 2
() Deseribe what the below two lines do, briefly. 121
BufferedReader bf new BufferedReader (new InputStreamReader (System. in) )
char str =
bf.readLine () .charAt (0);
char strl =
bf.readLine ().charAt (0);
(ii) What are the data types of the two variables with names x and y, in below couc
121
Integer x =
new
Integer (22)
int y 24;
(iii) Specify any three data types of the type of number in Java. 21
(iv) What is the wrapper class for the primitive data type of char? 12
(v) Specify a method that converts an integer i.e. int data type into its string equivalent. 121
(vi) Due to which of the below lines of the code will there be an error? How can you rectify the error?
Class Sorter {
12
// Line 1
int [] arr; // Line 2
int Cmp; // Line 3
public Sorter ( /7 Line 4
/ Line 5
f o r (int i = 0; i< 10; i++) 1/ Line 6
// Line 7
arr [il = 2*i; //Line 8
// Line 9
// Line 10
public static void main (String [ 1 args)// Line 11
// Line 12
Sorter = new sorter ()
// Line 13
(vii) If you do not use the new keyword to initialize it, what will the array type of variable hold when present as
a class member, as in the last question? 121
(vii) Assuming there are no zeroes in the array, what will the sign be of each element of the array y, after the
function executes? 21
void process (int[] x)
int [] y = new int[10];
for (int i = 0;i < x.length.;i++)
i f(x[il<0)
y[il x[il*x[il *x[i]
else
ylil -2*x[i];
(ix) In some programming languages, strings are treated as arrays, but not in Java. How can you access the last
character stored in a String data type? 2
(x) Write a Java expression for the following: 21
v3x +2
a+b
SECTIONB
this Section)
(Answer any four questions from
BlueJ environment or any
The answers in the section should consist proqrams in either
of the
program environment
with java as the base.
codes so that logic of the
tach program should be written using variable description/memonic
program is clearly depicted.
Flowcharts and algorithms are not required.
|15
Question3
numbers into the array.
out of the entered
reatc a of size 25. Sclect any number
single dimensional array
in descending order.
Find the rank of the selected number, when the data is sorted
[151
Question 4
the initials
Wite a program in Java to accept a name(Containing three words) and display only
(i.c.. first letter of cach word).
KA
Sample Input: LAL KRISHNA ADVANI Sample Output: L
|15
Question 5
Consider the following statement:
"January 26 is celebrated as the Republic day of India".
to August, Republic to Independence and finally print
Write program to change 26 to 15, January
a
day of India".
"August 15 is celebrated as the Independence
Question 6
[15
Convert it to uppercase. Count and output the number
of double letter
Write a program to accept a string.
words that exist in the string. For example:
"SHE WAS FEEDING THE LITTLE RABBIT WITH AN
APPLE"
Input:
Output: 4
Question 7 |15
the total number of characters and vowels present in
Write program to input any given string to calculate
a
the string and also reverse the string:
Example: INPUT Enter string: SNOWY
OUTPUT:
Total number of characters 05 Total number of vowels 01 Reverse string YWONS
Question 8 |15
Usingthe switch statement, write a menu-driven program to:
(a) Generate and display the first 10 terms of the Fibonacci series 0,1,1,2.3,5,..
(b) find the sum of the digits of an integer that is input. For example; 15390=18.
For an incorrect choice, appropriate error message should be displayed.