Java Programming Basics: Object Orientation
by
Gurunath Kalamadi
When learning Java, your understanding of basic concepts has to be sound. In particular, I have identified a set of five concepts that any Java professional must understand to be successful:
- Object orientation
- Runtime Polymorphism
- Interfaces
- IO Streams
- Event Handling
In a series of articles titled Java Programming Basics, I take up each of these concepts individually to provide beginners (as well as experienced software engineers wanting to diversify their skill set) with a strong foundation of basic Java knowledge through compact explanations and practical examples. This first article in the series covers object orientation.
The Basics of Object Orientation
For a Java beginner, it is imperative to understand the concept of object orientation completely. The tenets of object orientation are encapsulation, polymorphism and inheritance. Encapsulation is binding the data of a class to the methods of the class, so that "private" data can be accessed only through "public" methods.
Polymorphism is a mechanism by which a generic operation can be implemented to work on different types of data. Polymorphism enables the programmer to define and use multiple implementations for the same method name, provided these implementations result in different signatures. For example, method overloading is compile-time (static) polymorphism.
Central to the understanding of polymorphism is the notion of method signatures (also known as mangled names). A method signature consists of the method name and types of its parameters. (Return type is not a part of the signature.) The following table breaks down the notion of method signature.
| Sl No |
Method Prototype (specified by the developer) |
Method Signature (deduced by the compiler) |
| 1. |
int max(int num1, int num2) |
max_int_int |
| 2. |
int max(int num1, int num2, int num3) |
max_int_int_int |
| 3. |
int max(int[] iArr, int n) |
max_int[]_int |
The programmer specifies the prototypes and implementations. The compiler deduces the method signature from a method call and seeks an implementation that has the matching signature to resolve the call.
New on the Java Boutique:
New Review:
Time Management Made Easy with the Quartz Enterprise Job Scheduler
Why not just use the Java timer API? This open source scheduling
API boasts simplicity, ease-of-integration, a well-rounded feature
set, and it's free!
New Applet:
Reverse Complement
Reverse Complement is a simple applet that converts DNA or RNA
sequences into three useful formats.
Elsewhere on internet.com:
WebDeveloper Java
Lots of Java information on webdeveloper.com
WDVL Java
Thorough Java resource at the Web Developer's Virtual Library.
ScriptSearch Java
Hundreds of free Java code files to download.
jGuru: Your View of the Java Universe
Customizable portal with online training, FAQs, regular news updates, and tutorials.