aspose file tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes modifiers question from dan's exam Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Reply Bookmark "modifiers question from dan Watch "modifiers question from dan New topic
Author

modifiers question from dan's exam

anushree ari
Ranch Hand

Joined: Sep 30, 2002
Posts: 98
hi,
class Z {
void m1() {
abstract class A {} // 1
final class B {} // 2
private class C {} // 3
protected class D {} // 4
public class E {} // 5
static class F {} // 6
synchronized class G {} // 7
transient class H {} // 8
volatile class I {} // 9
strictfp class J {} // 10
}
}
Which of the follow class declarations results in a compiler error?
ans is 3,4,5,6,7,8,9,
synchronized,volatile,transient are field modifiers, so 7,8,9, correct, but why? 3,4,5,6.
anybody correct me?
thx


anushree
Jamal Hasanov
Ranch Hand

Joined: Jan 08, 2002
Posts: 411
Hi, Anushree
The reason is :
Inner Classes inside methods(local classes) may not be declared as private, public, protected, or static(jNotes)
All this classes are inside m1() method.

Regards,
Jamal Hasanov
www.j-think.com
Jose Botella
Ranch Hand

Joined: Jul 03, 2001
Posts: 2120
private, public, protected and static are not applicable to local variables either. They make no sense within a method because the local variables are not accesible from outside the method. Thus, why trying to specify the access modifiers or static.


SCJP2. Please Indent your code using UBB Code
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: modifiers question from dan's exam
 
Similar Threads
AccessModifiers and Access Specifiers
modifiers that are not possible for the members in an interface?Reason
valid combinations of Modifiers like static,native,transient etc
What's NOT In The Exam
what are all the modifiers in java...