Write 7 differences between "Public" function and
"Private" function?

Answers were Sorted based on User's Feedback



Write 7 differences between "Public" function and "Private" function?..

Answer / shankar

1. Public Functions are available to any member of the
class and Object of the class, while private functions are
available to member functions of the same class.

2. Public functions can be inherited, but private can't.

3. By making function Private we implement encapsulation,
but with public method we don't.

4 Private functions are not available in interfaces.
Interfaces only contains Public methods.

5. Private Method though it declare Static will not be
available By using Class Name.

7. Private functions can never be declared as abstract but
Public functions can be.

6. Public functions are defined using 'Public' keyword and
Private functions are defined using 'Private' keyword.

Is This Answer Correct ?    52 Yes 2 No

Write 7 differences between "Public" function and "Private" function?..

Answer / sriram

we can't access private function to the outside of the
package simply the scope of the function is with in the
function only

Is This Answer Correct ?    10 Yes 14 No

Post New Answer

More OOPS Interview Questions

Which is faster post increment or pre increment ? and in which cases should u use either - to increase speed?

4 Answers   EA Electronic Arts,


Write a program to demonstrate the use of 'Composition' in C++

2 Answers  


explain defference between structure and class with example

1 Answers  


difference between static and non-static variables?

2 Answers  


what is the difference between class to class type conversion and copy constructor ?

2 Answers  






How long to learn object oriented programming?

0 Answers  


What is virtual function?where and when is it used?

2 Answers   Sitel,


What is the output of the following code: int v() { int m=0; return m++; } int main() { cout<<v(); } 1) 1 2) 0 3) Code cannot compile

4 Answers  


What is constructor overloading in oop?

0 Answers  


What is encapsulation in simple terms?

0 Answers  


Is following functions are said to be overloaded? int add(int a,int b) char *add(int a,int b)

4 Answers  


Can enum be null?

0 Answers  


Categories