ACB_mock_comp 03-Dec-2024
ACB_mock_comp 03-Dec-2024
SECTION-A
Question:1 (Attempt all questions from this section)
Name the type of array represented in the (20]
picture below:
(tlfy||F0:
What is the value of y[oj?
(a) 0 (b)No output (c)lndexOutotBoundsException (d)Junk vaiue pTO
Question2
-ind
c
packages,
ix)System and Math classes are contained in
(a) lang (b) oi (c) util (d)api
What is the output of the below code:
int a[]-new int[50]:
for(int i=1;i<=3;it+){
alil=i:;)
System.out.print
(a) 3 (a.length);
(b) 4 (c) 5 (d) 50
( ||
(a)Lowcroperator (b)Higher
has precedence than &&
(c)Equal (d)All of the above
) Which of the
following is valid result of the stalement:
System.out.print("Namaste.comparcTo("NAMASTEY") ;
1, -1
(a)Only 1.
2.0
(b)Only 2
3.greater than 0 value
(c)Only 3 (d)Both 1. and 4.
4.less than 0 value
i)Size of aclass with two instance variables of data ty pes double is:
(a)4 bytes (b) 8bytes (c) 16bytes (d)32 bytes
(Yind errors in the following program scgment and write the corect statemente.
private class Number [2
private double w;
private void assignNumber(double 2)
h-2:}
}lend of the class number
public class checkError
{
checkError object=New checkError();
checkError.assignNumber(15.26);
System.out.println(h);
/*End of class checkError*/
(GWhat will be the status of
used for arranging elements infollowing list after third pass of bubble sort and
ascending order? 40,67,-23,11,27,38,-1 third pass of selection sort
(in The following is a segment of a
int x=l:y-1; program: [2)
if(n 0){
X=X+1;
yy-l;
What will be the value of x and y,if n
assumes a value 1(0?
(iConvert the
int m-5,n-10; following While loop to the corresponding for loop: [21
while(n>=1){
System.out.printin(m*n);
n--;}
(State the method that:
Convert a string to a primitive float data type. [2
(Determine if the specified character is an uppercase character.
(vYWhat is the difference between length and length() functions.
[2]
(viConsider the following Java statements and answer the questions that follows:
String a-("FLORIDA","AMAZON","WASHINGTON": [2]
(aWhat is the range of indices for array a?
(b)What is the size of array?
(vii What will be the following code output?
String s="malayalam"; [21
System.out.printin(s.indexOf('m');
System.out.println(s. lastIndexOf('m');
CixWhat is the use of the JAVA keyword "this"?Ilustrate with an examnle
[2]
Showthe output of the following looping constructs:
int que--12; [2
boolean ans-true;
while(ans) {
if(que<0)
quett;
continue:}
else
break;
Sy stem.outprintin(que):
p. TO
SECTION-B
)
cL-x|Conla9
(Answer any four questions from this SectionBlueJJenvironment or any
The answers in this section should consist of the grams in either
progr
environment withiavaas the base
Each program should be Program
written using variable descriptionmnemonic codessoth¡tthe logic of
the program is clearly depicted.
Flowcharts and algorithms are not requirea
Question 3: The calorie exercise can be. The
higher this value, the moreconsumed per minute (CCM) is aunit of how strenuous anactivity is 20 cal/min
- this strenuous the exercise. For example, if the CCM for calories. Hence. if the
mcans that for every minute one
person docs thc exercisc of the exercise, the will have to burn 20
will burnperson
for
football, the CCM value for an15 mins, hc/she a total of 20 * 15 = 300 calories In a game of
athlete varies
For the first 15 mins,the
throughout the 90. mins,based on the intensity ofthe game.
The next 30mins (till thegame is high intensity -ihe
CCM value is 30 caunm
half time of 45mins) - the CCM
After the restart, for the next 30 mins - the value drops to 20
The last 15 mins of the game is high CCM a0ain drops to 15 cal/mim cau
intensity witha cCM value of 35 calmin
WAP to input the amount of time in minutes that the athlere has
less than 90, print an error plaved in the match (this value shoula be
by that athlete during the message not so). Then calculate how much total calories have been expchded
if
match. [15)
Question 4: Designa class to overload a function series() as
display the sum of the series follows:
(3void series(int a, int n)To [15]
a - (a/2!) + (a/3!) - (a/4!) + n terms
given below:
(b void series(int n)-To isplay the sum of
1/2- 2/3+ 3/4 - 4/5 + the series given below:
n terms
Write a main method to create an object and invoke the
above methods.
Question 5:
Write a menu driven program to display the pattern as per user's
Pattern.1 choice. [15)
ABCDE Pattern 2.
B
ABCD
ABC
LI.
UUr
AB EEEE
A
For an incorrect option, an appropriate errOr message should be displayed.
Question 6: A Dudeney number is a positive integer that is a
cqual to the cube root of the number. Write a program to inputperfect cube such that the sum of its digits is
a number and check and print whether it is
a Dudeney number or not.
Example: (15)
Consider the number 512.
Sum of digits = 5 + 1+2=8
Cube root of 512 =8
As Sum of digits = Cube root of Number hence 512 is a Dudeney
number.
Ouestion 7: Write a program in Java to enter a Sring Sentence and display the
length of the longest word present in the String. longest word and the
Sample Input: "TATA FOOTBALL ACADEMY WIl LPLAY [15|
Sample Output: The longest word: FOOTBALL: AGAINST MOHAN BAGAN"
The length of the word: 8
Question 8: Write a program to perfom binary search on a list of integers given
clement input by the user. If it is founddisplay the element along with its position,elow, to search for an
otherw isc display the
message "Search element not found".
5, 7,9, 11, 15, 20, 30,45, 89, 97