Its packages represent the tasks most commonly associated with generalpurpose programming. This library is known as the "Application Programming Interface", or The Java platform provides an enormous class library (a set of packages) suitable for use in Thousands of individual classes, it makes sense to keep things organized by placing related Keep HTML pages in one folder, images in another, and scripts or applications in yet another.īecause software written in the Java programming language can be composed of hundreds or You can think of packages as being similar to different folders on your computer. In its most common form, an interface is a group of related methods with empty bodies.Ī package is a namespace that organizes a set of related classes and interfaces. Methods form the object's interface with the outside world theīuttons on the front of your television set, for example, are the interface between you and theĮlectrical wiring on the other side of its plastic casing. However, you must take care to properly document the state and behavior thatĮach superclass defines, since that code will not appear in the source file of each subclass.Īs you've already learned, objects define their interaction with the outside world through the This makes code for your subclassesĮasy to read. This gives MountainBike all the same fields and methods as Bicycle, yet allows its code toįocus exclusively on the features that make it unique. new fields and methods defining a mountain bike would go here The extends keyword, followed by the name of the class to inherit from: At the beginning of your class declaration, use The syntax for creating a subclass is simple. Superclass, and each superclass has the potential for an unlimited number of subclasses. In the Java programming language, each class is allowed to have one direct Objectoriented programming allows classes to inherit commonly used state and behavior from otherĬlasses. If a boltīreaks, you replace it, not the entire machine.Ī class is the blueprint from which individual objects are created.ĭifferent kinds of objects often have a certain amount in common with each other. This is analogous to fixing mechanical problems in the real world. Pluggability and debugging ease: If a particular object turns out to be problematic, youĬan simply remove it from your application and plug in a different object as its This allows specialists to implement/test/debugĬomplex, task-specific objects, which you can then trust to run in your own code.Ĥ. Code re-use: If an object already exists (perhaps written by another software developer), Internal implementation remain hidden from the outside world.ģ. Information-hiding: By interacting only with an object's methods, the details of its Once created, an object can be easily reused.Ģ. Modularity:- The source code for an object can be written and maintained independently What are the advantages of bundling code into objects?ġ. Through an object's methods is known as data encapsulation - a fundamental principle of Hiding internal state and requiring all interaction to be performed Methods operate on an object's internal state and serve as the primary mechanism for objectto-object communication. An object also has methods (functions in some programming languages). An object stores its state in fields (variables in some programming Software objects are conceptually similar to real-world objects: they too consist of state and Generated by Foxit PDF Creator © Foxit Software.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |