Question 2
(a): What is an interface? How it is different from a class?
(2)
An interface is like a class but not a class. In an
interface, the data members declared are always static final and methods are
declared only. A class can implement an interface but can’t extend an
interface.
A class contains data members and method members. Methods
are defined in a class. The data members and methods members of a class can
have any access specifiers – public, private, default or protected and they may
be either instance of static member. We can create objects of a defined class.
An interface contains data members which must be static
final and method declaration which should be final only. We can’t create
objects of an interface but a class can implements number of interfaces.
(b): Convert the following infix expression to postfix form
(2)
P * Q / R + (S+T)
PQ*R/ST++
(c): A matrix P[15][10]is stored with each element requiring 8
bytes of storage. If the base address at P[0][0] is 1400, determine the address
at P [10][7] when the matrix is stored in row major wise. (2)
(Row
major order) Address(Arr[j,k])=base(Arr)+w[n(j-1)+(k-1)] - 'w' is the bytes
required for each location and 'n' is length of 2nd dimension
1400
+ 8 * [10*9+6]
1400+8*96
2168
No comments:
Post a Comment