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

Answers were Sorted based on User's Feedback



Real Time sample code for Encapsulation and Abstraction. where to use abstract and where to use sp..

Answer / 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

Real Time sample code for Encapsulation and Abstraction. where to use abstract and where to use sp..

Answer / manikandan [ gtec,vellore ]

Encapsulation is used when v need to use a data with the
object access.
Abstraction is used when v need to restrict the end user to
access all process.

Is This Answer Correct ?    1 Yes 10 No

Post New Answer

More Core Java Interview Questions

Can sleep() method causes another thread to sleep?

0 Answers  


Is it possible to define a method in java class but provide it’s implementation in the code of another language like c?

0 Answers  


what is Portal(web based online portal)?

2 Answers   AIG,


What is composition in java?

0 Answers  


What package is math in java?

0 Answers  






how we can make a read-only class in java?

0 Answers  


What are different type of exceptions in java?

0 Answers  


How many bits is a char?

0 Answers  


What is stream api in java8?

0 Answers  


Can I use % with real numbers?

0 Answers  


What is meant by call by reference?

0 Answers  


What are three ways in which a thread can enter the waiting state in java programming?

0 Answers  


Categories