Quiz Space

Programming Concepts using Java · Quiz 1 · 25 Feb 2024 · January 2024 term

Question 11: Consider the following code: Choose the correct option t…

Question 11

+7 marksOne correct option

Consider the following code:

java
class Animal {
public void makeSound() {
System.out.println("Animal makes a sound");
}
}
class Dog extends Animal {
public void makeSound(String s) {
makeSound();
System.out.println("Dog " + s);
}
}
public class TestAnimals {
public static void main(String[] args) {
Animal myPet = new Dog();
//CODE SEGMENT
}
}

Choose the correct option to fill in the CODE SEGMENT so that the output is:
Animal makes a sound
Dog barks

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

Correct answer

  • D

Question 11 of 15 in the IIT Madras BS Programming Concepts using Java (Java) Quiz 1 paper sat on 25 Feb 2024, in the January 2024 term (IIT M DIPLOMA AN2 EXAM QDD2 25 Feb 2024). It carries 7 marks.

More questions from this paper

  1. Q1Which of the following statements is/are true about activation records?
  2. Q2Figure question
  3. Q3Consider the code given below. Choose the correct option.
  4. Q4Consider the Java code given below. Choose the correct option regarding the given code.
  5. Q5Consider the Java code given below. Choose the correct option.
  6. Q6Consider the Java code given below. Choose the correct option.
  7. Q7Consider the code given below. Choose the correct option to fill in place of CODE BLOCK so that the output is: Processi…
  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 Java code given below. Choose the correct option to fill in the CODE SEGMENT so that the output is:\ Toyot…
  11. Q12Consider the code given below that checks whether two Persons are the same. Method equals is overridden to compare two …
  12. Q13Consider the Java code given below. Choose the correct option regarding the above code.
  13. Q14Consider the code given below. Choose the correct option.
  14. Q15Consider the Java code given below. Choose the correct option.