Question: Which one is correct about the following block of code in java: class Animal { public static void main ( String args [ ] )
Which one is correct about the following block of code in java:
class Animal
public static void mainString args
Animal animal new Animal;
Dog dog new Dog;
animal.print;
dog.print;
void print
System.out.printlnSuperclass Animal";
public class Dog extends Animal
void printSystemout.printlnSubclass Dog";
Question options:
Dog is the superclass and Aminal is the subclass
The print method in the Animal class overloads the print method in the Dog class
A superclass variable can only shadow a subclass variable
The print method in the Dog class overrides the print method in the Animal class
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
