Home  >  Article  >  Java  >  Chapter 7 Final Tests

Chapter 7 Final Tests

Mary-Kate Olsen
Mary-Kate OlsenOriginal
2024-09-25 06:25:38230browse

Testes Finais do Capítulo 7

1 Does a superclass have access to the members of a subclass? And can the subclass access the members of a superclass?
Example: Exercise1

2 Create a subclass of TwoDShape called Circle. Include an area( ) method that calculates the area of ​​the circle and a constructor that uses super to initialize the part referring to TwoDShape.

3 How to prevent a subclass from having access to a member of a super class?

4 Describe the purpose and application of the two versions of super shown in this chapter.

5 Given the following hierarchy:
class Alpha { ...
class Beta extends Alpha { ...
Class Gamma extends Beta { ...

In what order do the constructors of these classes complete their execution when a Gamma object is instantiated?

6 A superclass reference can reference a subclass object. Explain why this is important in the context of method overriding.

7 What is an abstract class?

8 How to prevent a method from being overridden? And that a class is inherited?

9 Explain how inheritance, method overriding, and abstract classes are used to support polymorphism.

10 Which class is a superclass of all other classes?

11 A class that contains at least one abstract method must be declared
as abstract. True or false?

12 What keyword is used to create a named constant?

The above is the detailed content of Chapter 7 Final Tests. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn