/* */ Click to Join Live Class with Shankar sir Call 9798158723

What is Public member Function in Java ?


All the class members declared under public will be available to everyone.the data members and memeber function defined using access specifier public,can be accessed by other non-member function also.A part from that the member function of a class can access data members whether they are declared as private or public.

Q.) Example of Public Members Function in Java .
    
    class A  
{  
    public void msg()  
    {  
        System.out.println("Try it");  
    }  
}  
class PublicExample3 extends A {  
    public void msg()  
{  
    System.out.println("shineskill");  
}  
public static void main(String[] args) {  
    PublicExample3 p=new PublicExample3();  
    p.msg();  
      
}  
}  
Output
shineskill