APCS Unit 10 Interfaces

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

What are interfaces used for?

-capturing similarities between unrelated classes without artificially forcing a class relationship -declaring method methods that one or more classes are expected to implement

______ are used to encode _______ which classes of various types share but do not necessarily constitute a __________.

Interfaces similarities relationship

Do interface types have instance fields?

No

Do interfaces have constructors? Why?

No because they can't be initiated

Can interfaces extend more than one interface?

Yes

Which of the following is true?

a child class can extend one parent and implement 0/more interfaces

What is an interface?

a collection of constants and method declarations

We use ____ _____ when an operation is performed in a different way for the subclasses forcing subclass to provide a ____ implementation.

abstract methods custom

When a class implements an interface, what must it do?

declare and provide a method body for each method in the interface

An interface is a way to _____ what classes should do, without specifying ___ they should do it.

describe how

Interface _____ a set of associated behaviors that can be used by _____ classes

encapsulates dissimilar

A class implementing an interface should use the keyword _____

implements

A class realizes (_______) an ______ by promising to provide the _________ for all of the methods in the interface.

implements interface implementation

A java __ declares methods that classes are expected to implement.

interface

Methods form the object's ______ with the outside world

interface

Use the keyword __ to define an interface

interface

you can define a reference of type _____ but you should assign to it an object instance of class type which ______ that interface

interface implements

In the computer world, the term ____ refers to any mechanism that connects ____ devices or entities and _______ the rules for their _______.

interface two defines interaction

An interface can be implemented by ___ class and a class can implement multiple _____.

many interfaces

Some object oriented languages allow ____ _______ which allows a class to be derived from ______ or more classes, inheriting the members of all parents.

multiple inheritance two

Can an interface ever contain method bodies?

no

Can object be created from an interface?

no

Interfaces contain __ _____ ______ and cannot be _______.

no instance fields instantiated

is it ok if a class definition implements two interfaces, each of which has the same definition for the constant PI?

no, if a class implements several interfaces, each constant must be defined in only one interface

can an interface be given the private access modifier?

no- the interface could never be used then

All methods in an interface are automatically _____ and _____.

public abstract

class definition with implementation of interface

public class Name implements Name

It's not a class but a set of ____ for classes that want to conform to the ____.

requirements interface

can an interface extends another?

yes


Ensembles d'études connexes

LUOA english 11: week 2 module 2

View Set

THE CRUSHED STAR - THE ART OF SEDUCTION - ROBERT GREENE

View Set

Accounting 2 - Chapter 8 Employer Taxes, Payments, and Reports

View Set

Med Surd Exam 4 (Cardiovascular) prep U questions

View Set

Quiz: Maternity and Women's Health Nursing: Pregnancy, Labor, Childbirth, Postpartum - Uncomplicated, Pregnancy, Labor, Childbirth, Postpartum - At Risk, Nursing Care of the Newborn

View Set