Mock Test 1 2024-25
Mock Test 1 2024-25
Page 1 of 6
CALL: 7003064812 / 9007466531 / 9038770877
(iv) Find the output of the following code:
int s=14;
if(s>20)
System.out.print(“AB”+((char)(s+64;));
else
System.out.print(“BB”+((char)s+96);
System.out.print(“ CC”);
(a) ABC BBN CC
(b) AB BBn CC
(c) BbNCc
(d) BBnCC
(a) public
(b) static
(c) main
(d) void
(a) 120
(b) 625
(c) 300
(d) 230
Page 1 of 6
CALL: 7003064812 / 9007466531 / 9038770877
(d) ++,?=,<,+
(xii) Assertion (A): Functions in programming help in modularizing code for better
organization.
Reason (R): Functions allow code reusability by encapsulating a set of
instructions that can be used multiple times.
(a) Both Assertion (A) and Reason (R) are true and Reason (R) is a correct
explanation of Assertion (A)
(b) Both Assertion (A) and Reason (R) are true and Reason (R) is not a correct
explanation of Assertion (A)
(c) Assertion (A) is false and Reason (R) is true
(d) Assertion (A) is true and Reason (R) is false
(xiii) Read the following text, and choose the correct answer: The actual parameter is
copied to the formal parameter in such a way that any change made in the formal
parameter does not affect the actual parameter.
Which of the following options discusses the above mentioned statement?
(a) call by reference
(b)call by value
(c) Methods
(d) constructors
(xiv) If a string contains p characters, then what will be the middle index?
(a) p.length()/2-1
(b) p.length()-1
(c) p.length()/2
(d) 0
Page 2 of 6
CALL: 7003064812 / 9007466531 / 9038770877
(xv) Assertion(A): An array is used to store multiple values of different data types
under the same variable name.
Reason(R): An array is an example for reference datatype.
(a) Both Assertion (A) and Reason (R) are true and Reason (R) is a correct
explanation of Assertion (A)
(b) Both Assertion (A) and Reason (R) are true and Reason (R) is not a correct
explanation of Assertion (A)
(c) Assertion (A) is true and Reason (R) is false
(d) Assertion (A) is false and Reason (R) is true
Question 2
(i) What will be the output of the given code: [2]
Page 3 of 6
CALL: 7003064812 / 9007466531 / 9038770877
String str= “ALPHA”
System.out.println(str.charAt(0)*str.charAt(str.length()-1));
(iii) The following code segment should print the absolute of num. However, the [2]
code has errors. Fix the code so that it compiles and runs correctly.
public class Type {
public int getDouble(double num)
{
Double Value = Math.cbrt(8);
System.out.println(Value);
}
public static void main(String[] args) {
System.out.println("Absolute of number = " + getDouble(5));
}
}
(iv) Name the data type and the value returned by the following functions. [2]
a. Math.sqrt(16)
b. “COMIC”.compareTo(“COMET”);
(v) Given array A[][] = { {“BABA”, “DAD”, “MAA”},{“90”, “95”, “65”} }; [2]
System.out.println(A[0][1].length() * Integer.parseInt(A[1][1]));
System.out.println(A.length * Integer.parseInt(A[1][0]));
(vii) Write a function prototype for the function binary() which accepts two String [2]
and one double values and returns character.
Page 2 of 6
CALL: 7003064812 / 9007466531 / 9038770877
The answers in this Section should consist of the Programs in either BlueJ environment
or any program environment with Java as the base.
Q.3 Design a class to accept integers in a matrix (double dimensional) of 3x3 Display [15]
the sum of the left and right diagonal also display the product of the boundary
elements.
Q.4 Write a program to accept 10 characters in an array. Sort the array in descending [15]
order using bubblesort algorithm. Then display the array.
Q.5 Write a program to overload a function display() as per the details given below: [15]
(a) void display (String st, Char ch) – to display all vowels in the string if ch
is ‘v’ else display all the characters.
(b) void display (String s1, String s2) – to find the larger word by
comparing alphabet wise.
(c) void display (int n) – to check whether the prime factors of the number
n.
Q.6 Design a class to accept 10 words in an array and arrange them in descending [15]
order using the selection sort technique. Display the sorted array. Then accept a
word from the user and find the position of the word using binary search.
Q.7 Write a program to accept a number. Display the digits of the numbers in [15]
ascending order. Then display the appropriate alphabet based on the position.
Example Input: Enter a number: 3421
Example Output: Ascending order: 1234
Characters:
1 -> A
2 -> B
3 -> C
4 -> D
Page 3 of 6