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

What are the benefits of interface?

581


What is coupling in oop?

600


Why interface is used?

555


What is inheritance write a program to show use of inheritance?

614


What are the types of abstraction?

557






Where You Can Use Interface in your Project

1427


What is object and example?

604


Why can't we have instance(stack) of a class as a member of the same class like eg.Class A{A obj;} as we can have self refential pointer

1622


What causes polymorphism?

577


What is overriding vs overloading?

584


What is polymorphism and example?

592


What is abstraction encapsulation?

657


What are functions in oop?

586


What is overloading in oops?

598


any one please tell me the purpose of operator overloading

1967