Computer Science, asked by safrinists, 2 months ago

The methods of a class with the ____________ access specifier cannot be accessed in another class of different package.

Select one:

private

public

default

protected​

Answers

Answered by vishakasaxenasl
0

Answer:

The correct answer is private access specifier.

The methods of a class with the private access specifier cannot be accessed in another class of different package.

Explanation:

Access specifiers are commonly used in Object-oriented programming languages like C++, JAVA, etc to increase the security and encapsulation of the code.

There are a total of three types of access specifiers each having its own specialty:

  1. PUBLIC ACCESS MODIFIER: Public access modifiers are used with member functions of a class so that we can access the private data through the public member functions. However, this will access the class in another package.
  2. PRIVATE ACCESS MODIFIER: They are used when we want to access the data only within the class. Generally, the data of the class is kept private so that it can be saved from accidental changes.
  3. PROTECTED ACCESS MODIFIER: Protected access modifiers are especially useful in the case of inheritance. When the parent class has the protected data members, they can be accessed by using the child class object.

#SPJ3

Answered by pragyakirti12345
0

Answer: (a) Private

Explanation:

The methods of a class which has private access specifier cannot be accessed in another class of different package. Access specifiers are mostly used in Object-oriented programming languages to increase the security and encapsulation of the code. Languages which uses access specifiers are C++, JAVA, etc. . There are a total of three types of access specifiers which gives access to use fields and methods according to them:

  • PUBLIC ACCESS MODIFIER : Public access modifiers are used with member functions of a class so that one can access the private data through the public member functions. However, this will access the class in another package.
  • PRIVATE ACCESS MODIFIER : They are used when one want to access the data only within the class. Generally, the data of the class is kept private so that it can be saved from accidental changes. Private access modifier gives access within same class only.
  • PROTECTED ACCESS MODIFIER : Protected access modifiers are especially useful in the case of inheritance. When the parent class has the protected data members, they can be accessed by using the child class object. Protected access modifier give access within same package also.

__________________________________________________

Related links :

An access modifier cannot be applied on a.

https://brainly.in/question/3161498

What is the most restrictive access modifier that will allow members of one class to have access to members of another class in the same package?

a. public

b. abstract

c. protected

d. synchronized

e. default access?

https://brainly.in/question/2808956

#SPJ2

Similar questions