answersLogoWhite

0


Best Answer

Java is an object oriented programming language. The main concepts used in Java are:

Class

Defines the abstract characteristics of a thing (object), including the thing's characteristics (its attributes, fields or properties) and the thing's behaviors (the things it can do, or methods, operations or features). One might say that a class is a blueprint or factory that describes the nature of something. For example, the class Dog would consist of traits shared by all dogs, such as breed and fur color (characteristics), and the ability to bark and sit (behaviors). Classes provide modularity and structure in an object-oriented computer program. A class should typically be recognizable to a non-programmer familiar with the problem domain, meaning that the characteristics of the class should make sense in context. Also, the code for a class should be relatively self-contained (generally using encapsulation). Collectively, the properties and methods defined by a class are called members.

Object

A pattern (exemplar) of a class. The class of Dog defines all possible dogs by listing the characteristics and behaviors they can have; the object Lassie is one particular dog, with particular versions of the characteristics. A Dog has fur; Lassie has brown-and-white fur.

Instance

One can have an instance of a class or a particular object. The instance is the actual object created at runtime. In programmer jargon, the Lassie object is an instance of the Dog class. The set of values of the attributes of a particular object is called its state. The object consists of state and the behaviour that's defined in the object's class.

Method

An object's abilities. In language, methods (sometimes referred to as "functions") are verbs. Lassie, being a Dog, has the ability to bark. So bark() is one of Lassie's methods. She may have other methods as well, for example sit() or eat() or walk() or save_timmy(). Within the program, using a method usually affects only one particular object; all Dogs can bark, but you need only one particular dog to do the barking.

Message passing

"The process by which an object sends data to another object or asks the other object to invoke a method." Also known to some programming languages as interfacing. For example, the object called Breeder may tell the Lassie object to sit by passing a "sit" message which invokes Lassie's "sit" method. The syntax varies between languages, for example: [Lassie sit] in Objective-C. In Java, code-level message passing corresponds to "method calling". Some dynamic languages use double-dispatch or multi-dispatch to find and pass messages.

Inheritance

"Subclasses" are more specialized versions of a class, which inherit attributes and behaviors from their parent classes, and can introduce their own.

For example, the class Dog might have sub-classes called Collie, Chihuahua, and GoldenRetriever. In this case, Lassie would be an instance of the Collie subclass. Suppose the Dog class defines a method called bark() and a property called furColor. Each of its sub-classes (Collie, Chihuahua, and GoldenRetriever) will inherit these members, meaning that the programmer only needs to write the code for them once.

Each subclass can alter its inherited traits. For example, the Collie class might specify that the default furColor for a collie is brown-and-white. The Chihuahua subclass might specify that the bark() method produces a high pitch by default. Subclasses can also add new members. The Chihuahua subclass could add a method called tremble(). So an individual chihuahua instance would use a high-pitched bark() from the Chihuahua subclass, which in turn inherited the usual bark() from Dog. The chihuahua object would also have the tremble() method, but Lassie would not, because she is a Collie, not a Chihuahua. In fact, inheritance is an "a... is a" relationship between classes, while instantiation is an "is a" relationship between an object and a class: a Collie is a Dog ("a... is a"), but Lassie is a Collie ("is a"). Thus, the object named Lassie has the methods from both classes Collie and Dog.

Multiple inheritance is inheritance from more than one ancestor class, neither of these ancestors being an ancestor of the other. For example, independent classes could define Dogs and Cats, and a Chimera object could be created from these two which inherits all the (multiple) behavior of cats and dogs. This is not always supported, as it can be hard both to implement and to use well.

Abstraction

Abstraction is simplifying complex reality by modelling classes appropriate to the problem, and working at the most appropriate level of inheritance for a given aspect of the problem.

For example, Lassie the Dog may be treated as a Dog much of the time, a Collie when necessary to access Collie-specific attributes or behaviors, and as an Animal (perhaps the parent class of Dog) when counting Timmy's pets.

Abstraction is also achieved through Composition. For example, a class Car would be made up of an Engine, Gearbox, Steering objects, and many more components. To build the Car class, one does not need to know how the different components work internally, but only how to interface with them, i.e., send messages to them, receive messages from them, and perhaps make the different objects composing the class interact with each other.

Encapsulation

Encapsulation conceals the functional details of a class from objects that send messages to it.

For example, the Dog class has a bark() method. The code for the bark() method defines exactly how a bark happens (e.g., by inhale() and then exhale(), at a particular pitch and volume). Timmy, Lassie's friend, however, does not need to know exactly how she barks. Encapsulation is achieved by specifying which classes may use the members of an object. The result is that each object exposes to any class a certain interface - those members accessible to that class. The reason for encapsulation is to prevent clients of an interface from depending on those parts of the implementation that are likely to change in future, thereby allowing those changes to be made more easily, that is, without changes to clients. For example, an interface can ensure that puppies can only be added to an object of the class Dog by code in that class. Members are often specified as public, protected or private, determining whether they are available to all classes, sub-classes or only the defining class. Some languages go further: Java uses the default access modifier to restrict access also to classes in the same package, C# and VB.NET reserve some members to classes in the same assembly using keywords internal (C#) or Friend (VB.NET), and Eiffel and C++ allow one to specify which classes may access any member.

Polymorphism

