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 functional dependency does not holds in given relation and why?
- Which of the following is NOT a core principle of Object-Oriented Programming?
- What is the primary function of the CICS (Customer Information Control System) in mainframe computing?
- If signal-to-interference ratio is 5 dB, signal power is 8 dB, then what is the interference power in dB?
- Which of the following metrics is NOT typically used in algorithm analysis?
- A Process Control Block (PCB) stores all information about a process. Which of the following is not typically stored in a PCB?
- In Python, if a method in a subclass has the same name as a method in its superclass, which method will be called when invoked on an object of the subclass...
- Encapsulation is often described as a "protective barrier" that prevents the data from being accessed by the code outside the class. This statement is:
- Which are the popular frequency ranges used in India for Wi-Fi communication ?
- What is the primary purpose of the ALOHA protocol in networking?
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