| Author |
only static methods can access static members
|
Ankur kothari
Ranch Hand
Joined: Sep 06, 2009
Posts: 531
|
|
|
...is this true or false?
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56205
|
|
|
What happened when you tested this?
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
Ankur kothari
Ranch Hand
Joined: Sep 06, 2009
Posts: 531
|
|
|
i didnt test it...its a question from mughals book...its says the above sentence is false.
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56205
|
|
|
Go ahead and test it, we anxiously await your results.
|
 |
Ankur kothari
Ranch Hand
Joined: Sep 06, 2009
Posts: 531
|
|
|
i know that only static methods can access static members....non static methods cant access them..then why is the above sentence false.
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56205
|
|
|
When you test it, you will find that the statement is indeed false.
|
 |
Ankur kothari
Ranch Hand
Joined: Sep 06, 2009
Posts: 531
|
|
|
how? gimme an example
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56205
|
|
|
No one is here to do your work for you. Write an example yourself and you will see that your assumption is incorrect.
|
 |
Ankur kothari
Ranch Hand
Joined: Sep 06, 2009
Posts: 531
|
|
|
ok....u mean non static methods can access static members...i will try it
|
 |
Ankur kothari
Ranch Hand
Joined: Sep 06, 2009
Posts: 531
|
|
|
oh..i got it....static members can be accessed by non static and static methods....but static methods cannot access non static members
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56205
|
|
|
Bingo
|
 |
Ankur kothari
Ranch Hand
Joined: Sep 06, 2009
Posts: 531
|
|
|
thanks
|
 |
Atwal Usha
Ranch Hand
Joined: Sep 10, 2009
Posts: 137
|
|
|
The statement is false as static members can be accessed from within non static as well as static context.
|
Java Certification Exam Mock Tests: SCJA SCJP 5 SCJP 6 SCJP 6 (Online Training) SCJP 6 (Instructor Led Training) SCWCD 5 SCBCD 5 SCEA 5
|
 |
 |
|
|
subject: only static methods can access static members
|
|
|