Results 1 to 4 of 4

Thread: OOPS Concepts

  1. #1
    Join Date
    Dec 2008
    Posts
    3

    OOPS Concepts

    Can anybody help me to learn OOPS. I am very low in this and tried alot to achieve that. Please tell me the best way to learn it. As a C# developer I really need this.

    Thanks

  2. #2
    Join Date
    Dec 2008
    Posts
    2

    Re: OOPS Concepts

    what is your question ?

  3. #3
    Join Date
    Feb 2008
    Posts
    194

    Re: OOPS Concepts

    Here are some ebooks present online which will help you provide a detail knowledge of OOPS concepts.

    Free Ebooks
    New C# programmer, need beginners book

  4. #4
    Join Date
    Mar 2008
    Posts
    258

    Re: OOPS Concepts

    Hello suneel,

    There are 4 Basic OOPS Concepts in JAVA,and they are as follows:

    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 ‘is-a’ relationship: Lassie is a Collie. A Collie is a Dog. Thus, Lassie inherits the methods of both Collies and Dogs.
    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.

    There are also other but those are depends on the programming languages.

    Regards,

Similar Threads

  1. Behaviour of class in OOPs
    By TechGate in forum Software Development
    Replies: 5
    Last Post: 02-03-2010, 11:46 AM
  2. Oops management Date and TimeZone
    By Ash maker in forum Software Development
    Replies: 5
    Last Post: 09-02-2010, 03:40 AM
  3. Oops! This link appears broken. DNS error
    By Custidio in forum Networking & Security
    Replies: 5
    Last Post: 19-01-2010, 09:13 PM
  4. What does OOPS concepts comprises?
    By abigial_i in forum Software Development
    Replies: 3
    Last Post: 08-12-2009, 09:24 AM
  5. Whats the best way to learn oops
    By jaynok in forum Software Development
    Replies: 2
    Last Post: 29-04-2009, 08:08 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,399,231.63897 seconds with 17 queries