Java Programming - Declarations and Access Control - Discussion
Discussion Forum : Declarations and Access Control - General Questions (Q.No. 7)
7.
Which of the following is/are legal method declarations?
- protected abstract void m1();
- static final void m1(){}
- synchronized public final void m1() {}
- private native void m1();
Answer: Option
Explanation:
All the given statements are legal declarations.
Discussion:
14 comments Page 1 of 2.
Sainath said:
1 decade ago
Can you explain it in detail?
Vinu said:
1 decade ago
Can any one explain ?
Sush said:
1 decade ago
Please anyone explain it?
Rocks said:
1 decade ago
What is the working of synchronize and native?
Adrian said:
1 decade ago
Synchronize and native works because synch blocks the execution of other methods on the same class (for the duration of the method). Maybe the native method wants to modify a shared resource.
Venkat said:
1 decade ago
1. protected abstract void m1();
Is correct because abstract method may be implemented in subclass and protected allows it to do so.
2. static final void m1(){}
Is also correct because final does not allow method to be changed and static does not user to another method with same name.
3. synchronized public final void m1() {}
It allow only one instance of method to be executed at a time.
4. private native void m1();
It allows method written in another programming language to be executed in java
Is correct because abstract method may be implemented in subclass and protected allows it to do so.
2. static final void m1(){}
Is also correct because final does not allow method to be changed and static does not user to another method with same name.
3. synchronized public final void m1() {}
It allow only one instance of method to be executed at a time.
4. private native void m1();
It allows method written in another programming language to be executed in java
Chandra Bhushan said:
1 decade ago
But as I can see the question is asked for declaration only and not the definition of function.
Limia said:
1 decade ago
Shouldn't access specifiers like public, private and protected be the first words in a declaration statement? Please correct me if I'm wrong, I read this somewhere.
Manohar said:
1 decade ago
static final void m1(){}
Can anyone explain it clearly?
Can anyone explain it clearly?
Kaustubh Kaley said:
1 decade ago
Why are {} specified in the declaration?
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers