Respuesta :
Answer:
using the private access specifier on the class fields.
Explanation:
We can protect the data stored inside the object from the code outside in java by using the private access specifier on the class fields.
If the any class field is declared private it is not accessible to the objects outside that class.Private member are also not inherited in inheritance.
using the private access specifier on the class methods
Further explanation
Java is an OOP (Object Oriented Programming) paradigm programming language that can be run on computers with 32-bit or 64-bit systems. One software that operates the Java programming language is NetBeans IDE 7.2.
Private is the code that matches the name, this access is private. in other words, data and methods can only be accessed by the class they have.
Protected is an access code that makes a data or method that is defined with this level of access can be accessed by classes that have it only and also classes that include having descendants or Encapsulation data
Private Access
public class StudentRecord
{
// basic access to variables
private int name;
// basic access to the method
private String getName () {
return name;
}
}
In the example above, the variable name and the method getName () can only be accessed by the internal methods of the class.
Protected Access
public class StudentRecord
{
// access to variables
protected int name;
// basic access to the method
protected String getName () {
return name;
}
}
In the example above, the variable name and the getName () method can only be accessed by internal class methods and subclasses of the StudentRecord class.
Learn More
private protected in Javascript https://brainly.com/question/13133829
method and class in javascript https://brainly.com/question/13148975
Details
Class: High School
Subject: Computers and Technology
Keywords: javascript, private access, protected