+ 1
#difference bww inter face &abstract class
Core java
3 Respostas
+ 11
1. Declaration and use
An interface is declared by the interface keyword. Subclasses use implements keyword to implement interfaces
An abstract class is declared by the abstract keyword. Subclasses use extends keyword to extend an abstract class.
2.Method keywords
An Interface has all methods are public and abstract by default. You can declare a method with the public, private, abstract, default, static and strictfp are permitted. If you try to use a protected modifier then it will throw an exception at compile time because it is not permitted the protected modifier. Since Java 8 we can define the default method and static method in the interface. In Java 9, we can define private methods also.
An abstract class is more flexible than the interface in declaring the methods. You can define abstract methods with protected modifier also. In the interface, the static method and default method is supported since Java 8.
For details: https://javagoal.com/difference-between-abstract-class-and-interface/
+ 5
There are many differences between interfaces and abstract classes. The most notable are:
- interfaces may only have abstract methods, default methods, and static methods, where as abstract classes can also have non-abstract methods.
- abstract classes don't support multiple inherritances, but you can implement as many interfaces as you like.
- abstract classes can define non-static variables, but interfaces may only have static and final variables.
- an abstract class can have class members of different access types. in an interface, all members default to public.
Here are some resources. Try searching your question before asking next time. Thanks :)
https://www.sololearn.com/discuss/363907/?ref=app
https://www.javatpoint.com/difference-between-abstract-class-and-interface
+ 1
Nice 💐