What is the difference between and interface and an
abstract class ?

Answer Posted / porchelvi

ABTRACT CLASS
*************
• It can not be instantiated

• It allow us to specify all access modifier except
Private

• A class inheriting this must implement all of its
abstract method


• A class can inherit only one abstract class at a
time.

• Abstract class can add more functionality with out
destroying child classes that were using old version.


• We can declare the following
1. Fields
2. Constructors
3. Static Constructors
4. Static Functions
5. Concrete Functions

INTERFACE
*********
• It can not be instantiated

• It allows only public Access modifier

• A class implementing interface must provide body
for its entire member.

• A class can implement more than one interface at a
time.

• Adding of additional functionality will have an
effect on its child class due to the necessary
implementation of interface methods.

• We can not declare the following
1. Fields
2. Constructors
3. Static Constructors
4. Static Functions
5. Concrete Functions

Is This Answer Correct ?    11 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Why do we use class?

635


What is coupling in oop?

600


What is polymorphism and why is it important?

562


Question In a class, there is a reference or pointer of an object of another class embedded, and the memory is either allocated or assigned to the new object created for this class. In the constructor, parameters are passed to initialize the data members and the embedded object reference to get inialized. What measures or design change should be advised for proper destruction and avioding memory leaks, getting pointers dangling for the embedded object memory allocation? Please suggest. Question Submitted By :: Sunil Kumar I also faced this Question!! Rank Answer Posted By Re: In a class, there is a reference or pointer of an object of another class embedded, and the memory is either allocated or assigned to the new object created for this class. In the constructor, parameters are passed to initialize the data members and the embedded object reference to get inialized. What measures or design change should be advised for proper destruction and avioding memory leaks, getting pointers dangling for the embedded object memory allocation? Please suggest. Answer # 1 use copy constructors 0 Shanthila There is something to be taken care in destructor, in copy constructor, suppose the memory is assigned to the embedded member object pointer with the parameter passed value, but if some other objects of different class also are pointing to this memory, then if some one deletes the object then this class member pointer object will become dangling, or if the object is not deleted properly then there will be memory leak. Please suggest the design change required to handle or avoid this situation

1662


What are classes oop?

598






What is purpose of inheritance?

645


hi all..i want to know oops concepts clearly can any1 explain??

1683


Get me an image implementation program.

1559


What is polymorphism programming?

605


What is inheritance in simple words?

627


What is multilevel inheritance?

727


which feature are not hold visual basic of oop?

1725


What language is oop?

595


Why is encapsulation used?

577


What is the difference between procedural programming and oops?

557