Answer:
int[ ][ ] X = new int[5][5];
It can also be declared and initialized this way:
int[][] X = {
{1,2,3,6,8},
{4, 5, 6, 9},
{7,5,6,8,9},
{8,5,8,8,9},
{10,2,6,8,11},
};
Explanation:
Above is a declaration of a two-dimensional array that can hold 5*5=25 int values. A java program is given below:
public class JavaTwoD{
public static void main(String args[ ]) {
// creating the 5X5 array
int[ ][ ] X = new int[5][5];
// looping through the array to add elements
for (int i = 0; i < X.length; i++) {
for (int j = 0; j < X[i].length; j++) {
X[i][j] = i * j;
}
}
Answer:
Name.
Explanation:
The constructor in the class must have the same name as the class.Constructors are used to initialize the object when created.There are basically three types of constructors which are as following:-
- Default Constructor.
- Parameterized Constructor.
- Copy Constructor.
Default Constructor:-This constructor is already present in the class when the class is defined.It does not have any arguments.
Parameterized Constructor:-As the name suggests this constructor have parameters that are used to initialize the object.
Copy Constructor:-This constructor is called whenever an object is copying the values of other object.For example:-
There is already an object present with name obj1.
class obj2=obj1;