Question 2
(a) State two advantages of using the concept of inheritance in Java. [2]
(b) An array AR [ –4 …. 6, –2….12 ] , stores elements in Row Major Wise, with [2]
the address AR[2][3] as 4142. If each element requires 2 bytes of storage, find the
Base address.
(c) State the sequence of traversing a binary tree in: [2]
(i) preorder
(ii) postorder
(d) Convert the following infix expression into its postfix form: [2]
(A/B+C)*(D/ (E-F))
(e) State the difference between the functions int nextInt( ) and boolean hasNextInt( ). [2]
Comments of Examiners
(a) A number of candidates were not aware of the Suggestions for teachers
advantages of inheritance. Some used examples while OOP’s concepts must be
others explained in their own words. A few candidates explained with advantages and
wrote the definition instead of the advantages. examples. Real world examples
(b) Candidates who had the knowledge of the formula to may be used to explain these
find the address of a cell in an array could solve and get terms.
the correct answer. Others gave vague answers. Some Practice should be given in
calculated using memory cell diagram. understanding the formula using
(c) In parts (i) and (ii), some candidates explained with the row major and column major
help of a diagram. A few used the term vertex or an and making the subject of
operator to represent root. formula that is required in the
(d) Some candidates wrote the correct answer without question.
showing the working. Others applied the postfix Students should be given more
correctly, but could not derive the final answer. practice in binary trees and
(e) Several candidates wrote the functions with syntax while various terms used.
others wrote in their own language. Examples need to be practiced
with conversion of Infix to
Postfix notation, the order of
precedence; the Polish stack
method should be explained
clearly.
143