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 best describes a gateway in Computer Networks?
- Three processes P1, P2 and P3 arrive at time 0 (in that order) with burst times 10, 5 and 8 ms. Using Round Robin with a time quantum of 4 ms, what is the ...
- Which of the following is a default connector for Shielded twisted pair?
- What does the acronym "REST," commonly used in the context of web APIs, stand for, and what is one of its defining characteristics?
- Consider the following Java code: import java.util.regex.Matcher; import java.util.regex.Pattern; public class RegexGroup { public static void ...
- What is overfitting in the context of machine learning models?
- Which of the following sorting algorithms has the best worst-case time complexity of O(n log n)?
- In a demand-paged system, the memory access time is 200 ns and the average page-fault service time is 8 ms. For the effective access time not to exceed 400...
- 'Thrashing' in a virtual memory system refers to a condition where:
- What is the primary goal of code optimization in software development?
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)