default methods vs abstract class

gudii9
gudii9 used Ask the Experts™
on
Hi,

I was reading below link

http://www.java2blog.com/2014/06/interface-default-methods-in-java-8.html

I have not understood below point relating to state

Parameter
Abstract class
Interface with default methods
State of objects
Abstract class can hold state of object
Interface with default methods can not hold state of objects

Read more at http://www.java2blog.com/2014/06/interface-default-methods-in-java-8.html#vEL23vv16DICqYjs.99

what is state of object?
How it one can hold and other cannot hold?

Also what it mean by overriding method to solve compilation error as below
you can solve this compilation error by overriding decorateWithPaints method in Room class
view plainprint?
public class Room implements Decorable,Paintable{  
 
    public void decorateWithPaints()  
    {        
        System.out.println("Decorate using paints");    
  }  
}

Read more at http://www.java2blog.com/2014/06/interface-default-methods-in-java-8.html#4dayfCwCZs3KPu77.99

please advise
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Senior Java Architect
Commented:
For your first question: Abstract classes can have member variables. Interfaces can't.

For your second question: If you implement more than one interface that has a default method with the same signature, you have to provide your own implementation of that method. If you don't provide one, the compiler can't tell which default method you wanted and gives you that error.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial