Professional Documents
Culture Documents
The time given at the head of this Paper is the time allowed for writing the answers.
SECTIONJA
(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
(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);
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
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 =
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
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.