St. Georges Unit 2 Preboard
St. Georges Unit 2 Preboard
Attempt all the questions from Section A and any four questlons from Section B.
(a) 14 b) -14
(c) 22 (d) -22.
(xiv) Retun type of concat() is
()char b) siring
(c) int (d) boolean.
(xv) Return type of trim() is :
(a) char (b) Saring
(c) int (d) boolean.
xvi) Givethe output
Math.max(-24,-8.4)+Math.sqrt(4);
(a) -6.4 (b) 6.4
(c) -0.4 (d) None of these.
(xvii) Give the output:
System.out.printin ("Compare" CompareTo (COMPARE)y';
(a)-32 b) 0
c)32 (d) 1.
3
(xvii) for (k =1; k <=2; kt++),
System.out.print(m* 2)
Rs. 1,75,000.
Write a main method to create object of a class and call the above member methods.
3. Design a class to overload a function num_cal( ) as follows: [15
) void num_cal (int num, char ch) with one integer It
argument and one character argument. cormputes
the square of an integer if choice ch is 's' otherwise, computes its cube.
(7 void num_cal (int a, int b, char ch) with two integer arguments and one character argument. It
computes the product of integer arguments if ch is p' else adds the integers.
1) void num_cal (String str 1, String str 2) with two String arguments prints the two Strings are
equal
or not.
4. A string is said to be 'Unique' if none of the letters present in the string are repeated. Write a program
to accept a string and check whether the string is Unique or not. The program displays a message
accordingly. [15]
Sample Input: COMPUTER
Sample Output: Unique String
5. Design a class to overload a function area( ) as follows [15
double area (double a, double b, double c) with three double arguments, return the area of scalene
triangle usingthe formula:
theformula:
area 1/2 * height (a + b)
(i) double area (double diagonal 1, double diagonal 2) with two double arguments, returms the area of
a rhombus using the formula
area 1/2 * (diagonal 1 * diagonal 2)