answersLogoWhite

0


Best Answer

A class method or attribute (data item) that is declared protected can be accessed only by methods of the same class or by methods of derived classes of the class.

User Avatar

Wiki User

13y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: If a data-item is declared as a protected access specifier then it can be accessed?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

What is a specifier?

a specifier tells the JVM how to treat a particular class,method and variable while executing the program. For example, final classes cannot be extended and final methods cannot be overriden and final variables cannot be changed once declared. Likewise,static methods and variables can be accessed without having to instantiate an object for their class


Can you declare printf for integer variable?

printf is declared in stdio.hFormat specifier for an integer value is %d.


What is meant by private access in c plus plus?

It isn't. Private is the default access for class members. For struct members, the default access is public. Aside from default access, a class and a struct serve the same purpose; to define a class. As such, the following class definitions are equivalent: class X { int a; }; struct Y { private: int b; }; Typically, we use a struct to define simple data types with trivial construction and use class for more complex data types, often to encapsulate an invariant or to acquire a resource, hiding the implementation details from consumers using private access.


When do you use protected visibility specifier to a class member in C?

a class member declared as private can only be accessed by member functions and friends of that classa class member declared as protected can only be accessed by member functions and friends of that class,and by member functions and friends of derived classes


What do you mean by public private protected and friendly?

An Access Modifier is a key word in java that determines what level of access or visibility a particular java variable/method or class has. There are 4 basic access modifiers in java. They are:1. Public2. Protected3. Default and4. PrivateJava does not have a friendly access modifier.Public Members:If a variable or method is declared public, it means that it can be accessed by anyone or any other class (irrespective of which package they are in).Private Members:Members marked private can't be accessed by code in any class other than the class in which the private member was declaredProtected and Default Members:The protected and default access control levels are almost identical, but with one critical difference. A default member may be accessed only if the class accessing the member belongs to the same package, whereas a protected member can be accessed (through inheritance) by a subclass even if the subclass is in a different package

Related questions

How the jvm is able to access your class even you declare it using default access specifier but the same class is not accessed from other class which is declared in another package?

The JVM knows about all of your classes, no matter what package they are in or what access specifier you declared them with. The access specifier is only used to limit access from other classes.


What is a specifier?

a specifier tells the JVM how to treat a particular class,method and variable while executing the program. For example, final classes cannot be extended and final methods cannot be overriden and final variables cannot be changed once declared. Likewise,static methods and variables can be accessed without having to instantiate an object for their class


Why protected access specifier is not in interfaces?

Because an interface is like a contract/skeleton which decides what the implementing class has to do. So, if any entity in an interface is protected, they would not be available to the class that is implementing the interface. Hence, all the variables and methods declared inside an interface are public by default


Can you declare printf for integer variable?

printf is declared in stdio.hFormat specifier for an integer value is %d.


What is Private public and protected?

They are access modifiers used in c++ under the concept of Object Oriented Programming. They're generally used within a classPublic: The data members and methods having public as access specifier can be accessed by the class objects created outside the class.Protected: The data members and methods declared as protected will be accessible to the class methods and the derived class methods only.Private: These data members and methods will be accessible from the class methods only, not from derived classes and not from objects created outside the class.


What is meant by private access in c plus plus?

It isn't. Private is the default access for class members. For struct members, the default access is public. Aside from default access, a class and a struct serve the same purpose; to define a class. As such, the following class definitions are equivalent: class X { int a; }; struct Y { private: int b; }; Typically, we use a struct to define simple data types with trivial construction and use class for more complex data types, often to encapsulate an invariant or to acquire a resource, hiding the implementation details from consumers using private access.


When do you use protected visibility specifier to a class member in C?

a class member declared as private can only be accessed by member functions and friends of that classa class member declared as protected can only be accessed by member functions and friends of that class,and by member functions and friends of derived classes


Private in java?

The private identifier is used to specify that an element can not be directly accessed from the outside. For example, a field or method declared as private can not be accessed directly from outside of the object or class in which it is used.


What do you mean by public private protected and friendly?

An Access Modifier is a key word in java that determines what level of access or visibility a particular java variable/method or class has. There are 4 basic access modifiers in java. They are:1. Public2. Protected3. Default and4. PrivateJava does not have a friendly access modifier.Public Members:If a variable or method is declared public, it means that it can be accessed by anyone or any other class (irrespective of which package they are in).Private Members:Members marked private can't be accessed by code in any class other than the class in which the private member was declaredProtected and Default Members:The protected and default access control levels are almost identical, but with one critical difference. A default member may be accessed only if the class accessing the member belongs to the same package, whereas a protected member can be accessed (through inheritance) by a subclass even if the subclass is in a different package


In ANSI C you can hide data by using private access specifier Justify?

One can always declare a datatype as static which will limit the scope to the file only. this way data hiding can be achived. For more clearance on the same please refer 'the C programming language'. Data hiding means only relevant data is visible to the user and all the background information is hidden from the user. In c++, the variables are named as data members and these can be hidden with the help of private access specifier. In procedural languages, variables(global variables) are free to flow from functions to functions and hence they were not secured. But in C++, only the class in which the data members are being declared can access them by using private specifier. As, the data members and also member functions of a class cannot be accessed outside the class if they have private access so, they get hidden from the user and hence the data hiding is achieved. Also in inheritance when we derive a class from the base class then the derived class cannot access the private members of the base class. In addition, if a class is derived from another class privately i.e. for example syntax : class B : private A , is used then all the public and protected members (not private) becomes private to class B and cannot be accessed outside the class B, even by using the object of class B. Hence, data hiding is achieved in C++ through private access specifier.


What did the Mexican government has done to protect the monarch butterflies?

They declared the forest where they overwinter a protected area


What does In public mean?

The keyword public is an access specifier. A variable or a method that is declared public is publicly accessible to any member of the project. Any class or method can freely access other public methods and variables of another class.