Question
Consider the following Java code: class Animal { String type = "Generic Animal"; void eat() { System.out.println("Animal eats food."); } } class Dog extends Animal { String type = "Dog"; void bark() { System.out.println("Dog barks."); } } public class TestInheritance { public static void main(String[] args) { Dog myDog = new Dog(); System.out.println(myDog.type); myDog.eat(); myDog.bark(); } } What will be the output of this code?
More IT Operating System Questions
- Which of the following is a blueprint for creating objects?
- Complete a simple hash function for a string s that sums the ASCII values of its characters and then takes the modulo of a prime number M. def simple_ha...
- Consider the following C code snippet for calculating base raised to the power of exp: #include double power(double base, int exp) { ...
- Consider a Java method printList(Node head) for a singly linked list. class Node { int data; Node next; Node(int d) { data = d; next = null...
- Consider the following code snippet (Java-like): class Animal { public void makeSound() { System.out.println("Animal makes a s...
- What is a 'context switch' in operating systems?
- The IP address 127.0.0.1 is known as the loopback address. Which address range is reserved for loopback in IPv4 and what is its primary purpose?
- A network uses CIDR block 172.16.0.0/20. How many usable host addresses are available in this subnet?
- Consider the following C code snippet: #include int factorial(int n) { if (n == 0) { return 1; } // ...
- What is the time complexity where the inner loop runs only half the times outer loop?
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)