Quiz Space

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

Question 2: Consider the Java code given below. Choose the correct op…

Question 2

+6 marksOne correct option

Consider the Java code given below.

java
interface Purchasable {
public default void purchase() {
System.out.println("Product purchased");
}
}
interface Reviewable {
public default void review() {
System.out.println("Product reviewed");
}
}
class Headphone implements Purchasable, Reviewable {
public void purchase() {
System.out.println("Headphone purchased successfully");
}
}
public class Test {
public static void main(String[] args) {
Purchasable p1 = new Headphone();
p1.purchase();
p1.review();
}
}

Choose the correct option.

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

Correct answer

  • C

Question 2 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 6 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. Q3The following code maps a set of athletes names to the number of medals they have won and categorizes the athletes base…
  3. Q4Consider the Java code given below. What will the output be?
  4. Q5Consider the Java code given below that prints the highest purchased amount among a set of given Buyer objects. From am…
  5. Q6Consider the Java code given below. Choose the correct option.
  6. Q7Consider two Java files located in the same package as shown below. A.java: B.java Choose the correct option.
  7. Q8Consider the Java code given below. Identify the first assert statement that throws the AssertionError when the class i…
  8. Q9Consider the Java code given below. Identify the appropriate option to fill in place of LINE 1 such that the output is:
  9. Q10Consider the Java code given below. Choose the correct option to be filled in place of LINE 1 so that the output is:
  10. Q11Consider the Java code given below. What will the output be?
  11. Q12Consider the Java code given below. Choose the correct option to fill in the CODE BLOCK to add the name and average exp…
  12. Q13Consider the Java code given below. Choose the correct option.
  13. Q14Consider the following Java code. What will the output be?
  14. Q15Consider the Java code given below that should print the names of vehicles whose mileage is between 15.0 and 25.0 (both…