TOPUPchat logo...
Forgot password?

Select : C language | Java

Q.15] a drop of generics

1  public class Test2
2  {
3    public static void main(String[] args) {
4    ArrayList numbers = new ArrayList();
5    for (int i = 1; i <= 3; i++) {
6    for (int j = 1; j <= 3; j++) {
7    int value = i * 2 / 2;
8    {Integer intObj = new Integer(value); numbers.add(intObj);}    } }
9    { System.out.println(numbers); }    }}
    

Options]

A)  [1, 2, 3, 1, 2, 3, 1, 2, 3]
B)  [1, 1, 1, 2, 2, 2, 3, 3, 3]
C)  Compilation error at line no-8.
D)  Compilation error at line no-9.        

Click to See Answer
B)  [1, 1, 1, 2, 2, 2, 3, 3, 3]    

Next | error with i

Previous | comma oparetor in java

Hemen Ashodia [paper setter]
Register & recharge
Male Female
I agree Terms and Conditions