• Home
  • Recent Q&A
  • Java
  • Cloud
  • JavaScript
  • Python
  • SQL
  • PHP
  • HTML
  • C++
  • Data Science
  • DBMS
  • Devops
  • Hadoop
  • Machine Learning
in JAVA by
Explain about Public and Private access specifiers.

Methods and instance variables are known as members.


Public members are visible in the same package as well as the outside package that is for other packages.


Public members in Class A are visible to Class B (Same package) as well as Class C (Different package).


Private members are visible in the same class only and not for the other classes in the same package as well as classes in the outside packages.


Private members in class A is visible only in that class. It is invisible for class  B as well as class C.

Related questions

0 votes
asked May 24, 2019 in JAVA by rajeshsharma
  • #interviewquestionandanswer
  • #javaquestion
  • #javainterview
  • #javaanswer
  • #javaquestionanswer
  • #java
+1 vote
asked Jul 16, 2019 in C Plus Plus by Indian
0 votes
asked Dec 5, 2020 in Tableau by SakshiSharma