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

Answer Posted / 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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

When not to use object oriented programming?

758


What is polymorphism and why is it important?

754


What does and I oop mean in text?

837


2. Give the different notations for the class.\

1789


c++ program to swap the objects of two different classes

2104


What is a function in oop?

815


Why is polymorphism used?

761


What is difference between data abstraction and encapsulation?

824


can inline function declare in private part of class?

3951


What is the difference between inheritance and polymorphism?

783


What is use of overloading?

840


Whats is abstraction in oops?

822


What is object in oop?

866


What is difference between multiple inheritance and multilevel inheritance?

852


write a code for this:trailer recordId contains a value other than 99, then the file must error with the reason ‘Invalid RECORD_ID’(User Defined Exception).

1884