• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

about MMMMMModifiers-fires

 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
tell me which modifiers applicable to following
classes and interfaces,methods,construtors,


1.inner class
2.nested class
3.top level class
4.contrutors
5.methods
6.inside main()

7.anaonymous class
8.interfaces
9.static ,final ,abstract where to come

10 which modifiers to come both?

11.inside construtor {
mehod(//here which modifier will come)
{}
inner construtor{//tell we which modifier }

class xxxx{ //tell me which modifer will come}
}

12. with in parameter(//which modifier will come)
{//tell me if it is inside method,construtor,abstarct //
//tell me if it (Method inside class)
}


lot of confusion don't ask me to refer JLS
that also not able get in my mind.
 
Ranch Hand
Posts: 159
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1.inner class --> forgot hehe..some one add here please
2.nested class --> forgot hehe..some one add here please
3.top level class --> coderanch, default(no access modifier),abstract,strictfp,final(but never combine with abstract),abstract,etc(add here)

4.contrutors--> default,coderanch,protected,private
5.methods-->coderanch,protected,private(but not combine with abstract),default(no acc mod),abstract,final(not combine with abstract),synchronized(but never combine with abstract),native(not comb with abstract),static(but not with abstract),strictfp(not with abstract in combination), add here...

6.inside main()-->final modifier only, or array declaration, no static, no access modifier allowed in static or normal method.

7.anaonymous class --> haven't review...
8.interfaces -->
for constant : protected,private,transient,volatile is not allowed.
implicitly public static final(for constant).
for method within interface : --> only public and abstract is allowed because methods within interface is implicitly "public abstract"

9.static ,final ,abstract where to come
10 which modifiers to come both? -->
abstract static(not allowed)
abstract private(not allowed)
abstract final(not allowd)
abstract strictfp(not allowed)
abstract synchronized(not allowd)
abstract native(not allowd)
any thing elese add here...

11.inside construtor {
mehod(//here which modifier will come)
{}
inner construtor{//tell we which modifier }

class xxxx{ //tell me which modifer will come}
}

12. with in parameter(//which modifier will come)
{//tell me if it is inside method,construtor,abstarct //
//tell me if it (Method inside class)
} ???
 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Giribabu Venugopal,
here is a table under this link (Modifiers in Java)that might help you remember the modifiers.

I found this link very useful, when I was preparing for the SCJP Exam.

hope this helps!
cheers!
~ Rao
 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Inner classes:
-->can have PUBLIC,PRIVATE,PROTECTED,DEFAULT(No modifier)
-->But a static inner class can only access static variables or
methods of the outer class.It can't access non-static data of
outer class.
-->A final modifier declared inside a method,can be accessed by the inner class.Also,the inner class must be within that method.
--->Inner classes can have constructors and initializers
Anonymous classes:
-->cannot define any specific constructors
-->arguments in the constructors must be that of parent class
Bit about this... I think u cannot specify modifiers to anonymous classes.



and final static ---- allowed
final native ---- allowed

I could figure out this much....
 
Ranch Hand
Posts: 3271
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are you just trying to memorize these? Here's my bit of advice - don't. Actually try to understand what the modifiers mean and, in almost all cases, you can figure out what modifiers are applicable in any situation.

For example, does it make sense to have a final constructor? Of course not. Marking something as final means it can't be overridden - constructors aren't even inherited. Therefore, it makes no sense for a constructor to be final. Same goes for abstract constructors.

You see, you don't need to memorize this stuff if you just have a good understanding of what it all means.

By the way, learn to read the JLS. I know it's confusing at first and it can be quite overwhelming, but it's the best source on Java. Besides, a lot of the information you're asking about is written out, plain as day. For example, the stuff I was just mumbling about appears in the JLS, §8.8.3 Constructor Modifiers:


ConstructorModifier: one of
public protected private



It even goes on in more detail:


Unlike methods, a constructor cannot be abstract, static, final, native, strictfp, or synchronized. A constructor is not inherited, so there is no need to declare it final and an abstract constructor could never be implemented. A constructor is always invoked with respect to an object, so it makes no sense for a constructor to be static. There is no practical need for a constructor to be synchronized, because it would lock the object under construction, which is normally not made available to other threads until all constructors for the object have completed their work. The lack of native constructors is an arbitrary language design choice that makes it easy for an implementation of the Java virtual machine to verify that superclass constructors are always properly invoked during object creation.



The JLS is your friend. Get to know it.
 
Beny Na
Ranch Hand
Posts: 159
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Corey,
yes...you are absolutely correct Corey, i automatically remember them because i know what is all keywords mean/for. I don;t want to remember that keyword if i don;t know what it is for(that is a very bad idea), in case i/we remember all of them, then i can sure within 2-3 months, or in 2 weeks we will forgot everything...
learn the concept is better than memorizing...

By the way, i still have a problem with collection chapter for the exam next week, do you have any idea how to grasp the concept from this chapter.
and the thread chapter is quite hard..and i can't learn it within one/two week to get a good concept in order to solve complicated question.
if you could explain the concept or any good link that explain about thread it would be helful for my exam.

thanks
 
Corey McGlone
Ranch Hand
Posts: 3271
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Beny Na:
By the way, i still have a problem with collection chapter for the exam next week, do you have any idea how to grasp the concept from this chapter.
and the thread chapter is quite hard..and i can't learn it within one/two week to get a good concept in order to solve complicated question.
if you could explain the concept or any good link that explain about thread it would be helful for my exam.

thanks



Benny,

That's really off-topic from the original question of this thread. In order to keep discussions around here a little more "sane," I'd suggest posting your question(s) in their own thread.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic