GeekInterview.com
  I am new, Sign me up!
 
GeekInterview.com  >  Interview Questions  >  J2EE
Go To First  |  Previous Question  |  Next Question 
 J2EE  |  Question 17 of 104    Print  
can we declare class as private?
what will happen if we declare like that?

  
Total Answers and Comments: 9 Last Update: August 25, 2006     Asked by: suresh 
  
 Sponsored Links

 
 Best Rated Answer

No best answer available. Please pick the good answer available or submit your answer.
February 25, 2006 14:23:47   #1  
vimal        

RE: can we declare class as private?what will ha...

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.


 
Is this answer useful? Yes | No
March 06, 2006 23:30:18   #2  
anup        

RE: can we declare class as private?what will ha...

Hi

We can declare class as private. Only top level class can't be private.

public class PrivateClassTest {

private class PrivateClass{

}}


 
Is this answer useful? Yes | No
March 13, 2006 00:36:30   #3  
madhavendra        

RE: can we declare class as private?what will ha...

we can declare java class as private . But the tat class wont b accesslible from its outer scope like

public class B{

// member variables and methods

private class C{

// member variables and methods

}

}

now the prob wid dis is only the members of class B can access dis class C

and by OOP design we want more reusability of code which cant b possble in dis case


 
Is this answer useful? Yes | No
March 15, 2006 16:28:57   #4  
james        

RE: can we declare class as private?what will ha...

A class cannot be declared private


 
Is this answer useful? Yes | No
March 16, 2006 04:20:26   #5  
asheeshbarua Member Since: March 2006   Contribution: 4    

RE: can we declare class as private?what will ha...

A class can be declared as Private

A nested class that can only be accessed inside the class in which it is defined.


 
Is this answer useful? Yes | No
April 06, 2006 09:47:29   #6  
vikas sahu        

RE: can we declare class as private?what will ha...

Hi all

We can use private protected static default only with inner class not with the outer class.


 
Is this answer useful? Yes | No
April 06, 2006 09:59:10   #7  
nrsankepally9@gmail.com Member Since: April 2006   Contribution: 1    

RE: can we declare class as private?what will ha...
no we can't declare class as private/protected but In INNER CLASS we can give class as private.............
 
Is this answer useful? Yes | No
April 19, 2006 13:31:40   #8  
Bimales Mandal        

RE: can we declare class as private?what will ha...
If a class is declared as private then no one can access the class.
 
Is this answer useful? Yes | No
August 25, 2006 09:56:54   #9  
Visitor        

RE: can we declare class as private?what will ha...
Not true the class can be accessed by an outer-class.
 
Is this answer useful? Yes | No


 
Go To Top


 Sponsored Links

 
About Us -  Privacy Policy -  Terms and Conditions -  Contact -  Ask Question -  Propose Category -  Site Updates 

Copyright © 2005 - 2009 GeekInterview.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape