Computer Java

Only available on StudyMode
  • Download(s) : 101
  • Published : June 1, 2013
Open Document
Text Preview
1. Object Orientd Prrogramming : A type of programming in which programmers define not only the data type of a data structure, but also the types of operations (functions) that can be applied to the data structure. In this way, the data structure becomes an objectthat includes both data and functions. In addition, programmers can create relationships between one object and another. For example, objects can inherit characteristics from other objects. One of the principal advantages of object-oriented programming techniques over procedural programming techniques is that they enable programmers to create modules that do not need to be changed when a new type of object is added. A programmer can simply create a new object that inherits many of itsfeatures from existing objects. This makes object-oriented programs easier to modify. To perform object-oriented programming, one needs an object-orientedprogramming language (OOPL). Java, C++ and Smalltalk are three of the more popular languages, and there are also object-oriented versions ofPascal.

2. Chracterstics of OOP:
Encapsulation – Encapsulation is capturing data and keeping it safely and securely from outside interfaces. Inheritance- This is the process by which a class can be derived from a base class with all features of base class and some of its own. This increases code reusability. Polymorphism- This is the ability to exist in various forms. For example an operator can be overloaded so as to add two integer numbers and two floats. Abstraction- The ability to represent data at a very conceptual level without any details. Some key features of the Object Oriented programming are:

• Emphasis on data rather than procedure
• Programs are divided into entities known as objects
• Data Structures are designed such that they characterize objects • Functions that operate on data of an object are tied together in data structures • Data is hidden and cannot be accessed by external functions • Objects communicate with each other through functions • New data and functions can be easily added whenever necessary • Follows bottom up design in program design 

3. Concept of classes and object:

A class is a blue print from which individual objects are created.

A sample of a class is given below:

public class Dog{
String breed;
int age;
String color;

void barking(){
}

void hungry(){
}

void sleeping(){
}
}

.

A class can have any number of methods to access the value of various kind of methods. In the above example, barking(), hungry() and sleeping() are methods.

Object - Objects have states and behaviors. Example: A dog has states-color, name, breed as well as behaviors -wagging, barking, eating. An object is an instance of a class.

Let us now look deep into what are objects. If we consider the real-world we can find many objects around us, Cars, Dogs, Humans etc. All these objects have a state and behavior.

If we consider a dog then its state is - name, breed, color, and the behavior is - barking, wagging, running

4. Abstraction: In computer science, abstraction is the process by which data and programs are defined with a representation similar in form to its meaning (semantics), while hiding away theimplementation details. Abstraction tries to reduce and factor out details so that the programmer can focus on a few concepts at a time. A system can have several abstraction layers whereby different meanings and amounts of detail are exposed to the programmer. For example, low-level abstraction layers expose details of the computer hardware where the program is run, while high-level layers deal with the business logic of the program.

5. Encapsulation: In programming languages, encapsulation is used to refer to one of two related but distinct notions, and sometimes to the combination[1][2] thereof:

• A language mechanism for restricting access to some of the object's...
tracking img