Polymorphism - Lecture 18

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

What three things does encapsulation give you?

- Control access - Update attribute correctly - Maintainability

What are the key characteristics of polymorphism?

- shared behaviour - type (similar)

What is polymorphism?

A mechanism to define types that share behavior.

What are types?

Classes.

What is a polymorphic relationship?

Connection between two pairs. Those that share polymorphic behaviors may not necessarily be related if they do not share together.

How do we implement polymorphism, if superclass is Employee and subclass is fulltimeemployee, who needs a name and salary?

Employee LeoCaprio = new fulltimeemployee (String, Name. int salary)

(True/False) Polymorphism is the same as overriding a method.

False, you can have polymorphism without overriding methods.

What is inheritance in Java?

Inheritance in Java is the concept where the properties of one class can be inherited by the other. It helps to reuse the code and establish a relationship between different classes. Inheritance is performed between two types of classes: Parent class (Super class) Child class (Subclass class) A class which inherits the properties is known as Child Class whereas a class whose properties are inherited is known as Parent class.

Is it a good idea to use protected in Java?

No, weakens encapsulation.

Is the creation of many classes via composition polymorphism?

No.

What is an association relationship

Object uses another, does not share type or behavior, not polymorphic, and/or not part of state.

What is overriding a method?

Overriding a method is having another method with the same signature (name, parameters) in the child class, replacing the one in the super class.

What is the symbol for private?

Private: -

What is protected vs private in Java?

Protected access modifier is similar to that of private access modifiers, the difference is that the class member declared as Protected are inaccessible outside the class but they can be accessed by any subclass(derived class) of that class.

What is the symbol for protected?

Protected: #

What is the symbol for public?

Public : +

Why do we use polymorphism?

Reuse references in different objects (if those objects belong to the same type hierarchy).

Polymorphism is the provision of a ____ to entities of a different types.

Single interface

What is a component in Java?

Using methods inside other objects.

Late binding

When the actual method to call is not determined until run time.

Is polymorphism and inheritance linked?

Yes.

Polymorphism allows you to __________________ using the ________________.

call different behaviours, same reference


संबंधित स्टडी सेट्स

Christ and the Everlasting Gospel Midterm 1

View Set

A&P 102 MSJC-Vessels & Cardiac Study Guide

View Set

EXAM 2 Chapter 29 MasteringBiology

View Set

Technology For Success Module 2 Notes

View Set

exam 3 hormones, metabolism, immunity, inflammation

View Set

N406 Exam 3 Unit 11 PREPU (Endocrine)

View Set

CH. 10 World Regional Geography homework and quiz

View Set