Quiz Space

Programming Concepts using Java · End Term · 30 Apr 2023 · January 2023 term · Set QPD1-S2

Question 18: Consider the Java code given below that prints the recha…

Question 18

+5 marksOne or more correct options

Consider the Java code given below that prints the recharge time of each charger in a list of chargers. From among the options, identify the appropriate function header for function display that takes as input a list of Charger objects and prints the recharge time of each.

java
import java.util.*;
abstract class Charger{
abstract void rechargeTime();
}
class USBCharger extends Charger{
public void rechargeTime() {
System.out.println("USB recharge time");
}
}
class LightiningCharger extends Charger{
public void rechargeTime() {
System.out.println("Lightining charger recharge time");
}
}
public class Test {
// LINE 1: FUNCTION HEADER
{
// invokes method rechargeTime()
// to print the recharge time of each charger
}
public static void main(String[] args) {
List<Charger> clist = new ArrayList<Charger>();
clist.add(new USBCharger());
clist.add(new LightiningCharger());
display(clist);
}
}

Choose the correct option(s).

Select all that apply.

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

Correct answers

  • C
  • D

Question 18 of 23 in the IIT Madras BS Programming Concepts using Java (Java) End Term paper sat on 30 Apr 2023, in the January 2023 term (IIT M DIPLOMA ET1 EXAM QPD1 S2 30 Apr 2023). It carries 5 marks.

More questions from this paper

  1. Q1Consider the Java code given below. During execution of Line 14 in the above code, the activation record of which metho…
  2. Q2Consider the following code. What will the output be?
  3. Q3Consider the code given below Choose the correct option.
  4. Q4Consider the code given below that checks whether two laptops are the same. Method equals is overridden to compare two …
  5. Q5Consider the Java code given below, and answer the question that follows: Choose the correct option.
  6. Q6Consider the code given below. What will the output be?
  7. Q7Consider the code given below. What will the output be?
  8. Q8Consider the Java code given below. What will the output be?
  9. Q9Consider the Java code given below. What will the output be?
  10. Q10Consider the code given below. Choose the correct option.
  11. Q11Consider the code given below. What will the output be?
  12. Q12Consider the code given below.\ Assume that file "data.txt" exists and contains the following text.\ I love my country\…
  13. Q13Consider the Java code given below. Choose the correct option when the program is executed as:\ java -ea AssertionTest
  14. Q14Figure question
  15. Q15Consider the code given below. What will be the possible output?
  16. Q16Consider the code given below. Choose the correct option to be filled in place of CODE BLOCK so that the output is: Cha…
  17. Q17Consider the code given below. Choose the correct option/s
  18. Q19Figure question
  19. Q20Consider the code given below. From among the options given below, which are possible outputs of the given code?
  20. Q21Consider the code given below. Identify the appropriate option(s) to fill in the blank at LINE 1, such that the output …
  21. Q22Consider the code given below. If the code given above produces the output: Apples\ Grapes\ Apples\ Grapes What should …
  22. Q23Consider the Java code given below. Choose the correct option(s) to be filled in place of CODE BLOCK so that the progra…