answersLogoWhite

0


Best Answer

Some differences are:

  • An abstract class can have code for one or more methods but an interface cannot
  • All variables in an interface are public static and final but in an abstract class it is not
  • Abstract classes are faster than interfaces
User Avatar

Wiki User

โˆ™ 2010-02-12 14:03:21
This answer is:
User Avatar
Study guides

Mixture

1 card

Class

โžก๏ธ
See all cards
4.36
โ˜†โ˜…โ˜†โ˜…โ˜†โ˜…โ˜†โ˜…โ˜†โ˜…
22 Reviews

Add your answer:

Earn +20 pts
Q: What is difference between abstract class and interface in core java give brief answer with example?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

How is abstract class different from interface with example?

An abstract class has at least abstract methods. An interface has only abstract actions. For example, the javax.swing.AbstractAction class has only one abstract method that must be overriden: public void actionPerformed(ActionEvent e). The java.awt.event.ActionListener interface has the same method that must be overriden; however, it is its only method. The AbstractAction class is a subclass of the Action class, which implements the ActionListener interface. The AbstractAction class has overriden all but one of the Action class's methods.


What are the differences between an interface and an abstract class?

An interface is like a 100% abstract class. Only abstract methods can go in an interface. In addition, all methods in an abstract class are public and abstract by default. You "extend" an interface using the keyword implements. You can implement multiple interfaces, but you have to extend only one class. An interface can have only constants. This means no instance variables.As for an abstract class, you can put both abstract and concrete methods in an abstract class. It can have instance variables, but you can only extend one abstract class.Sun recommends using abstract and concrete class extension to signify what a class is, with an example in the following inheritance tree:Object||-Person||-Programmer||-JavaProgrammerAn interface is for signifying what jobs a class can do, like a Message class implementing a Sendable interface. Also, class names should be nouns and interface names should be adjectives, but conventions vary widely among programmers.


What is the difference between data structure and abstract data type?

An Abstract Data Type is an interface that interacts with a data structure. A Data Structure is an implementation of the ADT. for example. If you were going to create a linked list you would create an Interface listing all the methods required by the list. Then in the linked list class you would code how the list uses these methods. Hope this helps :)


Can you create an object of abstract class and interface?

No, not directly. You cannot use new operator to create either. However, you may create an instance of derived class from the abstract class, and treat (by casting, for example) as an instance of the abstract class. Similar to an interface: create an object from a class that implements the target interface, then treat that object as an instance of that interface.


What part of speech is difference?

The word 'difference' is a noun, a common, singular, abstract noun. Example use: The difference between right and wrong is sometimes a choice between difficult and easy.


What is the different between command line interface with Menu based interface?

Differentiate between Command line interface and Menus interface and example of each interaction style


What is the difference between microprocessor and microcontroller?

The basic difference between the microprocessor and microcontroller is that we can interface a microcontroller directly means "for example we can directly connect a keyboard to microcontroller to any of its ports"....where as for microprocessor we can't interface directly...we require a circuit board since it requires ram,ic's.....etc.,! beyrojac mahinay


Real time example for interface vs abstract class in java?

w.frnds........ I am just trying to an example of abstract class and interface class in real life . As these two ["interface class" is not a term in Java programming - just "interface"] classes [sic] are a concept of objest orientation so easy we can easily compare thhese with our real life . Suppose we have an abstract class called clark and an abstract method behabour of this abstract class ,which has no definition in abstract class. two other class security and receptionist inherits these clark class. So in thses two derived class there must has to be a defonation of behabour method,which depends on the derived class which types of behabour they will show........ So that is a real life example of Abstract class .Interface is also same as abstract class only the difference is it can't contain any implementation of any method in base class or super class. I think this is a sufficient example to understand abstract class and interface. [No, it is not sufficient.] If u have any doubt then u can contact me with this email id-rkmahanta26@gmail.com [Interfaces support multiple inheritance; classes do not. Interfaces contain only public members; classes do not have to. Interfaces do not have superclasses, except the implicit 'Object' supertype; they have superinterfaces. Nested interfaces are always static, never inner, unlike classes which can be inner classes. "u" is not an English pronoun. Use the tutorial and the JLS to understand interfaces and abstract classes, not this garbage answer.]


Difference between cli and GUI based on os?

CLI is Command Line Interface GUI is Graphical User Interface CLI - You type commands into a prompt and the computer executes them. GUI - You use a graphical interface and make selections with the mouse and the computer executes them. CLI example: MS-DOS GUI example: MS Windows XP


Difference between a command-line interface and a graphical user interface?

A command line interface is made up completely of text. A graphical user interface (GUI) is used in conjunction with a pointer device to used icons in place of the text. For example, in compiling a java program, the Eclipse IDE uses a point and click interface, while a command line interface would be the javac command.


What is difference between abstract noun and compound noun?

Abstract nouns are intagible and at the same time it is just felt; where as compuond noun is made up up of more than one noun like for example: SOn-in-law


What is the difference between a Unix or Linux shell and X-Windows?

A "shell" can often refer to an "interface", in which case X-Windows is simply an example of an interface. In Unix and Linux, however, a "shell" is often used to refer to a command-line interface, such as bash or csh. The X Window system is system for displaying a graphical user interface (which in itself can vary significantly in appearance).

People also asked