MCQ and Logical 4 Prelims Ans in Last Page
MCQ and Logical 4 Prelims Ans in Last Page
Question 1 [20]
Choose the correct answers to the questions from the given options.
(Do not copy the question, write the correct answers only.)
()
(ii) "Java compiled code (byte code) can run on all operating systems"
- Name the feature.
(a) 2 bytes
(b) 4 bytes
(c) 8 bytes
(a) 16 bytes |Recalll
T25 861-SPECIMEN 2 of 12
(iv) Identify the operator that gets the highest precedence while ||
evaluating the given expression:
a+b% c*d-e
(a) +
(b) %
(c)
(d) [Analysis)
(v) Which of the following is a valid java keyword?
(a) If
(b) BOOLEAN
(c) static
(d) Switch [Understanding|
(vi) The output of the following code is:
System.out.printin(Math.ceil(6.4)+Math.floor(-1-2):
(a) 3.0
(b) 4
(c) 3
(d) 4.0 |Analysis]
(vii) Which of the following returns a String?
(a) length)
(b) charAt(int)
(c) replace(char, char)
() indexOf(String) [Understanding|
(vii) Which of the following is not true with regards to a switch
statement?
(a) checks for an equality between the input and the case labels
(b) supports floating point constants
(c) break is used to exit from the switch block
(d) case labels are unique [Understanding]
(a) x[51F100
(b) x[48]-100
(c) x[49F100
(a) x[50}100
[Analysis]
(xii) Method prototype for the method compute which accepts two
integer arguments and returns true/false.
(b) System.exit(0)
(c) continue
(d) return [Recall]
(a) False
(b) 0
(c) false
(a) Only A
(b) Only C
(c) All the three
(d) Both A and C [Analysis]
(xvii) The statement used to find the total number of Strings present in
the string array String s] is:
(a) s.length
(b) s.length)
(c) length(s)
(d) len(s) [Analysis]
(xix) Consider the following program segment in which the statements
are jumbled, choose the correct order of statements to swap two
variables using the third variable.
void swap(int a, int b)
{ a=b; ’(1)
b=t; ’ (2)
int t =0; ’(3)
t=a; ’ (4)
(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 [Application]
Question 2
booleanx= true;
switch(x)
case 1: System.out.println ("WIN"); break;
case 2: System.out.printin ("LOOSE");
[Analysis<l
int x=10;
while (true) {
Systen.out.printin (x+tt * 2);
if (x%3-=0)
break;
[Analysis]
(vi) Write the output of the following String methods: [2]
String x= "Galaxy ", y= "Games ";
class calculate
int a; double b;
calculate(0
a-0;
b-0.0;
}
calculate(int x, double y)
{
bry;
void sum)
[Analysis]
System.out.printin(a b):
Question 1 [20]
(1) (b Two Dimensional array with 4 rows and 5 columns
(ii) (C) Platform Independent
(ii) (a 2 bytes
(iv) (b) %
(v) (c) static
Question 2
(i) if (code ='g'| code =G')
System.out.printin("GREEN");
(i) Statement with error - boolean x-true ; To get the required output - int x =1; [21
22
(vii) X b [2]
.
Question 3
{
double p,n,r,a;
Scanner ob = new Scanner(System.in);
void accept()
System.out.printin("Enter principal");
prob.nextDouble):
System.out,printin("Enter number of years");
n=ob.nextDouble);
void calculate()