Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


can we declare private class in java file?

Answers were Sorted based on User's Feedback



can we declare private class in java file?..

Answer / 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

can we declare private class in java file?..

Answer / manoj purohit

•Only nested classes can be private. If a top-level class
were private, nothing could access it.

So, private nested classes are just like other private
members (methods and variables)--they can only be
accessed "within the body of the top level class that
encloses the declaration of the member or constructor"

Private classes are to be used only by their declaring
class (more or less) just like other private members

Is This Answer Correct ?    117 Yes 2 No

can we declare private class in java file?..

Answer / ravikiran

No for the outer class and we can declare it for the inner
class.

Is This Answer Correct ?    59 Yes 4 No

can we declare private class in java file?..

Answer / shreya sarker

Within a static method,we can only call another static
method.Is it true?

Is This Answer Correct ?    29 Yes 13 No

can we declare private class in java file?..

Answer / prasanthi

yes,but it is declare to inner class,not to outter class.if we are declaring "private" to outter class nothing can be accessaed from that outter class to inner class.

Is This Answer Correct ?    15 Yes 3 No

can we declare private class in java file?..

Answer / honey

main class can not be make private in java ,only the nested class can be make privateand it can be assessable only in the main class not access by any other class in the package.

Is This Answer Correct ?    13 Yes 3 No

can we declare private class in java file?..

Answer / eonsimi

nested classes can be decalred as private and they can be accessed by its siblings and by their parent.

Is This Answer Correct ?    11 Yes 2 No

can we declare private class in java file?..

Answer / sankesh sinha

yes it occur when class is inner, top level class not be
private bcoz jvm will not able to compile.

Is This Answer Correct ?    9 Yes 5 No

can we declare private class in java file?..

Answer / eknath wagadre

private and static keyword in java we can't use those
keyword any of the outer block. we can use those keyword
only and only inside of the block.(Block i.e Class )

NOTE: Outer class can't be private but inner class can be
private(bcz of this is the part of the outer class and also
inner class can be static.)

Is This Answer Correct ?    1 Yes 0 No

can we declare private class in java file?..

Answer / veerendra

yes,we can declare if it is inner most class, but outer
class is not allowed because java supports inheritance
concept for reusing the properties from super class to sub
class,at that time the super class is private it wont access
inside,only public features we can reuse it, we can access
and execute through out the world, not private with in the
class onle we can access it.

Is This Answer Correct ?    1 Yes 0 No

Post New Answer

More Core Java Interview Questions

what is static import in java? Explain

0 Answers  


How do you declare a destructor in java?

0 Answers  


What’s the difference between unit, integration and functional testing?

0 Answers  


Name the package that always imported by default?

4 Answers  


How to create a custom exception?

0 Answers  


Can we override singleton class?

0 Answers  


Hi Friends, I am beginner in java. what i know about synchonized keyword is,If more that one 1 thread tries to access a particular resource we can lock the method using synchronized keyword. Then after that how the lock is released and how next thread access that.Please explain with example.

5 Answers  


What is tcp ip in java?

0 Answers  


Can we create an object of static class in java?

0 Answers  


What is constructor chaining and how is it achieved in java?

0 Answers  


What about anonymous inner classes in java?

0 Answers  


What happens if we override private method?

0 Answers  


Categories