Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

a) b) c) d) Class Wolf is a subclass of class Animal. Consider the following code: wolf wolfi - new Wolf(Scott) Animal animall -new Wolf(Isaac);

a)

image text in transcribed

b)

image text in transcribedc)

image text in transcribed

d)image text in transcribed

Class Wolf is a subclass of class Animal. Consider the following code: wolf wolfi - new Wolf("Scott") Animal animall -new Wolf("Isaac"); Animal animal2 new Animal ("Joe"); // sets instance variable "name at Animal level // sets instance variable "name" at Animal level // sets instance variable "name" at Animal level ArrayList(; //Note: there is a howl() method in the Wolf class for (Animal animal : zoo) f ((Wolf) animal) howl) Nobody will howl; we will get a runtime error Scott, Isaac and Joe will all howl, and there will be no runtime errors. Scott and Isaac will howl, then we will get a runtime error. Only Scott will howl; then we will get a runtime error The code will not compile, so we will never know who will howl. Which of the following is not one of the ways in which inheritance supports the principles of Object Oriented Design Principles/Encapsulation? Choose one or more of the following. a Good use of inheritance can help reduce the amount of duplicated code in a project . It allows for new features & functionality to be added to a class (by extending/subclassing it) without actually changing (or needing to know) the implementation of the class. C It allows the designer of a class to specify the behavior of that class without worrying about the implementation d.It aids in easy code maintenance and allowing developers to create a separation of the different concems (responsibilities) of classes. Based on our discussions of inheritance in class (and the slides) which of the following statements is false? a. Substitution is a form of static polymorphism because the actual objects are known at compile time. This allows us (as programmers) to substitute subtypes when some method expects super-types of a certain class hierarchy. All of these are examples of some kind of polymorphism Method overloading is a form of static polymorphism. The methods share the same name but at compilation, the compiler can determine which implementation to bind to which method calls based on the lists of parameters. Method inheritance/overriding is a form of dynamic polymorphism. Its not possible for the compiler to determine at compilation which implementation of an inherited/overridden method to bind to which method call so the JRE handles it by accessing the runtime object and checking the class hierarchy for the correct method definition If you write a class and do not include a no-arg constructor, Java will provide one for you by default that will set all of the fields to their default values, object references will be set to NULL, numeric values set to 0, and booleans set to false. However for this to work, your class's parent must have its own no-arg constructor True False

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

Visual Basic6 Database Programming

Authors: John W. Fronckowiak, David J. Helda

1st Edition

ISBN: 0764532545, 978-0764532542

More Books

Students also viewed these Databases questions

Question

How do childrens self-concepts developpg12

Answered: 1 week ago