MCPS Prelim Jan 2023
MCPS Prelim Jan 2023
Q1) Choose the correct answer and write the correct option of question number and answer. [20]
ii) The parameter that appear in the method call are called as ____________.
(a) Call parameters (b) void parameters (c) actual parameters (d) formal parameters
vi) Though the program compiles, the result is not the desired result as per the requirement
due to _________ .
(a) Syntax error (b) Logical error (c) Runtime error (d) compiler.
xi) Square root of a negative number can’t be determined. Hence the output will be __________.
(a) NaN (b) Null (c) 0 (d) 1
--2
-2-
xiv) The automatic conversion of primitive data type into an object of its equivalent wrapper
class is known as ____________ .
(a) autoboxing (b) unboxing (c) implicit conversion (d) explicit conversion
xvi) A variable which can take an array of values is referred to as a _________ variable.
xviii) _______function checks if the string is equal, bigger or smaller than the other string or not.
(a) an integer array (b) a character array (c) a string array (d) a numeric array
xx) Which of the following statement is false.
Q2) i) Consider following program and answer the questions given below. [2]
class Display {
int a, b;
static int c;
(a +b)(a+ b)
iii) Write the java expression for [2]
( x+ y )
do{
-3-
v) Write the ternary operator to display the minimum of three numbers. [2]
vi) Give the output of the following String function. [2]
System.out.println(s.toUpperCase());
System.out.println(s.substring(7));
int s=0;
s = b[i] + b[3-i];
System.out.println(s);
viii) Write the function prototype of a static function calc() which receives double type value and
returns boolean value. [2]
ix) Differentiate between the access specifier - public and private. [2]
x ) Write the array elements on given array below after the first pass to show the working of the
bubble sort algorithm. [2]
9 6 24 3 11
Attempt any four programs. Write the comments where necessary and the variable description
table at the end of each program
Data members :
name, consumer number , unit consumed.
Member methods :
i) To accept the name, consumer number, unit consumed.
iv) Write a main method to create the object of the class and call the above member methods.
--4
-4-
void disp(int choice, char ch) – Display the character in lowercase if choice is 1, otherwise
display the character in uppercase if the choice is 2.
void disp (String str) – Display the reverse of String str in capital. If input received for str is
“cat”, then the output printed should be “TAC”.
5) Write a program to store the year given in single dimentional array. Arrange them in the
ascending order using bubble sort technique. Print the original array and the sorted array.
Input - 2001 2000 2005 2003 2008
Output - 2000 2001 2003 2005 2008 [15]
6) Define the class to accept 10 students name and marks scored in maths. Check for the existence
of the given name in the array using linear search , if found print the position of the record, name
and marks scored in maths. If not found, print search unsuccessful. Also print the names starting
with “mo” . [15]
7) Write a program using Scanner class to enter a token / word in a mixed case . Change the case of
the word to lower case and display the new token after deleting all the vowels.
Input : ComPtEr
Output : cmptr [15]
8) Write a program to accept 20 numbers in a Single Dimensional Array. Find and display the
following.
i) Sum and count of even numbers. [15]
ii) Multiple of 3 as well as 5.
iii ) Buzz numbers.
A number that is divisible by 7 or has the last digit as 7 is said to be a buzz number.
*******************