Vous êtes sur la page 1sur 4

(B) What is Object Oriented Programming ? It is a problem solving technique to develop software systems.

It is a technique to think real world in terms of objects. Object maps the software model to real world concept. These objects have responsibilities and provide services to application or other objects. Object-oriented programming (OOP) is an engineering approach for building software systems Based on the concepts of classes and objects that are used for modeling the real world entities

Object-oriented programs Consist of a group of cooperating objects Objects exchange messages, for the purpose of achieving a common objective Implemented in object-oriented languages

(B) Whats a Class ? A class describes all the attributes of objects, as well as the methods that implement the behavior of member objects. Its a comprehensive data type which represents a blue printB of objects. Its a template of object. (B) Whats an Object ? It is a basic unit of a system. An object is an entity that has attributes, behavior, and identity. Objects are members of a class. Attributes and behavior of an object are defined by the class definition. You create classes in C# with the class statement: [attributes] [modifiers] class identifier [:base-list] { class-body }[;] Here are the parts of this statement: attributes (Optional)Attributes hold additional declarative information, as well seein Chapter 14, Using Attributes and Reflection. modifiers (Optional)The allowed modifiers are new, static, virtual, abstract, override, and a valid combination of the four access modifiers well see in this chapter. identifierThe class name. base-list (Optional)A list that contains the base class and any implemented inter-faces, separated by commas. class-bodyDeclarations of the class members.

Creating Objects To create an object, also called an instance, of a class, you use the new keyword. These parentheses are necessary when you use the new keyword. They let you pass data to a classs constructor, the special method that lets you initialize the data in a class. Calculator obj = new Calculator(); Access Modifiers As mentioned at the beginning of the chapter, encapsulation, the capability to hide data and methods to stop them from cluttering up the rest of your code, is one of the biggest advantages of OOP. Encapsulating data and methods not only ensures that they dont clutter up the rest of your code, it also ensures that the rest of your code doesnt interfere with them. You can use access modifiers to set the allowed access to not only classes, but also to all members of those classes. Here are the available access modifiers:

What Is Inheritance?

Inheritance provides a powerful and natural mechanism for organizing and structuring your software. This section explains how classes inherit state and behavior from their superclasses, and explains how to derive one class from another using the simple syntax provided by the Java programming language.

A class can extend another class, inheriting all its data members and methods The child class can redefine some of the parent class's members and methods and/or add its own A class can implement an interface, implementing all the specified methods Inheritance implements the is a relationship between objects

What Is an Interface?

An interface is a contract between a class and the outside world. When a class implements an interface, it promises to provide the behavior published by that interface. This section defines a simple interface and explains the necessary changes for any class that implements it.

What Is a Package?

A package is a namespace for organizing classes and interfaces in a logical manner. Placing your code into packages makes large software projects easier to manage. This section explains why this is useful, and introduces you to the Application Programming Interface (API) provided by the Java platform.

Abstraction Abstraction means ignoring irrelevant features, properties, or functions and emphasizing the relevant ones... ... relevant to the given project (with an eye to future reuse in similar projects) Abstraction = managing complexity Abstraction is something we do every day Looking at an object, we see those things about it that have meaning to us We abstract the properties of the object, and keep only what we need

Allows us to represent a complex reality in terms of a simplified model Abstraction highlights the properties of an entity that we are most interested in and hides the others

Encapsulation Encapsulation means that all data members (fields) of a class are declared private Some methods may be private, too

The class interacts with other classes (called the clients of this class) only through the classs constructors and public methods Constructors and public methods of a class serve as the interface to classs clients

Polymorphism Ability to take more than one form A class can be used through its parent class's interface A subclass may override the implementation of an operation it inherits from a superclass (late binding)

Polymorphism allows abstract operations to be defined and used Abstract operations are defined in the base class's interface and implemented in the subclasses

Vous aimerez peut-être aussi