Quiz Space

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

Question 11: Consider the code given below. Choose the correct option…

Question 11

+4 marksOne correct option

Consider the code given below.

java
interface Workable{
void work();
}
class Human{
public Workable getHeart() {
return new Heart();
}
public Workable getKidney() {
return new Kidney();
}
private class Heart implements Workable{
public void work() {
System.out.println("Pumps blood");
}
}
private class Kidney implements Workable{
public void work() {
System.out.println("Removes wastes");
}
}
}
public class PrivateTest {
public static void main(String[] args) {
//CODE BLOCK
}
}

Choose the correct option to be filled in place of CODE BLOCK so that the output is:

Pumps blood
Removes wastes

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

Correct answer

  • A

Question 11 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. Q10Consider the code given below. Choose the correct option.
  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…