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?
Solution
The correct answer is A
More IT Operating System Questions
- What is the primary goal of concurrent programming in software development?
- Which of the following statements best describes a mesh topology in network design?
- In Oracle database variable length column is declared by ____________
- There is a BST and below is the Pre order of the BST, What will be it’s In order 150 70 60 80 250 200 350
- Which of these techniques is primarily used for word embeddings?
- Consider the following Java code snippet: Â Â import java.util.PriorityQueue; Â Â public class HeapQuestion5 { Â Â Â Â public static void main(Strin...
- Consider the following Java code snippet: Â Â import java.util.PriorityQueue; Â Â public class HeapQuestion1 { Â Â Â Â public static void main(Strin...
- When an object that has an incoming reference is deleted or deallocated, without modifying the value of the pointer, so that the pointer still points to th...
- In PAM technique which of the below attributes of the pulse is used to vary as the amplitude of message varies
- Which collision resolution technique involves storing colliding elements in a linked list at the hash table index?