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
- To discard all pending data changes :
- Backtracking problem is seen in :
- What does the Hamming distance between two binary strings represent?
- What is a "smart object" in IoT?
- What does Polymorphism mean in the context of OOP?
- Which access specifier makes members accessible only within the class itself?
- What is the output of the following C program? #include int main() { int a=2, b=3, c=4; printf("%d", a<<1 | b&c); return 0; }
- Predict the output list1 = ['physics', 'chemistry', 1997, 2000] list2 = [1, 2, 3, 4, 5, 6, 7 ] print "list1[0]: ", list1[0]
- “Build Verification Testing” is the name of :
- In open addressing, if a collision occurs and the hash function h(key) maps to an occupied slot, which probing technique attempts to find the next availabl...
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)