Top Post

6/recent/ticker-posts

CS304 Important questions | Object oriented programming important topics

 Important Question of OOP



Q.

What is the difference between overloading and overriding?

Ans:

                Function overloading:

                                we declare more than one function with different arguments.

                                Example:

                                                void Print(string s);//Print string

                                                void Print(int i);//Print integer

                Faction overriding:

                                concept of inheritance. Functions with same name and a same number of arguments. Here the second function is said to have overridden the first

                        Example:

                                              Class a

{

public:

      virtual void display(){ cout << "hello"; }

};

 

Class b: public a

{

public:

       void display(){ cout << "bye";}

};

 

 

 

 

 

Q.

What is the difference between overloading and polymorphism???

Ans

Polymorphism means "many forms", and it occurs when we have many classes that are related to each other by inheritance.

Overloading is a kind of polymorphism

Different functions in different inheritance classes with the same name and arguments behave differently according to the object.

 

Q.
What is the difference between polymorphism and abstraction?

When a base class is created just for inheritance another derived class is called abstraction.

A class make an abstract class by declaring any of its function pure virtual function.

Polymorphism we discuss above.

                                

Post a Comment

0 Comments