can we declare private class in java file?

Answer Posted / ranganathkini

A class can be marked by the "private" access specifier only
if its a nested member of another class.

Top level classes cannot be marked as "private". Hence you
can have private classes in a java file but they must be
nested inside another class.

Is This Answer Correct ?    208 Yes 16 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Can a class extends itself in java?

801


If I don't provide any arguments on the command line, then what will the value stored in the string array passed into the main() method, empty or null?

1028


Why is string builder not thread safe?

855


What happens if we override only equals?

777


Why do we need autoboxing in java?

778


What are the types of collections in java?

810


If A Class Is Declared Without Any Access Modifiers, Where May The Class Be Accessed?

957


Can you inherit from an abstract class java?

776


What is garbage collector?

833


What is the difference between stringbuffer and stringbuilder class?

824


Are global variables initialized to zero?

732


Why is core java important?

810


What is a flag value?

730


What is the use of using enum to declare a constant?

801


What is the output of the below java program?

833