MCK Prelim Paper
MCK Prelim Paper
M.C.KEJRIWAL
VID YAPEETH
F.M. 100
(ü) Write a methodprototype namely, check() which takes an integer argument and returns acharacter:
(a) char check( ) (b) void check(int x) (c) check(int x) (d) char check(int x)
() When an object of a Wrapper class is converted to its data corresponding primitive type, it is called as
(a) Boxing (b) Explicit conversion (c) Unboxing (d) Implicit conversion
(iv) The element in x{4] of the array (3,5,7, 12, 16, 18,20,35,42, 89} is:
(a) 16 (b) 12 (c) 7 (d) 18
(v) Which of the following declaration and initialization is the below line equivalent to?
String str= new String( );
(a) String str = " (b) String str="0"; (c) String str-nul; (d) String str="\0";
(vi) State the value of 'y' after the following gets executed:
char x=9'; y-Character.isLetter(x);
(a) false (b) 9 (c) true (d) 9"
Turn Over.
This question paper consists of 6 printed pages.
(vi)Specify the return type ofa constructor methed.
(a) int (b) char (c) String (d) No return type
(viii) Select the access specifier that allows that allows the visibility of any data
(a) private member in a subclass:
(b) default (c) public (d) protected
(ix) Predict the final value that will be stored in variable 'x' after the following
double a=-7.35;
lines get executed:
double x=Math.abs(Math.floor(a);
(a) 9.0 (b)7.0 (c) 8.0 (d) 7
(x) Give the output:
int num[|={3,5,10,12,8):
System.out.print(nunm[2]+ "\t"+num{4-2);
(a) 1010 (b) 10 10 (c) 100 (d) 0
(xi) Give the output of thefollowing expression: a -=a -- + --a-a-; when a=10;
(a) 0 (b) 8 (c) 18 (d) None of these
(xii) Which of the folowing statements is true about con structors:
(a) Constructor methods are automatically invoked.
(b) Constructor methods needs to be explicitly invoked.
(c) Constructors always have a return typc.
(d) Constructors are private methods of a class.
(xii)Give the output:
"COMMENCEMENT". lastIndexOf(»M");
(a) 2 (b) 3 (c) 8 (d) 0
(xiv) Predict the output: devote".compareTo("DEVOTE");
(a) 32 (b) -32 (c) 0 (d) 100
(xviii) Select the searching mechanism that primarily works only on pre-sorted arrays:
(a) Linear (b) Birary (c) Both of these (d) None of these
(Xix) Choose the sorting mechanism that compes reincort array elements in pairs simultaneously:
(a) Selection (b)lnsertion (c) Bubble (d) None of these
-2
Av) ASSertion: In Call By Reference mechanism, the
reflected back upon the actual changed values of the formal parameters are
Reason: The mechanism works arguments,
and manipulates as
upon the well.
memory addresses of each object as required.
(a) Both Assertion and
Reason are true and Reason is a correct
(b) Both Assertion and Reason are true and Reason is not a explanation of Assertion
(c) Assertion is true and correct explanation of Assertion
(d) Assertion is false and Reason is false
Reason is true
Question 2
System.out.printIn("Excellent Conduct"):
(iv) The following program segment when executed is
displaying zero
values given as input. Rewrite the modified program code to get theirrespective
of any non-zero
correct answer. (2]
void trapezium(double a, double b, double h)
(v) How many times the following Ioop will get executed? Also, specify the output.
[21
int counter = 10:
do
System.out.println(counter):
}while(- - counter>=5);
-3
(vi)Give two points of differences between length) function and
length property of an array. (2)
(viii)Consider the following array and answer the
questions given below:
int x[ ] = { 23,45,67,12,45,89,24,12,9,7};
(a) What is the size of the array?
(b) What is the position of 89?
(ix) Specify the default values for the following primitive
(a) Any variable of char type.
types: (2|
(b) Any variable of double type.
(x) Mention the type of conversion /casting performed in the
given statements: (2]
(a) int a,b;
double res;
res=a+b:
(b) int x:
char res=(char)x;
-4
Cost Discount (in percentage)
Lessthan or equal to 10000
5%
More than 10000 and less than or equal to 20000
More than 720000 and less than or equal to 35000
10%
15%
More than 35000 20%
void display () T1odisplay customer name, mobile number, amount to be paid after discount.
Write a main() method to create an object of the class and call the above member methods.
Question 4 [15]
Write a program to input a number and check and print whether it is a Pronic number [15] or not.
(Pronic number is the number which is the product of two consecutive integers)
Examples:
12 =3 x 4.
20 = 4 x 5
42 =6 x 7
Question 5 [15]
descending order
Define a class to accept values in integer array of user defined size. Sort them in an
using selection sort technique. Display both the unsorted and the sorted arrays.
Question 6
[15]
-5
Question 8
(i) void check (String str, char ch) -to find and print the frequency of acharacter in a string.
Example :
Input:
str ="success
ch='s
Output:
Number of s present is = 3
(ii) void check(String si) - to display only vowels from string si, after converting it to lower case
Example:
Input:
sl =computer
Output:
Oue
-( -