Menu
Question Index
...

What will be the output of the following program?

import java.util.*;
public class ValueOf {
    public static void main(String[] args) {
        ArrayList al = new ArrayList<>();
        al.add('A');
        al.add(new String("Add"));
        al.add(256);
        al.add(Double.valueOf((int) 512.79));
        al.add(Integer.valueOf((int) 1024.9));
        al.add(Integer.valueOf(1048576));
        System.out.println(al);
    }
}


[A, Add, 256, 513, 1025, 1048576]
[A, Add, 256, 512.0, 1024, 1048576]
[A, Add, 256, 512.79, 1025, 1048576]
Some other output
Compilation Error or Runtime Error

Doubts

Problems

Topic: Java ArrayList

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App