Thanks A.jyotsna,
Can u tell me differnce between abstract class and interface

vikash

Answers were Sorted based on User's Feedback



Thanks A.jyotsna, Can u tell me differnce between abstract class and interface ..

Answer / sridhar

Abstact class can have both concrete and non-concrete
methods where as interface has only non-concrete methods.
Unlike interface, Abstract calss can contain fields that
are not static and final.

Is This Answer Correct ?    5 Yes 0 No

Thanks A.jyotsna, Can u tell me differnce between abstract class and interface ..

Answer / mohammad shoiab

Difference Between Abstract Classes and Interfaces
Abstraction - A way to provide a view to an object
In real life we have examples like resume,hotel menu,
trailer of a movie as examples for abstraction. They
provide an insight into the other object.
Abstract classes and Interfaces are implementation of
abstraction.
abstract class - when u want to create classification or
hierarchy of classes, u can use inheritance and generally
your parent classes would like to impose certain compulsory
behavior along with some free behaviours. in such a case
the compulsory behavior to be declared as abstract, there
by the class should also be declared as abstract, so the
right place for abstract class is only in the case of
inheritance.
Interface - Interface are more related to roles, like for
example, u r a kind of human, and u r playing the role of a
programmer, here human could be a abstract parent class
and programmer could be a interface.
In real life all roles carry compulsory behaviors and if
you want to get into some role, then it is compulsory to
implement all the methods of the role.
"The world is a stage, every one is a actor, every actor
carries a mask, and when the mask changes the role changes,
and when the role changes the behaviour changes"
The roles are interfaces - u know very well one person can
carry many roles, so one class can carry many interfaces
but it can belong to only one classification. Thats why
multiple inheritance is allowed for interfaces and not
allowed for abstract or concrete classes,

Happy!!! - want to know more fundas - contact me -
Shoiab - 9840135749 - Haaris Infotech - The Java Trainers -
Chennai

Is This Answer Correct ?    5 Yes 0 No

Thanks A.jyotsna, Can u tell me differnce between abstract class and interface ..

Answer / rakesh kumar jha

Abstract class:-
1. if we declare ny class as a abstract, then we can't
create an object/instace of that class explicitly.
2.afbstracts class may or may not contain abstract method.
3. if on declare any method as an abstract, then the class
should be declared as abstract.
4.if a method is declared as abstract in abstract class,
then child bound to define the abstract method of parent.
5.abstract class may contain constructor.
6.abstract class may hold the child object.
Interface class:-
1.by default all method be abstract.
2.class can implements more than one interface class.
3.child should give the body of all method of interface
class, but if a child class with abstract keyword, then nod
need to give the body of interface classes method.
4.interface can't create objects but can hold the object of
child.
5. variable in interface class are by default public,
static and final.
6.we can't use the final, static, native,synchronous
keyword with the methods define in interface.
7. we can't declare interface as final.


if any question have, tell me at rkjhaw@sify.com or
info@shandilya.org

Is This Answer Correct ?    1 Yes 0 No

Thanks A.jyotsna, Can u tell me differnce between abstract class and interface ..

Answer / jyotsna gupta

Abstract Class | Interfaces
|
1. Starts with a class keyword | Starts with interface
| keyword
2. abstract modifier has to be | No need to provide abstract
provided | modifier (100 % Abstract)
3. Not necessary to contain | All methods are by default
abstract methods, but if a | public and abstract, and
class has abstract method | all attributes are public
then class has 2 be abstract| static, and final (FIELDS)

4. Used for group of related | Any class can implement
classes only | interfaces

5. Single inheritance is | Multiple inheritance can
allowed only | be achieved

6. All class behaviours are | Cannot have constructors,
allowed, except creating | should initialise its
objects of abstract classes | Fields

Is This Answer Correct ?    1 Yes 0 No

Post New Answer

More Core Java Interview Questions

Why java does not support pointers?

0 Answers  


When will we prefer to use set and list in java and why?

0 Answers  


class A{ some variables; public void a()throws Excepion1,Exception2{....} } class B extends A{ variables... public void a()throws E2,E3{.....} } Qns: here override of methods occurs or not,ore else wil give any compilation error or run properly..plz tell me briefly whts happening with the above codes....

4 Answers   Quinnox,


What is unicode used for?

0 Answers  


How to eliminate duplicates from an array?

6 Answers   ABC, AdMod, Adobe, College School Exams Tests, Patni, Wipro,






Can we return null in java?

0 Answers  


What is close method? How it's different from Finalize & Dispose?

0 Answers   InfoAxon Technologies,


Why strings in java are called as immutable?

0 Answers  


What is an exception in java?

0 Answers  


solve this is my problem byte a=40,byte b=50 both add value is 90 this is with in range of byte... byte range is -128to 127.... why this pgm gives error like type mismatch.... package javapgms; public class byte1 { public static void main(String args[]) { byte a=40,b=50; byte c=a+b; System.out.println(c); } } note : dont use int k... a,b,c are in byte range... mind it..

2 Answers  


what is meant by encapsulation?

0 Answers   Aspire,


Explain reverse a linked list recursive java solution?

0 Answers  


Categories