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 the difference between the methods sleep() and wait()? : Java thread

0 Answers  


What is the immediate superclass of Menu?

3 Answers  


What is integer valueof?

0 Answers  


What is independent and dependent variables in research?

0 Answers  


is JVM platform dependent or independent..?

11 Answers   IBM, Tech Mahindra,


Why declare Main() inside the class in java ?

0 Answers   HCL,


Is it safe to install java on my computer?

0 Answers  


what are the difference between Java and .Net?

5 Answers  


What is the difference between superclass and subclass?

0 Answers  


What is the difference between Access Modifier and Access specifier?

1 Answers  


why the primitive data type have classes?

4 Answers  


which method is used to know the status of the Thread?

9 Answers   Honeywell,


Categories