Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

Real Time sample code for Encapsulation and Abstraction.
where to use abstract and where to use specifies like
public private.

Answer Posted / ravikiran

Encapsulation & Abstraction:

The private variable declaration is abstration,and making
usage of getters and setters is encapsulation

private String name="";
private String school="";

public String getName()
{
return name;
}

public void setName(String name)
{
this.name=name;
}

When We use private when we want to restrict the access
within the class.

When we use public then the variable or method will be
accessible in all the locations

Is This Answer Correct ?    18 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain about the select method with an example?

1180


What is the relationship between class and object?

1045


What are checked exceptions?

1034


What are data types in programming?

991


Can a list be null in java?

1050


What is immutability in java?

1090


Why volatile is used in java?

1067


Can we declare the static variables and methods in an abstract class?

990


How to make object serializable in java?

985


What does .equals do in java?

1096


Which data type is a class in java?

1002


Write the algorithm to check the number non-leaf nodes in a tree.

1076


Can we declare a static variable inside a method?

1001


Which is fastest collection in java?

1081


What is class and object in java?

1005