This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Marcus Exam 2 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 "Marcus Exam 2" Watch "Marcus Exam 2" New topic
Author

Marcus Exam 2

Hassan Naqvi
Ranch Hand

Joined: May 03, 2001
Posts: 158
Hello Friends,
I can't understand the philosphy of Marcus(Infact JVM) for the following question.

Ans: Compile time error
Explanation:
You will get an error saying something like "Cant make a static reference to a non static variable".
Note that the main method is static. Even if main was not static the array argv is local to the main
method and would thus not be visible within amethod.
Regards,
Hassan.


Always Belive On Logic!!
Rashmi Hosalli
Ranch Hand

Joined: Jun 25, 2001
Posts: 50
Hassan,
What is that you did not understand here?As the explaination goes,argv[] is of course local to the main method and amethod can access MyArg but not argv[].Also since MyArg[] is non static,you cannot access it directly without creating an instance of the class Arg.
Rashmi
Hassan Naqvi
Ranch Hand

Joined: May 03, 2001
Posts: 158
Got it!!
Ashik Uzzaman
Ranch Hand

Joined: Jul 05, 2001
Posts: 2370


argv is a local variable only accessible within main method!

------------------
azaman


Ashik Uzzaman
Senior Member of Technical Staff, Salesforce.com, San Francisco, CA, USA.
 
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: Marcus Exam 2
 
Similar Threads
method call
Please explain these answers
Interpreting Question
Why does this fail? I don't quite understand.
static reference