mock 5
mock 5
SECTION – A ( 40 Marks )
Attempt all questions.
Question 1 (2x5=10)
Question 2 (2x5=10)
Question 3 (2x5=10)
return c;
}
d) if (500>200)
x = 200
else
x = 100
Transfer the above Conditional Statement into ternary operator .
Question 4 (2x5=10)
a) i. Write the Java expression for the following: y = tan (log (13x9 ) )
ii. Evaluate the following if the value of x = 10 and y = 21,
System.out.println (Math.pow(Math.abs(Math.max(Math.min(x, y),y)),2);
b) What is the syntax to define an array ?
c) String s1 = “MINORITY”;
String s2 = “REPORT”;
i. System.out.println(s1.substring(0,3).concat(s2.substring(3,5))
ii. System.out.println(s2.substring(2));
iii. System.out.println(s2.replace(„p‟ , „s‟));
iv. System.out.println(s1.charAt(s1.indexOf(„R‟) + s2.indexOf(„R‟)));
Question 5 [15]
Write a program to enter any ten words and arrange in alphabetical order (Lexicographically) and
display them.
Question 6 [15]
Write a program to input multiple digited numbers in a single subscripted array of size 10 in the main ( )
method. Pass the array into a function named void remove_sort( ) that will remove the zeros from each
array element and sort the array elements in ascending order using Selection Sort Technique, and re-
display the elements within the same method.
Question 7 [15]
A company has employees, who are divided into four grades depending on their Basic pay per month as
follows,
Basic(Rs./month) Grade DA HRA
If the Net salary which is the total of Basic, DA, and HRA, is above Rs.50, 000 per month then Income
Tax at the rate of 30% of the annual salary exceeding 50,000 is deducted on monthly basis. Taking name
of the employee and the Basic (monthly) pay as inputs, prepare & print a pay slip, which contains
Name, Grade, Basic monthly pay, DA, HRA, Monthly Income Tax and Net Monthly Salary, for
employee.
Question 8 [15]
Write a program in Java to accept a line of text from the user and create a new word formed out of the
first letter of each word.
E.g. Mangoes Are Delivered After Midnight
Output: MADAM
Question 9 [15]
Write a program to generate the sum of the following series
Question 10 [15]
Area of rectangle
Area of square
Area of circle
Write an overloading function to display the above area in the respective functions,
calc_area (int,int) for rectangle,
calc_area (double) for square and
calc_area (float) for circle.