Polymorphism allows the programmer to treat derived class members just like their parent class' members. More precisely, Polymorphism in object-oriented programming is the ability of objects belonging to different data types to respond to method calls of methods of the same name, each one according to an appropriate type-specific behavior. One method, or an operator such as +, -, or *, can be abstractly applied in many different situations. If a Dog is commanded to speak(), this may elicit a bark(). However, if a Pig is commanded to speak(), this may elicit an oink(). They both inherit speak() from Animal, but their derived class methods override the methods of the parent class; this is Overriding Polymorphism. Overloading Polymorphism is the use of one method signature, or one operator such as "+", to perform several different functions depending on the implementation. The "+" operator, for example, may be used to perform integer addition, float addition, list concatenation, or string concatenation. Any two subclasses of Number, such as Integer and Double, are expected to add together properly in an OOP language. The language must therefore overload the addition operator, "+", to work this way. This helps improve code readability. How this is implemented varies from language to language, but most OOP languages support at least some level of overloading polymorphism. Many OOP languages also support Parametric Polymorphism, where code is written without mention of any specific type and thus can be used transparently with any number of new types. Pointers are an example of a simple polymorphic routine that can be used with many different types of objects.

Decoupling

Decoupling allows for the separation of object interactions from classes and inheritance into distinct layers of abstraction. A common use of decoupling is to polymorphically decouple the encapsulation, which is the practice of using reusable code to prevent discrete code modules from interacting with each other. However, in practice decoupling often involves trade-offs with regard to which patterns of change to favor. The science of measuring these trade-offs in respect to actual change in an objective way is still in its infancy.

Note: Not all of the above concepts are to be found in all object-oriented programming languages, and so object-oriented programming that uses classes is called sometimes class-based programming. In particular, prototype-based programming does not typically use classes. As a result, a significantly different yet analogous terminology is used to define the concepts of object and instance.

User Avatar

Wiki User

15y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

9y ago

Object oriented programming (OOP) makes programming easier in a number of ways.

First, consider the following structure:

struct name {

std::string forename;

std::string surname;

};

A structure is a class that has public access by default. Thus any code with access to this structure can manipulate the representation:

void f (name& n)

{

n.forename = ""; // invalidate the forename (surname is unaffected).

}

Obviously we wouldn't deliberately tamper with data like this, however the structure offers no protection against errant code manipulating the representation in unintended ways. With OOP, however, we can make it much more difficult for errant code to invalidate data:

structure name {

private:

std::string forename;

std::string surname;

};

void f (name& n)

{

n.forename = ""; // error! name::forename is private!

}

Private members of a class are only accessible to other members of the same class and to designated friends of the class. In so doing we have dealt with the first stage of debugging -- localisation -- before the program is even run! If the representation should become invalid, then it can and must occur within those members.

Although it is still possible for errant code to circumvent the privacy of a class representation (by direct memory manipulation for instance), there is a distinction between accidentally invalidating data and deliberately invalidating data (fraud). By making it that much harder to commit fraud, our code becomes more robust because it is safe to assume that anyone who uses our class wouldn't deliberately write errant code. All we have to do is provide a set of public members and friend functions that allow the user to initialise and interact with the representation in a controlled manner. With a well-designed public interface, the user cannot accidently write errant code. The public interface alone tells the user all they need to know in order to use the class. This is known as encapsulation, which is one of the four pillars of object-oriented programming.

The four pillars are: encapsulation, abstraction, inheritance and polymorphism.

Abstraction makes it possible for class designers to change the class representation or to alter the implementation of the public interface without affecting users of the class. All changes are localised to the class itself; from the user's perspective the class operates in exactly the same way so long as the interface does not change. In other words, it is not necessary for a user to know the implementation details of the class, they only need to know the interface; what it does, not how it does it.

Inheritance allows class designers to create new classes from existing classes. The new class inherits all the public (and protected) members of its base class, thus reducing the need to write duplicate code. The programmer can therefore take advantage of existing code and use it as the basis for deriving more specialised code.

Polymorphism makes it possible for base classes to provide virtual interfaces to derived classes. When a class defines a virtual method, the most-derived override for that method is always executed. Thus objects behave according to their runtime type even when the runtime type cannot be determined at compile time. Code can therefore be written in a much more generic manner, using the virtual interface rather than the actual interface.

This answer is:
User Avatar

User Avatar

Wiki User

12y ago

You can read all about it in object-oriented-programming

This answer is:
User Avatar

User Avatar

Wiki User

12y ago

Yes Java is pure object oriented language .

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Concept of object oriented programming
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What is the distinct difference between object oriented concept and object oriented programming?

Object oriented concepts are a generalisation of the object oriented principals (encapsulation, inheritance, polymorphism and abstraction) without specifying a particular implementation of those principals. Object oriented programming is the application of those principals through an object oriented programming language.


What are the disadvantages of object oriented programming over structured programming?

actually oop concept have some disadvantage when compared to structured programming


What are the basic concept of object oriented programming language?

Inheritance Encapsulation Polymorphism Abstraction


What is full form of oop's?

Object Oriented Programming


Object-oriented software is another name for structured software?

Object-oriented programming is a more recent subset of structured programming. Structured programming emphasized the need to align data structures with program structure, a concept that is formalized and carried much further in object-oriented programming. However, structured programming advocated hierarchical constraints on program structure that are incompatible with the event-driven, message-passing software architectures commonly implemented in the object-oriented style, today.


Is PHP object oriented?

Yes - 'advanced' PHP programming uses Object Oriented Programming (OOP).


What is an essential of Object Oriented Programming?

The 3 essential concepts of Object Oriented Programming are:InheritanceEncapsulation &Polymorphism


Is the object oriented programming in php useful?

Object orientation is not a concept related to usefull ness, it is a concept totally related to the software design. When we focused on software design we went for object orientation.


Is c is complete object oriented programming language?

No. C is not object oriented. C++ is object oriented.


Full form of oops?

The full form of OOP is Object-Oriented Programming.


What actually mean by object oriented programming Is C plus plus is a object oriented programming?

Just eat a watermellon!


What is the namespace in c?

C has no concept of namespaces. Namespaces are typically found in object-oriented programming languages as a means of organising code.