Sie sind auf Seite 1von 4

Object-Oriented Programming

Assignment One

Group Members
Name id
1. Abebe Tedila 193/03
2. Hospital Tenaw 219/03
3. Mesfin Telay 232/03
4. Tiruworke Fentaw 244/03

1. What is programming language? Give example of programming languages and classify them as
object-oriented and non object-oriented programming languages?

A programming language is an artificial designed to communicate instructions to a machine,


particularly a computer. Programming languages can be used to create programs that control the
behavior of a machine and/or to express algorithms precisely.
Programming language is a notation for writing programs, which are specifications of a computation
or algorithm. Some, but not all, authors restrict the term "programming language" to those languages
that can express all possible algorithms.

The earliest programming languages predate the invention of the computer, and were used to direct
the behavior of machines such as Jacquard looms and player pianos. Thousands of different
programming languages have been created, mainly in the computer field, with many more being
created every year. Most programming languages describe computation in an imperative style, i.e., as
a sequence of commands, although some languages, such as those that support functional
programming or logic programming, use alternative forms of description.

A programming language is usually split into the two components of syntax (form) and semantics
(meaning). Some languages are defined by a specification document (for example, the C programming
language is specified by an ISO Standard), while other languages, such as Perl, have a dominant
implementation that is used as a reference.
Generally programming languages may be divided in to three general types:
1. Machine language: a language directly understands by a computer. It consists of strings of
numbers (zero’s (0) and one’s (1)) and it is also machine dependent.
2. Assembly language: are English like abbreviations. They are translated to machine language
using assembles.
3. High level languages: allows programmers to write instructions that look almost like everyday
English and contains commonly used mathematical notation.
Examples of programming languages are:
A. Non Object-oriented programming languages
C, Pascal, FORTRAN, COBOL, BASIC
B. Object-oriented programming languages
C++, Java, Visual Basic, Small talk ,C#,Cobra
2. Discuss the advantage of object-oriented and non object-oriented (structured or unstructured)
programming languages.
Object-oriented programming (OOP) is a programming paradigm using "objects" – data
structures consisting of data fields and methods together with their interactions – to design
applications and computer programs. Programming techniques may include features such as
data abstraction, encapsulation, messaging, modularity, polymorphism, and inheritance.

OOP is about modeling the 'real world'


OOP is a programming paradigm that uses abstraction to create models based on the real world. It
provides for better modeling of the real world by providing a much needed improvement in
domain analysis and then integration with system design.

OOP is about code re-use


The power of object-oriented systems lies in their promise of code reuse which will
increase productivity, reduce costs and improve software quality.

OOP is about modularity


The source code for an object can be written and maintained independently of the source
code for other objects. Once created, an object can be easily passed around inside the
system.

OOP is about plug ability


If a particular object turns out to be problematic, you can simply remove it from your
application and plug in a different object as its replacement. This is analogous to fixing
mechanical problems in the real world. If a bolt breaks, you replace it, not the entire
machine.

OOP is about information hiding


By interacting only with an object's methods, the details of its internal implementation
remain hidden from the outside world.

OOP is about the passing of messages.


Message passing is the process by which an object sends data to another object or asks
the other object to invoke a method.

OOP is about separation of responsibilities.


Each object can be viewed as an independent little machine with a distinct role or
responsibility.

OOP is easier to learn.


OOP is easier to learn for those new to computer programming than previous approaches,
and its approach is often simpler to develop and to maintain, lending itself to more direct
analysis, coding, and understanding of complex situations and procedures than other
programming methods.

OOP is about actors and actions.


Object Oriented Programming is a mode of software development that modularizes and
decomposes code authorship into the definition of actors and actions.

OOP is all about late binding.


'Late' refers to the fact that the binding decisions (which binary to load, which function to
call) are deferred as long as possible, often until just before the function is called, rather
than having the binding decisions made at compile time (early).

A computer language can be aid to be Object Oriented if it provides support for the following:
A class is a blueprint, or prototype, that defines the variables (data) and the methods
Class
(operations) common to all objects of a certain kind.
An instance of a class. A class must be instantiated into an object before it can be
Object used in the software. More than one instance of the same class can be in existence at
any one time.
The act of placing data and the operations that perform on that data in the same
Encapsulation
class. The class then becomes the 'capsule' or container for the data and operations.
The reuse of base classes (superclasses) to form derived classes (subclasses).
Inheritance Methods and properties defined in the superclass are automatically shared by any
subclass.
Same interface, different implementation. The ability to substitute one class for
another. This means that different classes may contain the same method names, but
Polymorphism
the result which is returned by each method will be different as the code behind each
method (the implementation) is different in each class.

Non object-oriented programming language is a language that is centered on the procedures


or functions rather than classes and objects.
 It is difficult in debugging/correcting errors/.
 It doesn’t model real world problems.
 There is little attention to the data/attention is given more to tasks/
 There is no code reuse.
 There are no class and object.
Object-Oriented Programming
Assignment Two
1. List and discuss all primitive data types supported by java programming language

Java Primitive Data Types


A primitive type is predefined by the language and is named by a reserved keyword. Primitive
values do not share state with other primitive values. The eight primitive data types supported by
the Java programming language are:
 byte: The byte data type is an 8-bit signed two's complement integer.
 short: The short data type is a 16-bit signed two's complement integer.
 int: The int data type is a 32-bit signed two's complement integer.
 long: The long data type is a 64-bit signed two's complement integer.
 float: The float data type is a single-precision 32-bit IEEE 754 floating point
 double: The double data type is a double-precision 64-bit IEEE 754 floating point.
 boolean: The boolean data type has only two possible values: true and false.
 char: The char data type is a single 16-bit Unicode character.

Type Contains Default Size Range


boolean true or false false 1 bit NA

char Unicode character \u0000 16 bits or 0 to 216-1 or


unsigned 2 bytes \u0000 to \uFFFF
byte Signed integer 0 8 bit or -27 to 27-1 or
1 byte -128 to 127
short Signed integer 0 16 bit or -215 to 215-1 or
2 bytes -32768 to 32767
int Signed integer 0 32 bit or -231 to 231-1 or
4 bytes -2147483648 to 2147483647
long Signed integer 0 64 bit or -263 to 263-1 or
8 bytes -9223372036854775808 to
9223372036854775807
float IEEE 754 floating point 0.0f 32 bit or ±1.4E-45 to
single-precision 4 bytes ±3.4028235E+38
double IEEE 754 floating point 0.0 64 bit or ±439E-324 to
double-precision 8 bytes ±1.7976931348623157E+308

Das könnte Ihnen auch gefallen