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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T08:53:48+00:00 2026-06-10T08:53:48+00:00

I know my question will be nominated to be closed immediately upon publishing, but

  • 0

I know my question will be nominated to be closed immediately upon publishing, but let me tell you that I had been searching the site for a clear cut difference in terms of an example, in Java. Please don’t be in a hurry to close the question.

I’ve written the following:

public class Bank {
public String name="XXX Bank";
private int noOfCust;

public int getNoOfCust() {
 return getNoOfCusts() + 2;
}
public void setNoOfCust(int noOfCust) {
if(noOfCust > 0)
{
this.noOfCust = noOfCust;
}
}

private int getNoOfCusts()
{
noOfCust = 100;
return noOfCust;
}
}

Here, ‘noOfCust is the data being hidden’. I am not exposing the implementation part by introducing private getNoOfCusts(). So I believe this is encapsulation, because I have bundled all the details in a class and have hidden the data too.

Question 1: If this strong encapsulation ? If not, how could I improve it to be strongly encapsulated?

Question 2: Abstraction means complete hiding of the implementation. So what I’ve done above is abstraction?

I’ve posted this question out of frustration because I had given the above explanation to an interviewer, who told me, this is not the correct meaning.

P.S: Please answer in terms of above example. I don’t want real time examples or assumptions.

  • 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-10T08:53:49+00:00Added an answer on June 10, 2026 at 8:53 am

    Choosing necessary properties and hiding unwanted details is Abstraction. For e.g. Consider Person. Person has eyes, eyeColor, skinColor properties. But if he goes to Bank, then Bank does his Abstraction and does not consider these Person’s properties but it selects name, address, phone_number. This is Abstraction. You misunderstood it.

    Encapsulation simply means binding object state(properties) and behavior(methods) together. If you are creating class, you are doing encapsulation.

    From wiki : In object-oriented programming languages such as C++, Object Pascal, or Java, the concept of abstraction has itself become a declarative statement – using the keywords virtual (in C++) or abstract (in Java). After such a declaration, it is the responsibility of the programmer to implement a class to instantiate the object of the declaration.

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

Sidebar

Related Questions

Ambiguous question, I know. But anyway, I'm developing a client's site that will enable
I know that question sounds a little odd but i will try to explain
I somehow know that the answer to this question will be obvious, but I've
I know this question will be closed because I studied many example of this
I know that my question will be very similar to other ones already asked
I don't know if my question will be clear or not, but i'm starting
Okay, here's my short question: I know that === and !== operators will compare
I know, I am asking stupid question but your experience will help me to
I know this question will sound like a from the past thing but I
I know this question has been asked/answered but I can't find it for the

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.