Answered On : Feb 25th, 2006
hi, a class can not be private if we declare like that the error will be modifier private not allowed here. So the class can't be declared as private.
Answered On : Mar 7th, 2006
Hi,We can declare class as private. Only top level class can't be private.public class PrivateClassTest {private class PrivateClass{}}
Answered On : Mar 13th, 2006
we can declare java class as private . But the tat class wont b accesslible from its outer scope likepublic class B{// member variables and methodsprivate class C{// member variables and methods}}now the prob wid dis is only the members of class B can access dis class Cand by OOP design, we want more reusability of code which cant b possble in dis case
Answered On : Mar 15th, 2006
A class cannot be declared private
Answered On : Mar 16th, 2006
A class can be declared as Private A nested class that can only be accessed inside the class in which it is defined.
Answered On : Apr 6th, 2006
Hi allWe can use private,protected,static,default only with inner class not with the outer class.
Answered On : Apr 6th, 2006
No we can't declare class as private/protected,but In INNER CLASS we can give class as private.............
Answered On : Apr 19th, 2006
If a class is declared as private then no one can access the class.
Answered On : Aug 25th, 2006
Not true, the class can be accessed by an outer-class.
Answered On : Jul 28th, 2011
Yes.But we can not declare the outer class as private..If did so,the compiler will generate the error as the modifier private is not allowed here,but we can declare the inner class as private.
Answered On : Jul 28th, 2014
Some people might get confused by the many posts. The correct answer to the question "can we declare class as private?" is YES, BUT only as an inner class. A normal class cannot be protected or private.
Answered On : Jan 23rd, 2015
It will use in same class in same packages and use different class in different packages.
Answered On : Feb 24th, 2015
Yes, We can declare the class as a private but only inner classes can be a private.In that case we cant be use these class outside the class.
Answered On : Sep 22nd, 2015
If you have a private class on its own as a top-level class, then you cant get access to it from anywhere. Inner class can be made private because the outer class can access inner class where as it is not the case with if you make outer class private.
Answered On : Dec 6th, 2015
Child class will not be able to inherit it.
Answered On : Jul 8th, 2017
Java class cant be private it throws compile time exception.
Illegal modifier for the class TestClass; only public, abstract & final are permitted
Copyright © 2022 GeekInterview.com | All Rights Reserved
Copyright © 2022 GeekInterview.com | All Rights Reserved