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

What is finalize() function in java?

0 Answers  


Why is the type for real numbers called double?

0 Answers  


What is private protected in java?

0 Answers  


What is sortedmap in java?

0 Answers  


What’s meant by anonymous class?

0 Answers  






Is .net better than java?

0 Answers  


What is a copy constructor in java?

0 Answers   Amazon,


What is the diff. b/w Interfaces & Abstract class?

6 Answers   Ericsson,


Explain importance of throws keyword in java?

0 Answers  


What is an abstract class and what is it’s purpose?

0 Answers  


How many Java environments are there?

1 Answers   Phantom Technologies,


What are the types of strings?

0 Answers  


Categories