Interface, Types, and Typecasting + Polymorphism Flashcards
When a class implements an interface, it promises to provide _______ the behavior published by that interface.
ALL
TRUE OR FALSE:
Interfaces cannot be instantiated
TRUE
Every field declaration in the body of an interface is implicitly ___________________________.
public static final
Methods in an interface are ____________
Abstract methods
multiple interfaces gives the illusion of _____________
multiple inheritance
The type of one object is converted to match the type of another object
reference
Type Casting
T or F
Casts can be applied to both primitive data types and object references
T
Types of Casting
Explicit Casting
char c = (char) i
Implicit Casting
float num = i
Widening vs Narrowing Conversion
Narrowing conversion may cause less of precision and range (float to int / superclass to subclass)
Widening conversion may cause increase in precision and range
(int to float / subclass to superclass)
In type casting objects, the cast must be to ________________________
subclass types, superclass types, or interfaces
determines the operations an object can perform.
Type
determines the implementation of its methods
Class
is a side effect of Inheritance
and Typing
Polymorphism
___________________ for Flexibility: helps us write code
that is easy to modify and extend.
Polymorphism
it is the ability of the programming language to handle objects differently depending on their data type or class.
Polymorphism