Page 1 of 2
1 2

Programming in JAVA

Superclass variable can reference a subclass variable in java

A reference variable of a superclass can be assigned a reference to any subclass derived from that superclass. You will find this aspect of inheritance quite useful in a variety of situations. For example, consider the following: Here, weightbox is a reference to BoxWeight objects, and plainbox is a reference to Box objects. Since BoxWeight …

Superclass variable can reference a subclass variable in java Read More »

Multidimensional array in java

In Java, multidimensional arrays are actually arrays of arrays. Data in multi-dimensional arrays are stored in tabular form. Example : Syntax: Data_type[1st dimension][2nd dimension]—-[Nth dimension] array_name=new data_type[size1][size2]—-[size N]; Where datatype Type of data to be stored in the array. For example int, char, etc. Dimension: The dimension of the array created. For example : 1D, …

Multidimensional array in java Read More »