• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

only static methods can access static members

 
Ankur kothari
Ranch Hand
Posts: 531
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
...is this true or false?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65118
91
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What happened when you tested this?
 
Ankur kothari
Ranch Hand
Posts: 531
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i didnt test it...its a question from mughals book...its says the above sentence is false.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65118
91
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Go ahead and test it, we anxiously await your results.
 
Ankur kothari
Ranch Hand
Posts: 531
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 65118
91
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When you test it, you will find that the statement is indeed false.
 
Ankur kothari
Ranch Hand
Posts: 531
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how? gimme an example
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65118
91
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 531
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok....u mean non static methods can access static members...i will try it
 
Ankur kothari
Ranch Hand
Posts: 531
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 65118
91
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bingo
 
Ankur kothari
Ranch Hand
Posts: 531
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks
 
Atwal Usha
Ranch Hand
Posts: 137
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The statement is false as static members can be accessed from within non static as well as static context.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic