Usage of abstract class and interface

0 votes

I am really confused about when are the abstract classes or interfaces are created? And how do I decide which one to use and when?

Oct 23, 2018 in Java by code.reaper12
• 3,500 points
729 views

1 answer to this question.

0 votes

Well let me draw a clear line between the two:

InterfaceAn interface is used to declare the mandatory class members and methods required in a class. Classes implementing this interface then can declare and implement the methods of this interface according to their need. Also, you can implement any number of interfaces as you want.

Abstract Class: An abstract class is used generally to obtain a default implementation. Classes extending an abstract class needs to implement just its abstract methods and members. Unlike interfaces, you can extend only one abstract class at a time.

answered Oct 23, 2018 by geek.erkami
• 2,680 points

Related Questions In Java

0 votes
1 answer

Behavior of Integer Wrapper class and == operator

Well, this is happening because of the ...READ MORE

answered Jun 7, 2018 in Java by v.liyyah
• 1,300 points
2,826 views
0 votes
2 answers

What is the use of toString method in Java and how can I use it ?

Whenever you require to explore the constructor ...READ MORE

answered Aug 23, 2018 in Java by Daisy
• 8,140 points
4,108 views
0 votes
1 answer

In which class is the "length" property of array defined ?

It's defined in the Java language specification: The members ...READ MORE

answered May 8, 2018 in Java by Rishabh
• 3,620 points
1,149 views
+1 vote
3 answers

Copy Java Array and make a duplicate of it

int[] a = {1,2,3,4,5}; int[] b = Arrays.copyOf(a, ...READ MORE

answered Aug 30, 2018 in Java by Sushmita
• 6,920 points
1,706 views
0 votes
2 answers

What is the difference between implements and extends?

Extends : This is used to get attributes ...READ MORE

answered Aug 3, 2018 in Java by samarth295
• 2,220 points
16,227 views
0 votes
1 answer

Can Abstract Class have a Constructor?

Yes, an abstract class can have a ...READ MORE

answered May 11, 2018 in Java by sharth
• 3,370 points
1,170 views
0 votes
1 answer

using comparator for sorting in java

You've got two problems: 1) You're using Collections.sort (which takes ...READ MORE

answered Jul 6, 2018 in Java by samarth295
• 2,220 points
797 views
0 votes
1 answer

What is abstract class in java?

A class that is declared with abstract ...READ MORE

answered Jun 11, 2018 in Java by Daisy
• 8,140 points
969 views
+2 votes
3 answers

Listing all the subclasses of a specific class in Java

Try with BurningWave core library. Here an ...READ MORE

answered Dec 29, 2019 in Java by anonymous
• 460 points

edited Jan 9, 2020 by anonymous 14,514 views
0 votes
1 answer

Difference between String.equals() and ==

Though both are used for comparison, but the ...READ MORE

answered May 7, 2018 in Java by geek.erkami
• 2,680 points
900 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP