link one

link one

link one

link one

link one

link one

3.1 - Data Abstraction

Abstraction is related to the concepts in philosopy. For example, we have a notion, that is a concept of an horse, but in the nature we can see different horses, different in color, in height, in speed, their properties are different but they fit to the general concept of the horse, abstracted by the horse definition. Abstract data type is also similar. A data type with predefined properties is defined to fit many objects, all of them have same properties but the values of these properties may be different. Data abstraction associates a data type with a set operations which may be performed on that data type.

Data abstraction is while keeping application information visible, hiding implementation details from the programmer, so it can focus to the useful tasks and not disturbed by the low-level implementation details. For example, we are using addition operator without knowing how this operator is implemented to the machine.

In object oriented programming, abstraction is providing some objects which can communicate each other, changing their state, perform useful work, receive data and report results. Thay may be considered as the actors acting according to a definite scenario.

3.2 - Encapsulation

Encapsualtion or Information Hiding, is keeping working steps away and hided from the exterior. Only data is received from and results are supplied to the external medium. You may keep private the way you use to obtain a particular problem and only communicate the results.

3.3 - Polimorphism

Polimorphism is a special case of abstarction. In abstarction only one type data may use specific methods. When the same methods may be used with different types of objects we say that the method is polimorphic, that is , it may serve to the different types of objects. Motto of the polimorphism: One method many objects

3.4 - Inheritance

Inheritance is the ability of child objects inheriting fields and methods from their anchestors. This is an advantage f or getting the some functionalities without the need for defining the fields and methods already defined in parent classes. The advantage of inheritance is subtle. It allows to build multilevel hierarchical data types very useful in corporate data. We'll cover inheritance very soon.


3.5 - Objects

Objects are the concrete instances of some abstract definition. We define a class Motor but there is not anything in the world such a thing. There is ChevroletMotor a physical object conforming to the definition (abstraction) of the motor but it is physical object that you can touch. There are also Toyota or Nissan motors, they are all conform to the definition of the abstract class motor, but they are all different from each other. Software objects are also the same, they are created to represent some physical objects, found in the physical world, according to an abstract definition covering this material type. Software objects are instances created according the recipe defined in their class definition. Classes define the structure of the objects. All the objects originated from same class have identique properties set by the class definition. The properties of the object instances defined in the class structure may consist every available language elements, namely variables and functions which are called methods in Java.

Every object has an internal state. This state can be invoked or set by messages to that object. Messages are sent or invoked by the dot operator in Java (as well as most of the programming languages). For a property having single value, this message is simply:;

For a method requiring no arguments, this will be:


For a method requiring arguments.

object.method(arg1[,arg2, arg3, argn]);

3.5 - Methods

Java is a native object oriented programming language and do not allow independent standalone functions The functions of Java is embedded in classes and named methods. Using Java methods is the same as in the similar programming languages.

The mechanism of the method is simple. Every method is described by so called formal parameters, most of the time aliased as parameters. Function parameters are rather definition terms about the functioning of the method . In Java, method names are chosen as beginning with lowercase characters by convention.

Java methods labelled as void can make useful work and return no value. They can for example print a predefined message when invoked. For example the the method below, is designed to display a "Merry Christmas And Happy New Year !" message when called:

void merryChristmas () {
System.out.println("Merry Christmas And Happy New Year !");

This method return no value and receive has no parameter. But, void methods also may have parameters. The method below act as a voice of the owner, it say anything you tell for saying:

void tellThis (String message) {

The things has changed now. The method has a parameter. Actually that is a blueprint on what will be realised when it is called with a real world arguments. The layout of this method may be read as, "display any String data type supplied as the argument of this method ! ". O.K. we will do what it says, we call this method either with string literal or with a string variable. Both the cases is presented below:

String myMessage = "Greetings !";
tellThis (myMessage);

or ,

tellThis ("Greetings!");

Not all the methods are void methods of course, some of them are intended to return some results. In Java all the variables have a data type, so the data returned from the function has also a type. Since the return value of the method may be assigned to a variable of the same type, every metdod which is non- void have a type that they return. The return type of the method is signalled in the function declaration step like the example shown below, which accepts two double arguments and return the result of their multiplication in type double .

 double multiply ( double  r,  double  s) {
return r * s;

This method may be invoked by two variables of data type double or by two numeric literal of data type double ( default types of numeric literals in Java). Invocations of this method is illustrated below:

double width = 22.56;
double length = 38.77778;
double area = multiply(width, length);


multiply( 11.89 / 34.55 , 127.5535 / 46.78);

The mystique on the main() method that we are using all the time may be partly enlighted. The arguments of main() method , String[] args are nothing than an array of Strings named args. Since arrays are objects, we will cover them after we have introduced basic informations about objects.

<< Index

Polyglott HTML5(XHTML5 compliant HTML5 code)