Quantcast

Got Homework?

Connect with other students for help. It's a free community.

  • across
    MIT Grad Student
    Online now
  • laura*
    Helped 1,000 students
    Online now
  • Hero
    College Math Guru
    Online now

Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

liliy

Assume that Animal extends Object (and assume Animal is an abstract class, no other abstract classes) and that FarmAnimal extends Animal Cow extends FarmAnimal Chicken extends FarmAnimal Assume all the above classes have a default constructor. Which of these statements compile? Animal a1 = new Animal(); ______ Animal a2 = new Cow(); ______ Cow a3 = new Animal(); ______ Cow a4 = new FarmAnimal(); ______ FarmAnimal a5 = new Cow(); ______ Cow a6 = new Cow(); ______ Cow a7 = new Chicken(); ______ Chicken a8 = new Cow(); _____ Chicken a9 = new FarmAnimal(); ______

  • one year ago
  • one year ago

  • This Question is Open
  1. charpede
    Best Response
    You've already chosen the best response.
    Medals 0

    Animal a1 = new Animal(); Animal a2 = new Cow(); FarmAnimal a5 = new Cow();

    • one year ago
  2. charpede
    Best Response
    You've already chosen the best response.
    Medals 0

    *assuming this is Java and the rules of polymorphism is the question

    • one year ago
  3. charpede
    Best Response
    You've already chosen the best response.
    Medals 0

    http://docs.oracle.com/javase/tutorial/java/IandI/polymorphism.html This tutorial should help clear up any confusion

    • one year ago
  4. Meepi
    Best Response
    You've already chosen the best response.
    Medals 2

    Animal a1 = new Animal(); doesn't compile! Animal is an abstract class and can't be instantiated. Animal a1 = new Animal(); Does not compile, Animal is abstract Animal a2 = new Cow(); Compiles, Cow is a subclass of Animal and is not abstract Cow a3 = new Animal(); Does not compile, Animal is abstract Cow a4 = new FarmAnimal(); Does not compile, FarmAnimal isn't a subclass of cow (it's superclass) FarmAnimal a5 = new Cow(); Compiles, Cow is a subclass of FarmAnimal Cow a6 = new Cow(); Compiles Cow a7 = new Chicken(); Does not compile, Chicken isn't a subclass of Cow Chicken a8 = new Cow(); Does not compile, Cow isn't a subclass of Chicken Chicken a9 = new FarmAnimal(); Does not compile, FarmAnimal isn't a subclass of Chicken

    • one year ago
    • Attachments:

See more questions >>>

Your question is ready. Sign up for free to start getting answers.

spraguer (Moderator)
5 → View Detailed Profile

is replying to Can someone tell me what button the professor is hitting...

23

  • Teamwork 19 Teammate
  • Problem Solving 19 Hero
  • You have blocked this person.
  • ✔ You're a fan Checking fan status...

Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.

This is the testimonial you wrote.
You haven't written a testimonial for Owlfred.