What is friend function? | Sololearn: Learn to code for FREE!

-2

What is friend function?

Java

4/30/2021 2:15:42 AM

Nikhil Ekhande

3 Answers

New Answer

+3

The friend keyword does not exist in Java. it's a C++ keyword.

+2

A non-member function that can access private member of the class

0

Function ( in JavaScript) is a block of code are used to perform a specific task. Syntax: function <functionName>(paranthesis1,paranthesis2 ...){ //block of code } <functionName>(); 1.we can reuse the code by creating function 2. We need to call function Function/ method( in Java) Same as javascript function definition Example public class Program{ public void display(){ System.out.println("Hello Friends"); } public static void main(String args[]{ Program obj=new Program(); obj.display(); // output Hello Friends } } I hope u understands function/method