• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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: 9708
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.
 
I found some pretty shells, some sea glass and this lovely tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic