top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration Why to Join

Facebook Login
Site Registration

Define important terms related to Object Oriented Programming?

0 votes
Define important terms related to Object Oriented Programming?
posted May 10, 2014 by anonymous

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

Object Oriented Terms:--b(wiki)

Abstraction: Definition:
The ability to represent a complex reality in terms of a simplified model. Abstraction is not limited to OOP. It is used in procedural languages in top down step-wise refinement and through the use of subprograms, functions, etc. An example of an abstraction is the MOVE command in COBOL. While the MOVE may seem like a concrete statement, it truly is abstract. By MOVEing A-VAR to B-VAR, COBOL is required to do all of the editing, alignment, and error checking to be sure it is legal and to handle fields of dissimilar lengths and types.

Java Implementation:
Java implements abstraction through the class. The methods in the class provide an interface between the complex operations of realizing the model and the simple messages (returned values from a method) sent from the class.

The ability to "hide" the implementation and the data stored in an object. This protects programs from the "side-effects" of unwanted changes. The Input-Process-Output (IPO) chart is a good example of encapsulation. The Input and Output represent the interface but the process itself and any variables (other than the Input and Output variables) are considered to be local. Local variables altered in the process are separate from local variables in another process, even though they may share the same name . Since variables are declared in the Data Division of a COBOL program, they are global (not local) and are available to all paragraphs in the program. This makes variables in a program susceptible to alteration in a paragraph where they are not intended to be.

Java Implementation:
Java provides the modifier private, this means that the data or method may only be accessed within the class. You may wonder if private affects inheritance. The answer is yes, if you wish to have private components inherited then the java term protected is used. protected means that the component can only be accessed by this class and any subclasses of this class.

Inheritance Definition:
The ability to "add on" to a class, additional components and/or to "override" certain components of the class we are inheriting from to create a more specific model. Suppose we created a person class. The person could be refined to be a student by adding student characteristics and functions. Since a person may be defined to have a name, address, age, etc., we could now say that a student is a person who attends a school, has a GPA, major etc.

Java Implementation:
When a java class is defined with the extends classname clause. This indicates that we wish to add more variables or methods to make this class more specific to our needs without rewriting all of the extended class's variables and methods. If methods need to be changed in the inheriting class we may override the methods. In order to override and existing method it must have the same method name, return type, and the same number of parameters, in the same order and same type as the original method.

Multiple inheritance Definition:
The ability to inherit and refine from more than one class. Using the person-student inheritance example (from inheritance above), we can also add that a person is also an employee and has employee functions as well. In this case the student inherits both person and employee characteristics/functions.

Java Implementation:
By defining a class with the implements interfacename. May also be used with the extends classname. An interface is similar to a class but contains only abstract methods (methods which do not have a body, but do contain the prototype or interface). abstract methods must be given a body by the inheriting class. By writing the body in the subclass rather than in the interface this avoids the possible confusion of inheriting two methods with the same name and interface but different implementations.

Polymorphism Definition:
Literally "many forms", this powerful feature allows us to have the same method take on different meanings depending on which class is instantiated. An example might be an abstract idea called a shape. The shape could have two characteristics: area and perimeter. There could be two type of shapes (inherited) called circle and square. We would indicate in the shape class, that there are two values to be determined, area and perimeter. The first determining a value indicating the number of square inches and the other inches. Since I don't know what shape it is I cannot tell you the equation for the area or the perimeter. I will leave those details out. When I create a class of circles, I do know how to calculate the area and perimeter of a circle and can now provide these details to the appropriate functions. The same goes when I create a class of squares. Since both circles and squares are inherited from shapes they are considered part of the shapes class and can be thought of as such. When I ask for the area of a shape, through polymorphism, the type of shape will be determined and the correct area calculated. Polymorphism has two implementations: inherited polymorphism, which occurs through inheritance and overriding; ad hoc polymorphism, which occurs between multiple class structures.

Java Implementation:
Usually through the invocation of an array of superclass objects that contain subclass elements (inherited polymorphism). Since the superclass will have an abstract method, the "details" of the method are left to the subclasses. Thus when an abstract method is called in the superclass, Java must look at the subclass for "how" to implement the method. Since each of the subclasses will have their own implementation, the way the method works internally will be different, yet the returned type will be of the same type for all of the objects.

answer May 16, 2014 by Vrije Mani Upadhyay
Contact Us
+91 9880187415
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Karnataka INDIA.