• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

OCPJP Coding Exercises: Question 1h (Inner Classes)

 
Ranch Hand
Posts: 173
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Folks,


Sharing my solution to the coding exercises from the book 'Practice Exams' by Bert Bates and Kathy Sierra. This solution seems fine to me, do correct me if I am wrong or if there would be a better way of coding it. Hope like minded souls would find this post useful. I will be posting my solutions to the other questions as and when I complete them. Thank you.

Question 1.h

Create a class that has a static inner class and a method local inner
class. Make instances of each inner class. Create code that accesses the
inner classes’ members from the outer class. Create code that accesses the
outer class’s members from within the inner classes.




Result:
static inner class:go
method local inner class: Value of x in outer is FootballTeam

 
Sheriff
Posts: 9709
43
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You forgot to do this part: Create code that accesses the outer class’s members from within the inner classes.
 
We should throw him a surprise party. It will cheer him up. We can use this tiny ad:
Clean our rivers and oceans from home
https://www.kickstarter.com/projects/paulwheaton/willow-feeders
reply
    Bookmark Topic Watch Topic
  • New Topic