Question Index

What will be the output of the following program?

import java.util.*;

public class FindMaX
    public static void main(String[] args)
        Vector<Double> numberAdd = new Vector<Double>();
        numberAdd.add(new Double("3.9999"));
        numberAdd.add(new Double("3.3532"));
        numberAdd.add(new Double("3.342"));
        numberAdd.add(new Double("3.342"));
        numberAdd.add(new Double("4")); //LINE M
        numberAdd.add(new Double("2.3"));
        Object maximum = Collections.max(numberAdd);
        System.out.println("The maximum number is: " + maximum);

The maximum number is: 3.9999
The maximum number is: 4.0
Compilation Error because instead of double we used Double.
Compilation Error at LINE M, because number 4 is of integer type
Compilation Error for some other reason



Topic: Java Vector

Read this topic
Take test on this topic

Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App