Quiz Space

Programming Concepts using Java · Quiz 2 · 1 Dec 2024 · September 2024 term

Question 15: Consider the Java code given below that should print the…

Question 15

+7 marksOne or more correct options

Consider the Java code given below that should print the names of vehicles whose mileage is between 15.0 and 25.0 (both inclusive).

java
import java.util.*;
class Vehicle {
String name;
double mileage;
public Vehicle(String n, double m) {
name = n;
mileage = m;
}
}
public class Test {
public static void main(String[] args) {
List<Vehicle> vehicles = new ArrayList<>();
vehicles.add(new Vehicle("Toyota", 18.5));
vehicles.add(new Vehicle("Honda", 20.2));
vehicles.add(new Vehicle("Ford", 14.8));
vehicles.add(new Vehicle("Chevrolet", 25.0));
vehicles.add(new Vehicle("BMW", 30.0));
//CODE BLOCK
}
}

Choose the correct option(s) to fill in place of CODE BLOCK to obtain the right answer.

Select all that apply.

  1. A
  2. B
  3. C
  4. D
Show answer

Correct answers

  • B
  • C

Question 15 of 15 in the IIT Madras BS Programming Concepts using Java (Java) Quiz 2 paper sat on 1 Dec 2024, in the September 2024 term (IIT M DIPLOMA AN EXAM QDD2 01 Dec 2024). It carries 7 marks.

More questions from this paper

  1. Q1Consider the Java code given below that prints the price of laptops. From among the options, identify the appropriate f…
  2. Q2Consider the Java code given below. Choose the correct option.
  3. Q3The following code maps a set of athletes names to the number of medals they have won and categorizes the athletes base…
  4. Q4Consider the Java code given below. What will the output be?
  5. Q5Consider the Java code given below that prints the highest purchased amount among a set of given Buyer objects. From am…
  6. Q6Consider the Java code given below. Choose the correct option.
  7. Q7Consider two Java files located in the same package as shown below. A.java: B.java Choose the correct option.
  8. Q8Consider the Java code given below. Identify the first assert statement that throws the AssertionError when the class i…
  9. Q9Consider the Java code given below. Identify the appropriate option to fill in place of LINE 1 such that the output is:
  10. Q10Consider the Java code given below. Choose the correct option to be filled in place of LINE 1 so that the output is:
  11. Q11Consider the Java code given below. What will the output be?
  12. Q12Consider the Java code given below. Choose the correct option to fill in the CODE BLOCK to add the name and average exp…
  13. Q13Consider the Java code given below. Choose the correct option.
  14. Q14Consider the following Java code. What will the output be?