Essays.club - Получите бесплатные рефераты, курсовые работы и научные статьи
Поиск

Java Programming 2-3: Java Class Design – Abstract Classes

Автор:   •  Ноябрь 12, 2022  •  Практическая работа  •  752 Слов (4 Страниц)  •  117 Просмотры

Страница 1 из 4

Министерство науки и высшего образования Российской Федерации Санкт-Петербургский политехнический университет Петра Великого

Институт компьютерных наук и технологий

Высшая школа киберфизических систем управления

Отчёт по практической работе

«Java Programming 2-3: Java Class Design – Abstract Classes»

По дисциплине «Системный подход к разработке ПО»

Выполнил

студент гр.                                                                    , 12.06.2022 

  подпись, дата                                

Проверил

Руководитель                                         ______________ С.А. Нестеров

                                                            подпись, дата

Санкт-Петербург

2022

Словарь:

The type of casting that changes a generalized object to a more specialized object type. – Downcasting

The process of a call to a generalized method and actually calls the instantiated subclass method, or appropriate subclass method. –Virtual Method Invocation

The operator that allows you to compare a class instance against a class type. – InstanceOf

The process of explicity changing one data type to another data type. – Casting

A class with an abstract constructor and at least one method that is defined but not implemented. – Abstract Class

This type of casting changes a specialized object instance into a generalized instance. It doesn’t lose any of its detail but you can’t access them without downcasting the object to access specialized methods. – Upcasting

A constructor without implementation that makes the class restricted in that it cannot create instances. – Abstract class constructor

1 задание:

Update the JavaBank.java application to use the toString() methods to display the bank account details to the text area in the Java application.

[pic 1]

  1. Update the myAccounts array definition to use the AbstractBankAccount class as its base class.

[pic 2]

  1. Update the displayAccountDetails() method to accept a single parameter of type AbstractBankAccount name

c) Call the account objects toString() method to provide the text for the JTextArea.

d) Update the method calls to displayAccountDetails() to pass a single account object as an argument.

[pic 3]

2 задание:

Give one reason why you might use an Abstract class rather than an Interface.

Ответ:

Абстрактный класс позволяет существенно сократить количество повторяющегося кода, потому что его информация о состоянии объекта и функционал могут быть использованы (в нашем случае с помощью метода toString();). Интерфейс позволяет распространить функционал, но не содержит в себе информацию о состоянии объекта.

...

Скачать:   txt (5.7 Kb)   pdf (556.4 Kb)   docx (508.2 Kb)  
Продолжить читать еще 3 страниц(ы) »
Доступно только на Essays.club