Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started