aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Question from mock exam.... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Question from mock exam...." Watch "Question from mock exam...." New topic
Author

Question from mock exam....

Tony Sam
Ranch Hand

Joined: Nov 19, 2001
Posts: 32
here is the question:
Which of the following statements are true?
1) static methods do not have access to the implicit variable called this
2) A static method may be called without creating an instance of its class
3) A static method may not be overriden to be non-static
4) A static method may not be overloaded
i think ans may be 2) and 3) , but the correct ans is 1),2) and 3) , could somobody here explain this?
i think snippet below is correct:
static int i;
static int method(){
return this.i;
}
so why 1) is true?


Tony Sam<BR>One want to be a SCJP...
Simeon Shi
Ranch Hand

Joined: Dec 09, 2001
Posts: 35
hi,Tony...
have u ever tried the snippet? the compiler will also complain
"non-static variable this cannot be referenced from a static context". just like a static class which can be referred without
the instance of itself,a static method can also be called without the instance of the class containing it.so...a static method is not "bound" to the class.so,the "this" could not be used coz of this specific.

Vikrama Sanjeeva
Ranch Hand

Joined: Sep 02, 2001
Posts: 756
Originally posted by Tony Sam:
here is the question:
Which of the following statements are true?
1) static methods do not have access to the implicit variable called this
2) A static method may be called without creating an instance of its class
3) A static method may not be overriden to be non-static
4) A static method may not be overloaded
i think ans may be 2) and 3) , but the correct ans is 1),2) and 3) , could somobody here explain this?
i think snippet below is correct:
static int i;
static int method(){
return this.i;
}
so why 1) is true?

Yes 1,2,3 are true
For confirmation you may try this code

Bye.
Viki.

------------------
Count the flowers of ur garden,NOT the leafs which falls away!


Count the flowers of your garden, NOT the leafs which falls away!
Prepare IBM Exam 340 by joining http://groups.yahoo.com/group/IBM340Exam/
Tony Sam
Ranch Hand

Joined: Nov 19, 2001
Posts: 32
Okay, i got it !
Thanks Simeon and Vikrama !
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Question from mock exam....