• 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

generics... page 598

 
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi... can anybody tell me what is super doing in this code at line 1 2 3 4... thanks...



[ May 25, 2008: Message edited by: sweety singh ]
[ May 25, 2008: Message edited by: sweety singh ]
 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi singh,

Please try to write up the correct code next time... there are way too many typos... Also make sure you use Java style curly braces for classes, methods , and code blocks.

Anyway, assuming I can guess the missing characters the following should answer your questions:

on 1: The subclass is simply calling the super classes constructor which is
Since List<Car> IS-A list you may pass it.

on 2: The subclass is simply calling the super classes implementation of the getRental() method. If you omit the "super" part you will find yourself in an infinite loop because the getRental() method in CarRental will call itself over and over and over again.

on 3: exactly the same as #2.

on 4: exactly the same as #2 & #3.

If you're familiar with c#, for example, then super is identical to c#'s base.

I would like to point out once more that your code is really bad. You should use an IDE (like eclipse) to format, debug, run, and test your code before submitting it to this forum in the future.

hope that helped.
 
author
Posts: 9050
21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Guys,

Well I agree...partly

I do agree that everyone should format their code properly before posting it here. If you go to the JavaRanch main page you'll find a link to the "Chicken Coop" and there you will find the code formating standards preferred by "most" of the moderators around here. You don't have to use that particular formatting style, there are others in common use, but you SHOULD pick one of the common styles.

As far as using IDEs goes - there I'd have to disagree! We strongly encourage SCJP candidates to NOT use an IDE for studying. It's too easy for IDEs to hide crucial information! I can tell you that the entire team of experts that created the exam, did so without using an IDE.

hth,

Bert

p.s. Once you're an official SCJP, go ahead and crank up that IDE
reply
    Bookmark Topic Watch Topic
  • New Topic