File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/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


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
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 !
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Question from mock exam....
 
Similar Threads
difference between static and final method
Mock Exam Q
Are my answers correct ?
Marcus Mock3 Q17
Urgent ..one more Thread ....