23.11.2017 Views

java_tutorial

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Java<br />

File Class ...................................................................................................................................................... 262<br />

Directories in Java........................................................................................................................................ 272<br />

Listing Directories ........................................................................................................................................ 273<br />

19. Java – Exceptions .................................................................................................................................. 274<br />

Exception Hierarchy..................................................................................................................................... 275<br />

Built-in Exceptions ....................................................................................................................................... 276<br />

Exceptions Methods .................................................................................................................................... 278<br />

Catching Exceptions ..................................................................................................................................... 279<br />

Multiple Catch Blocks .................................................................................................................................. 280<br />

Catching Multiple Type of Exceptions ......................................................................................................... 281<br />

The Throws/Throw Keywords ..................................................................................................................... 281<br />

The Finally Block .......................................................................................................................................... 282<br />

The try-with-resources ................................................................................................................................ 284<br />

User-defined Exceptions .............................................................................................................................. 286<br />

Common Exceptions .................................................................................................................................... 289<br />

20. Java – Inner Classes ............................................................................................................................... 290<br />

Nested Classes ............................................................................................................................................. 290<br />

Inner Classes (Non-static Nested Classes) ................................................................................................... 291<br />

Accessing the Private Members .................................................................................................................. 292<br />

Method-local Inner Class ............................................................................................................................. 293<br />

Anonymous Inner Class ............................................................................................................................... 294<br />

Anonymous Inner Class as Argument .......................................................................................................... 295<br />

Static Nested Class....................................................................................................................................... 296<br />

JAVA - OBJECT ORIENTED ........................................................................................................ 299<br />

21. Java – Inheritance ................................................................................................................................. 300<br />

extends Keyword ......................................................................................................................................... 300<br />

Sample Code ................................................................................................................................................ 300<br />

The super keyword ...................................................................................................................................... 302<br />

Invoking Superclass Constructor ................................................................................................................. 305<br />

IS-A Relationship .......................................................................................................................................... 306<br />

The instanceof Keyword .............................................................................................................................. 308<br />

HAS-A relationship ....................................................................................................................................... 309<br />

Types of Inheritance .................................................................................................................................... 309<br />

22. Java – Overriding .................................................................................................................................. 311<br />

Rules for Method Overriding ....................................................................................................................... 313<br />

Using the super Keyword ............................................................................................................................ 314<br />

23. Java – Polymorphism ............................................................................................................................ 315<br />

Virtual Methods ........................................................................................................................................... 316<br />

24. Java – Abstraction ................................................................................................................................. 320<br />

Abstract Class .............................................................................................................................................. 320<br />

Inheriting the Abstract Class........................................................................................................................ 323<br />

Abstract Methods ........................................................................................................................................ 324<br />

vii

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!