Java interfaces ebook

Java interfaces often cast doubt and confusion, which is a shame for the great strength and versatility they can bring to a Java application.

The Java interface design FAQ covers multiple inheritance, marker interfaces and interface constants and shows how a programming interface can improve concrete and abstract classes.

What if you were One Percent Better with Java interface design?

  • You seek interface design opportunities, not hide from them
  • You stop wasting time with fanciful inheritance schemes
  • Marker interfaces hold no fear, Serializable is your friend
  • You stop sweating multi-inheritance and blend behaviours like cocktails
  • You cast and pass interface types like a warm knife through butter
  • You enlighten friends with the simplicity of your interfaces

Java interface design FAQ

Java interface design FAQ ebook by Philip Shaw

ISBN
EPUB: 978-1-907863-03-5
Mobi: 978-1-907863-16-5

Answers to common Java interface design questions. Covers multiple inheritance, the marker interface design pattern, Serializable interface, abstract methods, interface constants and integration with abstract classes.

» More about the Java interface design ebook below

Buy now

Mobi for Amazon Kindle

EPUB for Apple iPad, Sony Reader, Nook

What's inside the Java interface design ebook?

We keep standard publishing blurb to a minimum and put it at the back. The book starts with a brief introduction, then straight into:

  • 33 core Java interface design questions and answers
  • 10 extra Java interface design answers from other FAQs
  • Links for online updates

You get updates to this edition free by email.

Java interface design ebook contents

The Java interface design FAQ ebook helps you solve problems like these.

Interface concepts

Why use interfaces to develop Java applications?
Don't spend ages adding new features to your apps, use a Java interface or two.
I still don't get why I should use interfaces!
Pointers on practical use of interfaces with Swing and Java threads.
How come methods in interfaces are not defined?
Its a struggle to learn abstract programming principles, interface program structures seem least intuitive.
What is the difference between abstract classes and interfaces?
Interface polymorphism adapts applications to new requirements by modular substitution.
What's the difference between an interface and an API?
If you write interfaces to fit classes you miss the best interface programming strategies.
Is an API a help document?
Its not all about Java SDK interfaces, practical interface development will make it all clearer.

Interface use

When should I use an interface?
Practical interface programming techniques ease the pain of brittle program structure.
Where should I use interfaces in my application?
Move beyond Java toolkit interfaces and write your own Java interfaces.
When should I use abstract classes rather than interfaces?
If your abstract classes look like interfaces, apply concrete methods.
Can you give an example of multiple inheritance with interfaces?
This multiple inheritance example will help make practical use of interfaces.
What are the rules for passing subclasses for method arguments?
Solve “incompatible type” compilation errors with this checklist of method argument cases.

How to define an interface

Should I use a public access modifier for interface methods?
Get your interface method modifiers right with these syntax notes.
Non-public modifiers can be used for nested interfaces!
You an create complex interface structures, but get basic interface declarations right first.
Can we create a Java class inside an interface?
Sometimes there is a case for a class nested in an interface, this answer shows how.
Can an interface extend a class?
Call off the search for a syntax to make an interface extend a class and learn interface inheritance hierarchy.
Can an interface extend an abstract class?
Can't work out how an interface extends an abstract class? You're not alone.
Can an interface be declared final?
If you write an interface like a standard class, you may have missed the point of Java interfaces.

How to implement an interface

Can we create an object for an interface?
Implementation is what interfaces are intended for.
How is the implements keyword different from extends?
Interface inheritance make better sense when you find a proper use for the implements keyword.
Can you show how to implement an interface?
Its easy to implement ActionListeners with this interface implementation example.
This code seems to be instantiating an interface!
Nested interface syntax can confuse, unwrap anonymous class declarations.
What if two interface methods clash in implementation?
Interface method declarations lose their fear when you write interface test cases.

Marker interfaces

What is a marker interface?
If you thought standard interfaces were vague, marker interfaces can seem downright bizarre.
How do marker interfaces affect the behaviour of classes?
The marker interface scheme is simpler than you might think.
Are there any marker interfaces that have methods?
Don't see the point of an interface that has no methods? The marker interface pattern is not about behaviour.
Why do we need to implement the Serializable interface?
Object serialization is tough enough, put an end to the NotSerializableException.
Can you show an example marker interface?
You have an empty interface and an implements statement but something is missing. This marker interface example will join up your thinking.

Interface constants

Do interfaces have member variables?
When you have duplicate variables in many implementation classes, its time to use interface constants.
Why are interface variables public static final?
The wrong interface constant modifiers can cause “modifier private not allowed” errors, find out why.
Interface variables can be overridden, right?
You unwittingly hide static interface constants, stop before it causes a bug.
This interface variable is assigned in a constructor!
Assignment to final variables seems to break interface constant rules. Clear the confusion over interface type variables.
What style should I use to declare a member variable in an interface?
Don't dither over interface constant modifiers, code style is easy to follow.
Is this interface constant declaration correct?
Compilation errors with curly braces “expected” suggest you may have muddled your interface constant declaration.

Extra Java interface design questions

This ebook includes 10 extra Java interface design-related answers from six other Java FAQs.

  • Can I achieve multiple inheritance without interfaces?
  • Can you show examples of Java inheritance?
  • Is multiple interface inheritance better than extending a class?
  • Why doesn't Java support multiple inheritance?
  • What Java types are available?
  • What part of memory is used for interfaces and abstract classes?
  • How can I cast an unknown sub-class returned by newInstance()?
  • Why use an abstract class instead of an interface?
  • What is a concrete object?
  • How should I use visibility modifiers with interfaces?

Any more questions?

Please contact us about the Java interface design FAQ ebook.

One Percent Better ebook stockists

One Percent Better ebooks are stocked at Amazon in Mobi format for the Kindle, the Apple iBookstore and Google eBookstore in EPUB format.

Kindle editions at Amazon

One Percent Better ebooks are distributed through Amazon for direct download to your Kindle.

iPad ebooks at the iBookstore

One Percent Better ebooks are also distributed through the Apple iBookstore for direct download to your iPad.

EPUB editions at the Google eBookstore

One Percent Better ebooks are distributed through the Google eBookstore in EPUB format. Search for “Java interface design FAQ”.

 

Ebooks for Web developers

More titles coming soon, contact us for news.