Page 661 - Computer science 868 Class 12
P. 661
(c) Assertion is true and Reason is false.
(d) Assertion is false and Reason is true.
Ans. (b) NOR is the complement of the OR gate. It produces high output (1) only when all inputs are low (0). In all other cases, low
output (0) is produced.
(viii) What is function of keyword super? [1]
Ans. super keyword is a reference variable which refers to the parent class object
(ix) Write the working principle of stack? [1]
Ans. LIFO (Last In First Out)
(x) Write one property of abstract methods in java. [1]
Ans. Abstract methods have only method definition but no method body.
Question 2:
(i) Convert the following infix to prefix form. [2]
(A+ B *C) * D * E / F
Ans. (A+ B *C) * D * E / F
Reversing the expression (F / E * D * (C * B + A))
= F / E * D * (C B * + A))
= ( (F / E * D * (C B * A +) )
= ( F E D C B* A + * * /)
Reversing it again
/ * * + A * B C D E F
(ii) Given an array, arr[-1…8][-2....12] with base value 1000 and the size of each element is 4 bytes in memory. Find the address of
arr[8][6] with the help of row-major order. [2]
Ans. Base address B = 1000
Storage size of one element store in any array W = 4 Bytes
Number of column given in the matrix N = Upper Bound - Lower Bound + 1
= 12 - (-2) + 1 = 15
Formula:Address of A[I][J] = B + W * ((I - LR) * N + (J - LC))
Address of A[8][6] = 1000 + 4 * ((5 - (-1)) * 15 + (6 - (-2)))
= 1000 + 4 * (6 * 15 + 8)
= 1000 + 4*98
Address of A[I][J] = 1392
(iii) With reference to the code given below answer the following questions.
String compute (int n)
{ String s="";
for (int i=n; i>0; i=i/2)
{ int d=i%2;
s=Integer.toString(d) +s;
}
return(s);
}
(a) What will function compute() return if n = 25 [2]
(b) What is the method solve computing [1]
Ans. Working
i 25 12 6 3 1
d 1 0 0 1 1
s “1” “01” “001” “1001” “11001”
(a) Function compute() will return “11001”
(b) The method is converting a decimal integer number to its binary from.
659
Sample Paper 659

