You are on page 1of 4

Model Test Paper 15 (Unsolved)

Maximum Marks: 1000


Time allowed: Tiwo hours
Answers to this Paper must be written
the paper provided separately
on

You will not be allowed to write during the first 15 minutes.


be spent in reading the question paper.
This time is to

The time given at the head of this Paper is the time allowed for writing the answers.

This Paper is divided into two Sections.


Aempt 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 [

SECTIONJA

(Attempt all questionsfrom this Section)


Question 1 201
Choose the correct answers and write the correct option.

)Based on the below line of code, what is stored in s?


String s =w + true;
(a) Nothing or null (b)
9
(c) Exception is thrown (d) "true
(ii) What change is made to the string s based on the below single line of code?
s.trim():
(a) The string is restored with all spaces inside it removed
(b) The string is restored with ali leading spaces removed
(c) The string is restored with all trailing spaces removed

(d) The string is restored with all leading and trailing spaces removed
is the maximum value of we can have for the call:
(ii) In the case of the string "Sayan", what x

Sayan". charAt (x)

4 (b) 5 (c) 6 (d) 7


(a)
class enables you to create string objects that can be changed in various ways, unlike the
(iv) The
String class, which represents string constants.
(a) Scanner (b) StringTokenize
(c) StringBuffer (d) String1loArray
(v) What is the ASCII value of the character 'C"?
(c) 67 (d) 97
(a) 65 (b) 66
(vi) Which of the following is a keyword in Java?
(c) String (d) Both (a) and (c)
(a) this (b) that
(vii) Each object (each instance of the class) has its own:
(c) super classes (d) instance variables
(a) Member methods (b) subclasses
109
CC
(vii) inheritance does not exist in Java. Thus, unlike Ct+, Java classes may only extend one class.
(a) Single (b) Cascading (c) Interrupted (d) Multiple
(ix) Expand JDK.
(a) Java Double Kit (b) Java Duplex Key
(c) Java Developers Kit (d) Java Devclopment Kit
() Choose the odd one out of:
char, int. float, bool, string.
(a) char (b) float (c) string (d) bool
(1) Sonmetimes there are two or more
possible matches for an invocation of a method due to similar method
Signature, so the compiler cannot determine the most specific match. This is referred to as:
(a) Amphibious situation
(b) Ambiguous invocation
(c) Conflict in building (d) Conflicted compilation
(xii) Suppose there is a member variable in the class:
int[ arr;
Later the initialization
arr[0] 2; is done. What line
=

must come somewhere before the initialization line, for


n0 exceptions to occur?

(a) ar[0] = new int; (b) arr = new int[5];


(c) arr = new int(5);
(d) None of these
(xi) Which of the following is the correct way to call the
length method of the String class?
(a) Length(str)
(b) Length(str, 0)
(c) str.length()
(d) strlength)
(xiv) What is returned by the Java line:
abc".compareTo ("abc") ;
(a) -1 (b) 0 (c) 1 (d) true
(xv) Suppose there is an Integer object, a. How can the
you access
integer value contained within this
object?
(a) a.int (b) a.length (c) a.intValue() (d) a.valueOf()
(xvi) Which of the below classes does not need initialization of its
object using the new operator, to use it?
(a) Int (b) Integer (c) Character (d) String
(xvii) The expression str.charAt (str. length () -1) always refers to:
(a) The first character of str (b) The second character of str
(c) The last character of str (d) The last but one character of str
(xviii) A method that displays something on screen cannot be a/an:
(a) Impure method (b) Static method
(c) Constructor (d) Pure method
(xix) Class variables are
always:
(a) Static in nature
(b) Private in nature
(c) Protected in nature (d) Public in nature
(xx) What boolean value will be returned by:
abe".endswith ("abc")
(a) true (b) false
(c) Cannot say (d) It does not return a Boolean value
Question 2

array does the lincar


search work? On what sort of array does the binary search work? 121
() On what sort of
(ii) What value is stored in the variable str? 121
str "hello". toUpperCase ()
String =

(iii) What is the difference between the String and StringBuffer classes? 21
Based the below two lines of Java, which Boolean value can the condition: 121
(iv) on

a==b

not have?
Integer a = new Integer (23);

Integer b =
new Integer (12);

(v) Is it true that the constructor has a return type of void? 12


(vi) Use of the same method name with differing argument lists is known as method 2
for casting of nt înto Integer type or casting Integer into int type in Java? 121
(vii) What are the names provided
(vii) With the help of the inbuilt constructor of Java, what is the below type of variable initialized to? 2
int[] abc;
used in the below manner, but is giving an error. How to rectify it? 21
(ix) The isLetter method is being
boolean b = isLetter ( 'A');

the arraysx and y have the same length, what does the below routine do? 121
(x) Assuming that
for (int i =0; i< x.length; it+)

Y[x.length i 11 =x[il1

SECTION B

(Answer any four questions from this Section)


The answers in the section should consist of the programs in either Bluel environment or any

program environment with java as the base.

Each program should be written using description/memonic codes so that logic of the
variable
program is clearly depicted.
Flowcharts and algorithms are not required.

Question 3 |15
it. If not, print
Suppose that the takes as input an integer. If the number is a perfect square, report
user
the two perfect squares between which the number lies. You may assume that the number is positive

or zero.

151
Question4
differ by 1. One example is
Determine all perfect squares and perfect cubes less than 100 such that the numbers
9 8 1. Write a Java program =

is a perfect cube, 9 is a perfect square and they differ by 1, since


-

8 and 9. 8
to determine all such pairs in the asked range.
111
Question 5 15
Sshouid be taken as nput from thee user.
from the user. The value of n
DCsIgn a class to take n strings as input gits. Report
of letters or entirely of digits. Report the same
TOu have to print out whether the string is made up entirely

depending on the casc.

Question 6 151
and ask the user to enter n
digits
strings. Ifthe string has aigits embedded
Design a class to take as input an integer n
the
the number. If there are no digits, print empty strino
n it, read the digits in order, left to right and print
For example:

Sa2ya3n445Bj5
23Deb435yan2
David
Abdul221la5h

Output
23445

234352

(Empty string)
225

Question7 115)

Design a class to take 6 strings as inputs. After taking the inputs, report the characters (letters or digits only)
that have any repetition within the string.

Question 8 115)
the two
Design a class to take an integer as input. If the number is a perfect cube, report Otherwise, print
it.

perfect cubes within which the number lies. The input integer can be positive, negative
or zero.

You might also like