Get the tools you need to learn Java skills fast!
Video tutorials, eBooks, hands-on lab exercises, sample code.
Get started
The moose likes Beginning Java and the fly likes Extending a class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of The Software Craftsman this week in the Agile forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Extending a class " Watch "Extending a class " New topic

Extending a class

jose chiramal
Ranch Hand

Joined: Feb 12, 2010
Posts: 266
How many ways can we extend a class ?

Can i say that we can extend a class in two ways :
1. using extends
2. using anonymous inner class
Devaka Cooray
ExamLab Creator
Saloon Keeper

Joined: Jul 29, 2008
Posts: 3389

You can extend an exception class as the same way as you extend any other class.
An anonymous inner class implicitly extends another class - so it can be used.

Author of ExamLab ExamLab - a free SCJP / OCPJP exam simulator
What would SCJP exam questions look like? -- Home -- Twitter -- How to Ask a Question
Lalit Mehra
Ranch Hand

Joined: Jun 08, 2010
Posts: 384

@ jose

yes ofcourse you can extend a class using extends ...

anonymous innner classes serve as an implicit datatype for the class they are constructed in ... having access to all its (data/method) members.
It is sorta covered in the JavaRanch Style Guide.
subject: Extending a class