• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

Which of the lines fail to compile and why?

 
Ranch Hand
Posts: 36
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Given:


Which of the lines will fail to compile?


I don't understand this one. Can someone explain with another example. thank you again for helping
 
Marshal
Posts: 6851
470
Mac OS X VI Editor BSD Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you use any book as a resource? What's written there there you don't understand about this topic?

I think would be quite difficult to use some other example not knowing more precisely what you actually don't understand.
 
Niall Kev
Ranch Hand
Posts: 36
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes I have read the Jeanne Boyarsky book. Maybe points aren't sinking in. From the above after reading the answer, I see you can't call static methods with Classname.static method?
 
Liutauras Vilda
Marshal
Posts: 6851
470
Mac OS X VI Editor BSD Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Niall Kev wrote:From the above after reading the answer, I see you can't call static methods with Classname.static method?


No. You can, but method needs to be static, which isn't the case in your specified snippet.
 
Niall Kev
Ranch Hand
Posts: 36
1
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
so StaticTest.m1(); and StaticTest.m3(); fail because they are not calling static methods? simple as that?
 
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
line no 3 and line no 7 fails to compile because they are non static and also remember if you remove the error lines you will still get StackOverflowerror because method calling itself...
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!