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

Question: Implement a base class Appointment and derived classes Onetime, Daily, Weekly, and Monthly. An appointment has a description (for example, “see the dentist”) and a date and time. Write a virtual function occurs_on(int year, int month, int day) that checks whether the appointment occurs on that date. For example, for a monthly appointment, you must check whether the day of the month matches. Then fill a vector of Appointment* with a mixture of appointments. Have the user enter a date and print out all appointments that happen on that date.

0 Answers  


how to create thread in java?

17 Answers   IBM, Infosys, Wipro,


What is encapsulation in oop?

0 Answers  


Why do we use encapsulation in oops?

0 Answers  


What is the purpose of enum?

0 Answers  


What is Iteration Hierarchy? What is what is Object behavioral concept?

1 Answers  


What is inheritance in oop?

0 Answers  


Program to check whether a word is the first word of the sentence.

1 Answers  


why the memory allocated with new cant be freed using free()

2 Answers  


What is class encapsulation?

0 Answers  


write a program which best describes polymorphism in real world?

2 Answers   CTS, Infosys, NexGen,


what is the difference between virtual function and destoctor?

1 Answers  


Categories