Question: 1
Given the following class:
Which two changes would encapsulate this class and ensure that the area field is always equal to length * height whenever the Rectangle class is used?
Question: 2
Given the code fragment:
Which two code fragments can be independently inserted at line n1 to enable the code to print the elements of the array in reverse order?
Question: 3
Given:
class Test
int a1;
public static void doProduct(int a) {
a = a * a;
)
public static void doString(StringBuilder s) {
s.append('' '' + s);
}
public static void main(String[] args) {
Test item = new Test();
item.a1 = 11;
StringBuilder sb = new StringBuilder(''Hello'');
Integer i = 10;
doProduct(i);
doString(sb);
doProduct(item.a1);
System.out.println(i + '' '' + sb + '' '' + item.a1);
}
}
What is the result?
Question: 4
Which two class definitions fail to compile?
Question: 5
The following grid shows the state of a 2D array:
This grid is created with the following code:
Which line of code, when inserted in place of //line n1, adds an X into the grid so that the grid contains three consecutive X's?