Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7988633
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T12:30:58+00:00 2026-06-04T12:30:58+00:00

I am relatively new to java and I did some reading about private and

  • 0

I am relatively new to java and I did some reading about private and public acccess modifiers. I would like to eliminate any confusion once and forall in this topic because I feel like I don’t have the best grasp on it.

Access modifiers in variables

Please correct me if I am wrong, a variable is public on default. If the access modifier is set to public or just not set at all, than other classes from the same project can access the integer and/or modify it. If it is private than it is not visible to the outside and cannot be accessed by classes outside the one in which it was created.

Accesss modifiers in classes

Access modifiers in classes, I don’t seem to fully understand. As far as my understanding, if I call a private method from method that is not in the same class, than it will not work. If it is public than it will?

Is there anything I am missing or don’t understand correctly?

I appreciate help in this regard.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T12:31:00+00:00Added an answer on June 4, 2026 at 12:31 pm

    Please correct me if I am wrong, a variable is public on default.

    You’re wrong. Assuming you mean fields, by default, they have “package” access, which can’t be expressed explicitly. Local variables have no concept of access control – they only exist within the context of a method anyway, so can’t be referred to from anywhere else.

    If the access modifier is set to public or just not set at all, than other classes from the same project can access the integer and/or modify it.

    If it’s set public, then any code can access it.

    If it’s default (package) access, then any code in the same package can access it.

    Access modifiers in classes, I don’t seem to fully understand. As far as my understanding, if I call a private method from method that is not in the same class, than it will not work. If it is public than it will?

    That’s pretty much right, yes.

    I suggest you read the Java tutorial on all of this, and consult the language spec section 6.6 for more details.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm relatively new to Java and would appreciate any help on this! I have
I've been doing some reading about two (relatively) new concepts in the Javascript language
I am relatively new to Java and while trying out some code came across
I'm relatively new to Java EE and have already began to hear about the
I'm relatively new to java (specifically swing) and have recently been making some fairly
I mostly use Java and generics are relatively new. I keep reading that Java
I'm still relatively new to Java and Android development, so I'm still unfamiliar with
Note: I'm relatively new to Objective-C and am coming from Java and PHP. Could
I am relatively new to PHP, but experienced Java programmer in complex enterprise environments
I am relatively new to Visual Basic. When it comes to logging, in Java

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.