CHAPTER-1(Introduction to Java)                                              BOTTOM  



What is oops

Oops stands for objects oriented programming. In oops we divide our program on the basis of real world objects rather than using procedures, which we have used in “C” and other non-object programming language. In procedural language we describe our program into a series of steps. The disadvantage of this approach is that if any problem or error occurs in our program the entire program stops working, which is not the case in oops where if one section stops working, the other part of program can continue its work. Object oriented programming is useful where the complexity of the program increases which is difficult to manage in procedural languages. In Object oriented programming we divide our program into classes and interfaces and access them through objects and references.


Feature of object oriented programming: -


There are four basic principles of Oops:-

1. Abstraction.
2. Encapsulation.
3. Inheritance.
4. Polymorphism.


Abstraction:-Abstraction is an essential element of oops .In abstraction we manage the complexity of our program. An abstraction denotes the essential properties and behavior of an object. Properties are attributes, which are defined by fields or variables in java, and behavior is defined by the methods or functions. We manage the complexity of the program through classes and objects.

Example: -

We take an example of a car. From outside it is a single object but form inside the car is divided into  several subsystems. Like brakes , sound system , steering and so on . The user ( in this case driver) need not know about the internal knowledge of the car which is abstract from him . So we can say that the user or client using the car is concerned with what should be done and not how it should be done. Abstraction is used to hide the details of the class.

Encapsulation:- Encapsulation is used to bind together code and date it manipulates. It is used to provide the safety to the code and data from outside interference. Encapsulation Is provides through class which acts as protective wrapper that prevents the code and data from being accessed by other code outside the class.

Through Encapsulation, we emphasize that to what extent the data can be accessed by outside code with the help of accessibility modifiers like private , public etc The basis of encapsulation is the class in which we define the scope of the members of the class .  In class we also define the complexity of the program ,so we can  say that the abstraction is done through encapsulation. In short Encapsulation is basically used to define the scope of the members of the class.

Example: -

Consider the automatic transmission on an automobile. It encapsulates hundreds of bits of information about your engine,
such as how much you are accelerating, the pitch of the surface you are on, and the position of the shift lever. You, as the user, have only one method of affecting this complex encapsulation: by moving the gear-shift lever. You can’t affect the transmission by using the turn signal or windshield wipers, for example. Thus, the gear-shift lever is a well-defined (indeed, unique) interface to the transmission. Further, what occurs inside the transmission does not affect objects outside the transmission. For example, shifting gears does not turn on the headlights! However, from the driver’s point of view, they all work the same.

Inheritance: - Inheritance is the property of oops in which one object or class acquires the properties of another object or class.It is the process through which we manage the hierarchy of our program. Inheritance is the fundamental mechanism of code reuse in oops. Through Inheritance we can derive new classes from an existing classes. The new derived class can inherit features members from the old (parent) class . The subclass or derived class can add new features And modify its inherited features. Inheritance is related to encapsulation in the sense that it inherits only those members, which are also accessible outside of super or parent class.

Figure- showing Inheritance

From the above figure we can say that mammals are simply more precisely specified animals, they inherit all of the attributes from animals. A deeply inherited subclass inherits all of the attributes from each of its ancestors in the class hierarchy.

Polymorphism: -

Polymorphism is another important concept of oops, which describes one name but different forms . The concept of polymorphism is expressed by the phrase “ one interface multiple methods”. This means that we define a generic method to a group of related activities. This helps in reducing complexity.

Consider an example of polymorphism , a dog’s sense of smell is polymorphic , if a dog smells a cat it will bark and run after it .If the dog smells its food then it will run to its bowl . The same sense of small is at work in both situations. The difference is the nature of data being operated upon dog’s nose. We implement polymorphism through overloading and method overriding.


1.C++ supports pointers whereas Java does not pointers. But when many programmers questioned how you can work without pointers, the promoters began saying "Restricted pointers.” So we can say java supports Restricted pointers.

2.At compilation time Java Source code converts into byte code .The interpreter execute this byte code at run time and gives output .Java is interpreted for the most part and hence platform independent. C++ run and compile using compiler which converts source code into machine level languages so c++ is plate from dependents.

3.Java is platform independent language but c++ is depends upon operating system machine etc.

4.Java uses compiler and interpreter both and in c++ their is only compiler.

5.C++ supports operator overloading ,multiple inheritance but java does not.

6.C++ is more nearer to hardware then Java

7.Everything is an object in Java (Single root hierarchy as everything gets derived from java.lang.Object).

8.Java does is a similar to C++ but not have all the complicated aspects of C++ (ex: Pointers, templates, unions, operator overloading, structures etc..).Java does not support conditional compile (#ifdef / #ifndef type).

9.Thread support is built-in Java but not in C++.

10.Internet support is built-in Java but not in C++.

11.Java does not support header file, include library files just like C++ .Java use import to include different Classes and methods.

12.Java does not support default arguments like C++.

13.There is no scope resolution operator “:: “in Java.

14.There is no "goto " statement in Java.

15.Exception and Auto Garbage Collector handling in Java is different because there are no destructors into Java.

16.Java has method overloading, but no operator overloading just like c++.

17.The String class does use the + and += operators to concatenate strings and String expressions use automatic type conversion.

18.Java support call by value only.

19.Java does not support unsigned integer.

Note :
After Successful completion of Training Candidate will be provided with Project Report and Training Certificate.

Home  |   FeedBack  |   Terms of Use  |   Contact Us  |   Report Error
Copyright © 2009 R.M Infotech (P) Ltd.                                             Designed by: Raman