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 8166097
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T19:44:36+00:00 2026-06-06T19:44:36+00:00

Can someone clarify the significance of the below code. class A { int i

  • 0

Can someone clarify the significance of the below code.

class A
{
    int i = 10;

    public void setI(int b)
    {
        i = b;
    }

    public int getI()
    {
        return i;
    }
}

class Test
{    
    public static void main(String args[]) throws Throwable
    { 
        final A ob = new A();
        ob.setI(10);
        System.out.println(ob.getI());
    }
}

The object A is declared as final, but I can change value of this object’s instance variable and also retrive the updated value. So what are the significance of declaring an object as final.
I am aware about declaring primitive datatype as final, which makes that variable constant.

  • 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-06T19:44:40+00:00Added an answer on June 6, 2026 at 7:44 pm

    ob will not be able to reference any other object : final keyword.

    It can not be reassigned. But you can change its internals (it is mutable, if it was originally).
    So this works :

      final A ob = new A();
      ob.setI(6)
    

    but this doesn’t :

      final A ob = new A();
      ob = new A();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can someone clarify my thinking on association fixup code in Entity Framework (T4 generated
Can someone please clarify using a SIMPLE user story the full slice of what
Can someone please help to clarify? Also, please mention if there are other representation
Can someone thoroughly explain the last line of the following code: def myMethod(self): #
Can someone clarify for me what the advantages and disadvantages of using MySQLi instead
Can someone clarify - if in my activity, I leave to call an intent
Please can someone clarify something which I should really know by now? If I
Im getting confused with WCF, can someone clarify this for me please. According to
In the context of data-structures synchronization, can someone clarify the difference between lockless and
I am confused can someone clarify what is .NET Framework means? Is that an

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.