Quiz Space

Programming Concepts using Java · Quiz 1 · 26 Feb 2023 · January 2023 term

Question 10: Consider the code given below. Choose the correct option.

Question 10

+4 marksOne correct option

Consider the code given below.

java
interface Vehicle{
default void getNoOfWheels() {
System.out.println("Has 2 Wheels");
}
default void getFuelCapacity() {
System.out.println("Capacity: 20L Petrol");
}
}
class ADMSBike implements Vehicle{ // LINE 1
public void getFuelCapacity() {
System.out.println("No petrol needed");
}
}
class MaruthiCar implements Vehicle{ // LINE 2
public void getNoOfWheels() {
System.out.println("Has 4 Wheels");
}
}
public class InterfaceTest {
public static void main(String[] args) {
Vehicle v[] = new Vehicle[2];
v[0] = new ADMSBike();
v[1] = new MaruthiCar();
for (int i = 0; i < v.length; i++) {
v[i].getNoOfWheels();
v[i].getFuelCapacity();
}
}
}

Choose the correct option.

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

Correct answer

  • D

Question 10 of 15 in the IIT Madras BS Programming Concepts using Java (Java) Quiz 1 paper sat on 26 Feb 2023, in the January 2023 term (IIT M DIPLOMA AN2 EXAM QPD2 26 Feb 2023). It carries 4 marks.

More questions from this paper

  1. Q1Match the following terms with their descriptions.
  2. Q2Consider the code given below. Choose the correct option.
  3. Q3Consider the code given below. Choose the correct option regarding the given code.
  4. Q4Consider the code given below. Choose the correct option regarding the given code.
  5. Q5Consider the code given below. What will the output be?
  6. Q6Consider the code given below. What will the output be?
  7. Q7Consider the code given below. Choose the correct option.
  8. Q8Consider the code given below. Choose the correct option.
  9. Q9Consider the code given below. Choose the correct option.
  10. Q11Consider the code given below. Choose the correct option to be filled in place of CODE BLOCK so that the output is: Pum…
  11. Q12Which of the following statements is/are correct?
  12. Q13Consider the code given below that checks whether two vehicles are the same. Method equals is overridden to compare two…
  13. Q14Consider the code given below. Choose the correct option(s) that can be filled in place of LINE 1 such that it does not…
  14. Q15Consider the code given below. Choose the correct option(s) to fill in place of CODE BLOCK so that the output is: XYZ J…