answersLogoWhite

0

A private class is a class that cannot be directly accesed from outside its outer class, similar to a private variable or method. This means that a private class must always be an inner class, though an inner class can be public or protected instead.

For instance, the following is valid and means that any X object cannot directly access the inner Y class.

public class X

{

private class Y{}

}

The following however is invalid.

private class X{}

User Avatar

Wiki User

15y ago

What else can I help you with?

Continue Learning about Engineering

Abstract class can be private?

A class can either be default or public it can never be declared as private, so the question of abstract class at the file level does not arise. But an inner class can be declared private and abstract as well.


Can you access in drive class from base class private data?

Base class should no knowledge about derived classes. The "private" modifier on a data member means private to the class which defined it. Base class cannot directly reference/access the private data member of the derived class, and the derived classes cannot access the private data member defined in the base class. Either way the accessing the private data member should be done via properties or getters


Can you make private class in c plus plus?

yes it is possible to make a private class in C++ but this class will not solve any purpose.................


Does java class must have public method?

no you can have a class with no public methods and even with a a private constructor public class Example { //constructor private Example(){ } }


Benefit of inner class in java?

Inner classes are very useful for classes that are written specifically to be used with the encompassing class. A good example of this would be a LinkedListNode class being part of a LinkedList class: public class LinkedList { private LinkedListNode root; private class LinkedListNode { private Object data; private LinkedListNode nextNode; } } No class except your LinkedList class needs to know anything about the LinkedListNode class. So we hide it so no one else needs to worry about what it does.

Related Questions

How do you abbreviate Private First Class?

How to abbreviate Private First Class


What specifies private access modifier and private base class?

A private variable is something that is not visible outside the class. A private class is one that cannot be inherited


Can a private first class have the rite to drop a private?

Yes a private first class has the right to drop a private under permission of a sergent or higher


Abstract class can be private?

A class can either be default or public it can never be declared as private, so the question of abstract class at the file level does not arise. But an inner class can be declared private and abstract as well.


Can you create a class in Call of Duty 3?

no, im private first class and i dont have it. and that is level 4 (private first class)


Can you access in drive class from base class private data?

Base class should no knowledge about derived classes. The "private" modifier on a data member means private to the class which defined it. Base class cannot directly reference/access the private data member of the derived class, and the derived classes cannot access the private data member defined in the base class. Either way the accessing the private data member should be done via properties or getters


Can you make private class in c plus plus?

yes it is possible to make a private class in C++ but this class will not solve any purpose.................


Does java class must have public method?

no you can have a class with no public methods and even with a a private constructor public class Example { //constructor private Example(){ } }


What is rank E-3 in the National Guard?

Private first class in the Army Guard, and Airman first class in the Air Guard.


What is private second class in us army?

The rank is simply Private (E2), referred to informally sometimes as "second class". There are three grades of Private in the Army - Private (E1), which wears no rank insignia, Private (E2), which wears one chevron, and Private First Class (E3), which wears one chevron and one rocker.


Can you define class as private in java?

Yes. However, ONLY nested classes (as in sub-classes of a top-level class) could be declared as private. The main (top-level) class cannot be private as it couldn't be accessed.


Benefit of inner class in java?

Inner classes are very useful for classes that are written specifically to be used with the encompassing class. A good example of this would be a LinkedListNode class being part of a LinkedList class: public class LinkedList { private LinkedListNode root; private class LinkedListNode { private Object data; private LinkedListNode nextNode; } } No class except your LinkedList class needs to know anything about the LinkedListNode class. So we hide it so no one else needs to worry about what it does.