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

how to java plateform independent?

5 Answers   TCS,


what is Portal(web based online portal)?

2 Answers   AIG,


How Marker Interfaces are instruct to complete the desired need ?

2 Answers  


How do you create a method in java?

0 Answers  


What is casting?

3 Answers   BMC,






Can a top level class be private or protected?

0 Answers  


explain local datetime api in java8?

0 Answers  


What are the basics of core java?

0 Answers  


Can we force the garbage collection to run?

0 Answers  


What class allows you to read objects directly from a stream?

0 Answers  


What are computer functions?

0 Answers  


Is it possible to compare various strings with the help of == operator? What are the risks involved?

0 Answers  


Categories