Interfaces

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

How are the fields on an interface?

Are implicit static and final.

How can we classify an abstract class?

If it haves one or more abstract methods.

What is an abstract class?

Is a class that we cannot create instances it serves as an abstract model to create subclasses

Why use an interface?

It allow to do multiple inheritance by creating a class that can be upcast to more than one base type?

What is the big advantage of using interfaces?

It permit us multiple implementations for the same interface, we can write a method that takes an interface basic you are saying "You can use my method with any object you like as long as your object implements my interface.

What is an interface?

It's a complete abstract class with no implementation at all, it allows the creator to implement method names, argument lists and return types but not method bodies, an interface is contract between the client and

What is an abstract method?

It's a method that belongs to an abstract class but don't have a body only the definition.

Why abstract classes are useful as re factoring tools?

Since they allow you to easily move common methods up the inheritance hierarchy.

What is an appropriate guideline to choose between classes and interfaces?

Start with classes and if become clear that interfaces are necessary then refactor.

What happens when you inherit from an abstract class?

The abstract methods must be defined in the derived class.

For what was used interfaces in the past?

To create enums before Java SE5.

What causes confusion using several interfaces?

Using the same method names.

How do we define abstract class or methods ?

With the abstract keyword

How do we define an interface?

With the interface keyword and use the implement to apply.

Can you apply more that one interface to a class?

Yes, it allows also to create a method that behaves differently depending on the argument object that we pass.


Kaugnay na mga set ng pag-aaral

Acquisition of Hawaii, Samoa, and Alaska

View Set

US History Chapter 7 Review Questions

View Set

Palliative Care at End of Life (9)

View Set

Prep-U Ch. 5: Fetal Development, Ch. 6: Maternal Adaptation during Pregnancy & Ch. 7: Prenatal Care

View Set