A class’s members include all the members declared in the class, along with all members (except constructors and finalizers) declared in all classes in its inheritance hierarchy . Private members in base classes are inherited but are not accessible from derived classes. Fields are variables declared at class scope.
Read moreWhich modifier is used to specify that a method Cannot be used outside a class?
Any variable, method, or class declared to use the default access modifier cannot be accessed by any other class outside of the package from which it was declared.
Read moreWhich of the following modifiers are used to control access to a class member?
The private modifier specifies that the member can only be accessed in its own class. The protected modifier specifies that the member can only be accessed within its own package (as with package-private) and, in addition, by a subclass of its class in another package.
Read moreWhich of the following modifier on members of a class that is not accessible to another class in different package but is accessible to any subclass in the same package?
protected : The protected access modifier is accessible within package and outside the package but through inheritance only. The protected access modifier can be applied on the data member, method and constructor. It can’t be applied on the class.
Read moreCan class be declared in main?
The main() method can appear in any class that is part of an application , but if the application is a complex containing multiple files, it is common to create a separate class just for main(). The main class can have any name, although typically it will just be called “Main”.
Read more