Question

In: Computer Science

If the class Parrot extends the class Bird, what can't be said about the classes? Select...

If the class Parrot extends the class Bird, what can't be said about the classes?

Select one answer:

A. The Parrot class has access to the Parrot methods

B. The Parrot class has access to the Bird methods

C. The Bird class has access to the Bird methods

D. The Bird class has access to the Parrot methods

Solutions

Expert Solution

Answer:

D. The Bird class has access to the Parrot methods

Explanation:

Inheritance is the process where one class acquires the properties or methods of another class. "extends" is a keyword that is used to inherit the properties of a class. The syntax is as follows:

class Super {
   .....
   .....
}
class Sub extends Super {
   .....
   .....
}

The class that inherits from another class is called a subclass or child class. The class being inherited is called a superclass or parent class. The subclass extends the superclass.

In the question above, class Parrot extends the class Bird. Therefore bird class is the parent/super class and parrot class is the child/sub class.

So parrot class will have access to its own class methods and along with that the methods of the bird superclass since it has inherited them.

The bird class will have access to its own methods but won't be able to access the methods of parrot class since it is not the inherited class. Infact it is the parent class and methods are inherited from it.


Related Solutions

How can the classes be modified to satisfy the comments: public class InvalidIntegerException extends Exception{    ...
How can the classes be modified to satisfy the comments: public class InvalidIntegerException extends Exception{     // Write a class for an InvalidIntegerException here     //Constructor that takes no arguments public InvalidIntegerException (){ super(); } //Constructor that takes a string message public InvalidIntegerException (String message){ super(message); } } import java.io.InputStream; import java.io.IOException; public class Parser { private InputStream in; public static final int CHAR_ZERO = (int) '0'; public Parser (InputStream in) { this.in = in; } // Complete the following...
PYTHON-- trying to teach myself how to create new classes. The Bird class will read a...
PYTHON-- trying to teach myself how to create new classes. The Bird class will read a file that has a list of species and will write to another file with the species and # of occurrences . use __lt__ to compare species and use #comments to explain the def methods in the class example of input file: blackbird canary hummingbird canary hummingbird canary output file: Blackbird,1 Hummingbird,2 Canary,3 class Birds: #do i need count in init? def __init__(self, species, count):...
Consider the following classes: public class Clock extends Bear { public void method3() { System.out.println("Clock 3");...
Consider the following classes: public class Clock extends Bear { public void method3() { System.out.println("Clock 3"); } } public class Lamp extends Can { public void method1() { System.out.println("Lamp 1"); } public void method3() { System.out.println("Lamp 3"); } } public class Bear extends Can { public void method1() { System.out.println("Bear 1"); } public void method3() { System.out.println("Bear 3"); super.method3(); } } public class Can { public void method2() { System.out.println("Can 2"); method3(); } public void method3() { System.out.println("Can 3"); }...
what can be said about drive
what can be said about drive
Much has been said about social stratification. Describe how the three major classes are able to...
Much has been said about social stratification. Describe how the three major classes are able to interact with one another as to contribute to the dynamic outcome of the economy that is Capitalism. What overall results do such interactions yield? What is the underlying theme in the outcome of this interaction?
Using JAVA: This assignment is about aggregation and class collaboration. You will create several Classes that...
Using JAVA: This assignment is about aggregation and class collaboration. You will create several Classes that will be part of an overall class named InstrumentDisplay. The classes are FuelGage, Odometer, MilesSinceLastGas, and CruisingRange. The FuelGage should assume a 15 gallon tank of gasoline and an average consumption of 1 gallon every 28 miles. It should increment in 1 gallon steps when you "add gas to the tank". It should decrement by 1 every 28 miles. It should display its current...
What are IP address classes? Please explain each class and their characteristics.
What are IP address classes? Please explain each class and their characteristics.
Macroeconomics class What is an identity? Explain them and all components. I can't find this anywhere...
Macroeconomics class What is an identity? Explain them and all components. I can't find this anywhere...
name one non-protein class of biological catalyst- What was it? What are the classes of enzymes?...
name one non-protein class of biological catalyst- What was it? What are the classes of enzymes? What are four advantages of biological catalysts over chemical catalysts? General properties of enzymes Compare and contrast with chemical catalysts
Construct a frequency distribution by hand with 5 or 6 classes. What are the class boundaries...
Construct a frequency distribution by hand with 5 or 6 classes. What are the class boundaries of this data set? and how did you find them? Show work please, thank you. HEADLEN 17.0 16.5 16.5 16.0 16.0 16.0 15.5 15.5 15.5 15.5 15.5 15.0 14.5 14.5 14.5 14.0 14.0 13.5 13.5 13.5 13.5 13.5 13.5 13.5 13.0 13.0 13.0 13.0 13.0 13.0 13.0 13.0 12.5 12.5 12.5 12.5 12.0 11.5 11.5 11.5 11.5 11.5 11.0 11.0 11.0 10.0 10.0 10.0...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT