Question
The following C++ code intends to demonstrate runtime polymorphism, but it's not working as expected. What is the issue? #include class Animal { public: void makeSound() { // Problematic std::cout << "Animal sound" << std::endl; } }; class Dog : public Animal { public: void makeSound() { std::cout << "Woof" << std::endl; } }; int main() { Animal* a = new Dog(); a->makeSound(); // Calls Animal's makeSound delete a; return 0; }
More IT Operating System Questions
- For a 4x4 chessboard, if the first queen is placed at (0, 1) (row 0, column 1), which of the following positions would be the *first valid position* for th...
- What is the time complexity of the KMP algorithm for searching a pattern of length 'M' in a text of length 'N'?
- A page has 2^12-byte size and a logical address is 32 bits. How many bits identify the page number?
- Which of the following best describes Cyclomatic Complexity of a program?
- Fill in the blanks R _________are the same as the arrays in C language which are used to hold ____________data values of the same type
- Which of these is an application of AI in healthcare?
- Fill in the correct option for 27 blank space.
- Which of the following statements accurately describes the layer functionality of a router in network communication?
- A system has 3 processes, each needing a maximum of 4 instances of the same resource type. What is the minimum number of resource instances that guarantees...
- Complete the recurrence relation for dp[i][j] in the Longest Common Subsequence (LCS) problem when text1[i-1] is *not equal* to text2[j-1]. # dp[i][j] s...
Hey! Ask a query
Please enter email id
The email must be a valid email address.
Please enter Mobile Number
Please enter valid Mobile Number
Please enter your Doubt
Think You're Ready for RBI Grade B?
RBI Grade B 2026 Phase 1 Memory Based Paper
- 200 Questions with Detailed Solutions
- Section-wise Coverage (GA, English, Quant & Reasoning)