Answered step by step
Verified Expert Solution
Link Copied!

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 main(String args[]){
Animal animal = new Animal();
Dog dog = new Dog();
animal.print();
dog.print();
}
void print(){
System.out.println("Superclass Animal");
}
}
public class Dog extends Animal {
void print(){System.out.println("Subclass Dog");
}
}
Question 9 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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Spomenik Monument Database

Authors: Donald Niebyl, FUEL, Damon Murray, Stephen Sorrell

1st Edition

0995745536, 978-0995745537

More Books

Students also viewed these Databases questions

Question

1. Is it a topic you are interested in and know something about?

Answered: 1 week ago