Mock 3
Mock 3
( THEORY )
( Two Hours )
Attempt all questions from Section A and any four questions from Section B.
Section A - 40 marks
[Attempt all questions]
QUESTION 1:
ii) If a function contains several return statements, how many of them will be executed?
QUESTION 2
i) Makes several passes through the array, selecting the next smallest item in the array each time
and placing it where it belongs in the array
ii) At each stage, compares the sought key value with the key value of middle element of the
array.
b) What is the role of the keyword void in declaring functions? [2 marks]
c) Write statements to show how finding the length of a character array and char[] differs from
finding the length of a String object str. [2 marks]
e) Give the prototype of a function search which receives a sentence sentnc and a word wrd and
returns 1 or 0 ? [2 marks]
QUESTION 3
System.out.println(sum);
b)What will be the result stored in x after evaluating the following expression?[2 marks]
c) In the program given below, state the name and the value of the following:- [4 marks]
class myClass{
int y=2;
System.out.println(x);
obj.sampleMethod(5);
int a=6;
System.out.println(a); }
void sampleMethod(int n) {
System.out.println(n);
System.out.println(y); } }
double b=-15.6;
double a=Math.rint(Math.floor(b));
double c=Math.ceil(Math.abs(b));
System.out.println("a="+c);
System.out.println(n.endsWith("e"));
System.out.println(s.indexOf("Computer,5"));
System.out.println(s.compareTo(n));
int i=10
switch(i)
case1:j=i*2;
break;
case2:j=i+2;
break;
case3:j=i-2;
break; }
int p[]={3,5,7,9,11,13,15,17,19,21};
for(i=8;i>=0;i=i-2){
System.out.println(p[i]);
Section B
(Attempt any four questions)
QUESTION 4 [15 marks]
A prominent builder has announced the launch of a property which starts at 4000 Rs per sft
(square foot) for the 1st floor floor flat. The price per sft increases by Rs. 50 per floor up to and
including the 10th floor. From the 10th floor upwards, the price per sft increases by Rs. 100 per
floor. There are two types of flats: 2BHK and 3BHK. The 2BHK flats have a saleable area of
1500 sft, and the 3BHK flats have a saleable area of 2000 sft. The building has 20 floors. Write a
program that prints the rate of each floor, and the cost of each type of flat for each of the floors, in
the format shown below:
1 … … …
2 … … …
Write a program that asks the user to enter a word, and print all the UNIQUE two-letter
combinations that exist of that word. [15 marks]
Sample Input:-goOd
Sample Output:-GO GD OG OO OD DG DO
Write a Program in Java to input a number and check whether it is a Disarium Number or not.
Note: A number will be called DISARIUM if sum of its digits powered with their respective
position is equal to the original number.
The International Standard Book Number (ISBN) is a unique numeric book identifier which is
printed on every book. The ISBN is based upon a 10-digit code. The ISBN is legal if 1*digit1 +
Sum=1*1 + 2*4 + 0*0 + 4*1 + 5*6 + 6*0 + 7*1 + 8*4 + 9*9 + 10*9 = 253 which is divisible by
11.
(ii) If the ISBN is not a 10-digit number, output the message “Illegal ISBN” and terminate
the program
(iii) If the number is 10-digit, extract the digits of the number and compute the sum as
explained above.
If the sum is divisible by 11, output the message “Legal ISBN”. If the sum is not divisible
by 11, output the message “Illegal ISBN”.
A sentence in the Special Fashion can be printed by taking two integers (not beyond total number
of words in the sentence or less than 1). These integers tell the word number of the sentence.
Replace only those words present at those given integer places by the next character in a circular
fashion according to the English Alphabets. If both the integers are same then replace only one
word. let us consider the following examples:
Input Integers: 2, 4
(i.e. word number 2 and 4 have been replaced by the next characters in a circular fashion)
Write a program that asks the user to enter an integer (N). Create a single-dimensional array of N
double values. Ask the user to enter the N double values to populate this array. Sort this array in
reverse (descending) order using the selection sort method, and print the same on a single line,
each element separated by a space.
*******************