cs101 introduction to computer science 1

Download CS101 Introduction to Computer Science 1

If you can't read please download the document

Upload: jessica-bone

Post on 25-Sep-2015

35 views

Category:

Documents


0 download

DESCRIPTION

Text book notes for Computer Science 101

TRANSCRIPT

Notes : CS101: Introduction to Computer Scienceby: Jessica Bone 3/23/15

CS101: Introduction to Computer Science 1

History of Computing 1.1The first modern computer came into existence is the 1940s.

Man's quest to simplify mathematical computations has let to extensive research, algorithm development and other innovations.

A computer is an electronic device that stores and processes data.

Hardware in a computer refers to the physical aspects of the computer and comprises the following main components: central processing unit (CPU), memory, storage devices (disks, Cd, and tapes). And input / output devices (monitor, keyboards, mice and printers.)

The earliest device to keep track of calculations was an abacus. It was used around 50 BC and was very popular in Asia.

John Napier, a Scottish Mathematician, Physicist and Astronomer definer natural logarithms in 1614 to simplify calculations. The use of logarithms greatly simplified the complex astronomical , navigational, mathematical and scientific calculations that were common place at the time. He also invented Napier's bones a mathematical tool that uses a set of numbered rods to simplified multiplication.

Charles Babbage, a British Mathematician and inventor first proposed the idea of a programmable computer. Whiles studying complex astronomical calculations that others had done by hand he found numerous mistakes. Which motivated him to design a mechanical computer that could do these calculations without errors. He designed the machine it was not built during his lifetime.

The need for programming came with the idea of making general purpose hardware that could be used to carry our a variety of tasks.

Ada Lovelace, who was the world's first programmer, published a paper in which she demonstrated how Babbage' s analytical engine could be programmed to perform various computations.

A device called a punch card was used in the late 1800s to keep track of data could be read by machines. Punch cards stored information in digital format, which was represented at the time by specific series of holes in paper card stock.

Herman Hollerith applied the idea of representing information as holes in paper cards to speed up the tabulation process in the 1890 US Census. Holleriths work contributed to initial programming methods, and punch cards were used to communicate with computers well into the 1970s.

In the late 1940s John Von Neumann introduced the idea of a computer architecture based on stored programs. The key idea was to store both the data and the program in memory. The idea behind storing programs in a memory was based on the construction of these programs using a small set of generic operations. This became know as Von Neumann Architecture in the field of computer science. This was a major advance in computer design, because until this point computers were programed by setting switched ans physically wiring the components; storing programs in memory completely changed that. This was also the start of machine language (a sequence of 0s and 1s.)

The first computer ENIAC (Electronic Numerical Integrator and Computer) was built by the United States Army's Ballistic Research Laboratory in 1946. It was part of the research aimes at providing better missiles to the U.S. Army during WWII.

Dr. Presper Eckert and Dr. John Mauchly two members of the team that built ENIAC, started their own company Universal Automatic Computer or UNIVAC to build the first commercial computer. Their first client was the United States Census Bureau, which needed a computer built to keep track of the growing U.S. Population. The computer was successfully built in 1951 at the cost of about one million dollars.

Figure 8: A layered structure showing where the operating system software and application software are situated while running on a typical desktop computer.During the 1950s and 1960s, several high-level programming languages were

introduced, such as FORTRAN, COBOL, Lisp, ALGOL, and PL/I. The 1970s saw the introduction of languages such as Pascal, C, and Prolog. Most of these languages such as Pascal, C, and FORTRAN are procedural programming languages.Procedural Programming is also referred to as imperative programming. The basic idea of this programming style is to specify the steps that the program must take to reach the desired state.

An exception to this style of programming comes from languages called Lisp and

Prolog. Lisp is a functional programming language, and Prolog is a logic programming language.In functional programming style, evaluation of mathematical style functions take place and the state variables are not used.

In logical programing a program is expressed as a sequence of logical assertions and these assertions are automatically evaluated to come up with the result. These languages include a logic evaluation engine along with the compiler.

In the late 1970s, a new design approach called object-oriented programming (OOP)

was developed. This programming technique has several advantages, and almost all languages today follow this approach.The 1980s saw the introduction of object-oriented programming language C++, which was later followed by another OOP called Java in the 1990s.

Java has become a popular programming language for the development of mobile and web based application.

The 1980s and 1990s also saw the introduction of scripting programming languages such as Perl, Python and Rudy.

Prior to the introduction of personal computers, businesses utilized minicomputers for

local computers, with users connected to the minicomputer remotely via terminals. Theminicomputers were often connected via computer networks to enable distributedsystems software made up of components, located or distributed on the networkcomputers, which communicate via messages to achieve a common purpose.The networks which began as local hard-wired networks grew rapidly by utilizing telephone networks and eventually evolved to include wireless connections.

Computers entered American households in the 1980s. In 1975, Bill Gates and Paul Allen co-founded Microsoft to create software for both businesses and personal computers. As the first major project for the company, IBM asked Microsoft to create operating system software for the personal computers that IBM planned to build. Microsoft named this operating system MS-DOS and released it as a product.

Although announced in 1983, the Windows operating system was not released until 1987. It was not until the 1995 release of Windows 95 that Microsofts software became a very popular operating system and one of the fastest-selling pieces of software in the history of computing.

In 2001, Microsoft introduced Windows XP, with features like multi-lingual support and a new, user-friendly interface. Released in 2006, Windows Vista addressed security issues that many critics voiced for Windows XP and also improved the accessibility of settings and programs. This was followed by Windows 7, which supported mobile computing as wireless Internet access became common. Now, with Windows 8, Microsoft has focused on touch-enabled computing, which has become popular with devices such as smart phones and tablets.

A web browser is a software program that allows users to easily browse the contents of the World Wide Web. It was first created in 1989 by Tim Berners-Lee, a British computer scientist, when he was working as a fellow at CERN. Marc Andreessen, a student at the University of Illinois in Urbana Champaign, later created a version of the browser in 1993, called Mosaic, which was much easier to install and use.

The browser later formed the basis for the company Netscape, which popularized the use of web browsers. Today, there are many browser options. The most popular include Google Chrome, Mozilla Firefox, Microsoft Internet Explorer, and Safari.

Founded in 1998, Google has become one of the most recognized technology companies in the world due to its search engine, which is used to find information on the Internet.

Googles search engine, as well as the companys other products, such as Gmail, Google Maps, Google Books, and YouTube, are web browser-based software applications.

There is a general trend towards using applications that do not run on your computer but run on servers located elsewhere, also known as the cloud.

The computing resources being used are remote, and your machine mainly takes up roles of display and communications with the remote entities. As devices become more capable and more mobile, software development is catering to the cloud computing paradigm more and more.

One of the enablers of cloud computing paradigm is a concept called virtual machines.

A virtual machine is a program that creates a self-contained operating environment on top of the underlying hardware and presents appearance of different machines to the user. This allows the same piece of hardware to be used as different machines at the same time.

You can create a Linux virtual machine on top of a Windows machine through the use of virtual machine software such as Oracles VirtualBox and EMCs VMWare.

Today, mobile applications drive a lot of software development.

Released in 2007, Apples iOS, which was previously known as iPhone OS, is a mobile operating system for the iPhone and iPod Touch devices.

the operating system functions for the iPad and the Apple TV, allowing for a familiar interface across devices that ameliorates the users experience.

Another leading OS for smart phones and tablets is Googles Android OS, which is Linux-based. Microsofts Windows 8 OS has also been designed to work with phones and tablets. These operating systems have made the development of mobile applications popular and spurred the creation of a large app-making industry

Hardware vs Software 1.2.1The word hardware is used for physical devices such as TV sets, DVD players and computers. When talking about hardware mean the physical parts of a computer. The hardware components of a computer system are the electronic and mechanical parts, such as the processor, main memory, secondary memory, input and output devices.

The word software is used for the information used with such devises: music, movies, novels, web-pages, computer programs and data. Software means the programs and data used with the physical computer. The software components of a computer system are the data and the computer programs.

Main Components of a Computer System

The terms input and output say if data flow into or out of the computer.

A bus is a group of wires on the main circuit board of the computer. It is apathway for data flowing between components. Most devices are connected to the bus through a controller which coordinates the activities of the device with the bus. The processor is an electronic device about a one inch square, covered in plastic, Inside the square is an even smaller square of silicon containing millions of tiny electrical parts. The processor is sometimes called the Central Processing Unit (CPU).

A modern processor chip (in 2014) may have up to 2.5 billion transistors. The first commercial chip 2.5 thousand transistors is 1971.

The processor performs all the fundamental computation of the computer system. Other components contribute to the computation by doing such thins a storing data or moving data into ans out the processor. The processor is where the fundamental action takes place.

The processor chip has relatively little memory . If has only enough memory to hold a few instructions of a program and the data they process. Complete programs and data sets are held in memory external to the processor.

There is two fundamental types of memory, main and secondary.

Main memory is sometimes called volatile because it looses its information when power is removed. Main memory is sometimes called main storage. Main memory is closest connected to the processor, stored data are quickly and easily changed; holds the programs and data that the processor is actively working with; interacts with the processor millions of times per second; needs constant electrical power to keep its information. Main memory is sometimes called RAM (Random Access Memory) which mean the memory cells can be accessed in any order. Properly speaking RAM means the type of silicon chip used to implement main memory. One megabyte of memory is enough to hole approximately one million (106) characters of a word processing document. Primary memory is fast, ecpensice, low capacity, works directly with the processor.

Secondary memory is usually nonvolatile because it retains its information when power is removed. (however it needs power when information is stored into memory or retrieved from it.) Secondary memory is sometimes called secondary storage or mass storage. Secondary memory is connected to main memory through the bus and a controller; stored data are easily changed but changes are slow compared to main memory; used for long tern storage of programs and data.; before data and programs can be used, they must me copied form the secondary memory into main memory; doe not need electric power to keep its information. Secondary memory is where programs and data are kept on a long-tern basis. Secondary storage devices are the hard disk and optical disks. Hard disk has a enormous storage capacity compared to main memory; usually contained inside the case of the computer; is used for long-tern storage of programs and data; data and programs o the hard disk are organized into files; a file collection of data on the disk that has a name; hard disk storage capacity of 500 gigabytes (room for about 500 x 109 characters) is about 100 times the capacity of main memory. Secondary memory is slow, cheap, arge capacity, not connected directly to the processor.

The reason for having to types of storage is this difference in speed and capacity. It the disk were the only type of memory the computer system would slow down to a crawl.

Large blacks of data are copied form disk into main memory. The operation is slow but slow, but lots of data is copied, the the processor can quickly read and wirte small sections of the data in main memory.

Input and output devices allow the computer system to interact with the outside world byt moving data into and out of the system.

An input device is used to bring data into the system. Some input devices include keyboard, mouse, microphone, bar code reader, graphics tablet.

Out put devices is used to send data out of the system. Some output devices include the monitor, printer and speaker.

A network interface acts as both input and output; data flows from the network into the computer and out of the computer into the network.

Input/output devices are usually called I/O devices. The are directly connected to electronic module attached to the motherboard called a device controller. Example of this the speakers of a multimedia computer system are directly connected to a device controller card an audio card, which in turn is plugged into a bus on the motherboard. Some motherboards have audio, graphics and network controllers built in. What counts as a I/O device depends on the context.

A computer that is part of a larger machine and which controls how that machine operates is an embedded system. Usually the processor constantly runs a single control program which is permanently kept in ROM (Read Only Memory).

Rom is used to make a section of main memory read only. Main memory looks the same as before to the processor, except a section of it permanently contains the program the processor is running. This section of memory retains its data even when power is off. A typically embedded system includes cellphone, car, digital camera, DVD player, meical equipment and home appliances. Majority of processor chips are used in embedded systems, less than 1% of processor chips are used in the familiar desktop computer.

Computer software consists of both programs and data.

Programs consist of instructions for the processor.

Data can be any information that a program needs: character data, numerical data, image data, audio data, and countless other types.

Both programs and data are saved in computer memory in the same way. The electronics of computer memory and secondary memory make no distinction between programs and data. Both programs and data can be saved using the same electronic methods is an important concept in computer science. Computer systems use memory for wither programs or data as needed.

There are two categories of programs applications and system programs.

Application programs are programs that people use to get their work done. Examples of application programs word processor, game programs, spreadsheets, data base systems, graphics programs, and web browsers.

System programs keep the hardware and software running together smoothly. An important system program is the operating system. Examples of system programs, operating system, networking systems, programming language software, website server, and data backup.

Operating System coordinates the operation of the other hardware and software components of the computer system. The operating system is responsible for stating up application programs, running them and managing the resources that they need. Examples of operating systems are Unix, Linus, Android, Mac OS and Windows. An operating system is a complex program that keeps the hardware and software components of a computer system coordinated and functioning. Most computer systems can potentially run any of several operating systems. For example, most Pentium-based computers can run either Linux or a Windows operating systems.

When a computer is first started, the hardware automatically loads the operating system and starts it running. This process is called booting.

Here is a simplified list of what happens when the user starts up a application: 1. the user asks to run a application ( this is done by clicking on an icon, making a menu choice or by other means), 2. The OS determines the name of the application. 3. The OS finds the files on the hard disk where the application ans its data are stored. 4. The OS finds an unused section of main memeory that is large enough for the application. 5. The OS makes a copy of the application and its data in that section of main memory. ( the software on the hard disk is unchanged. Main memory hols a copy of what is on disk.) 6. The OS sets up resources for the application. 7. Finally, the OS starts the application running.

As the application runs, the OS is there in the background managing resources, doing input and output for the application, and keeping everything else running.

A computer network consists of two or more computers connected so that they can exchange data and programs. When a computer is a member of a network, the programs it runs and the data it uses can be on the hard disk of some other computer on the network. The operating system that runs on a networked computer must manage its share of the network (along with managing all its other responsibilities).

In a local-area network only a few dozen computers are connected together, usually all located within the same building. Each computer has a network address that the other computers use to access it. Usually the computers share a printer. There may be an especially powerful computer called a server whose hard disk holds application programs and data that the other computers are expected to need.

Each computer in a network has a network interface card. This is an input/output device that sends and receives data over cables. The network interface cards of computers on a network are connected together with cables.

A wide-area network can connect thousands of computers together over great distances. The long distance connections are made by using optical fiber, telephone lines, microwave radio and satellite communications. Each computer in the network has a network address (as with local-area networks) to uniquely identify it.

An agreement about how to represent and transmit data over a network use a protocol called TCP/IP ( fr transmission control protocol / internet protocol).

The internet consists of many networks that have been connected together to form one huge worldwide network. Even on this huge network, each computer must have a unique network address, called an ip address, much like each telephone in the world has a unique telephone number I including the country code and area code.)

IP addresses actually are 32-bit binary numbers.

Networking equipment uses these addressed to route information over the network. But even when written in decimal the address is not clear to humans. One of the features of the World Wide Web is that it allows humans to use computer names rather than numbers.

This computer name corresponds to the above IP address. When you use it in a web browser it is converted into the 32 binary digits of the computer's IP address.

Fundamental Idea: Both programs and data are saved in computer memory in the same way. The electronics of computer memory (both main memory and secondary memory) make no distinction between programs and data.

Communications equipment makes no distinction between programs and data, either. It is all information as far as it is concerned, and all information is transmitted the same way.

The Internet provides the hardware and the information transmission protocols for the World-Wide Web. Data intended for the Web is transmitted over the Internet just like any data. What makes Web data special is that it is intended for Web browsers (such as the one you are probably looking at). A browser is a program that can read Web pages and display them in a nicely formatted way. This information is given using a language called Hypertext Markup Language (HTML). If you want to see the HTML that describes this page, look at the menu at the top of your Web browser, and select Tools/Web Developer/Page Source. For older browsers, select View in the menu then left-click on Source. This will bring up a new window with the HTML of this page in it. After you are done viewing, close the window by clicking on the close button in its upper right corner (the button marked with X).

One web page is connected to another with a hyperlink. A web browser usually displays a hyperlink in a distinguishing color ( usually blue) . When you click on it, the browser asks the operating system to get a particular web page from another computer connected to the internet.

The web page to get is specified with a uniform resource locator URL. A URL specifies the exact computer (among all the interent computers in the world) an the exact web oage on theat computer.

The Quiz On Computer Systems 1.2.1What is the difference between hardware and software? Hardware is tangible, but software is intangible.

What hardware components(of a typical desktop computer) are usually found inside of the case? The processor, main memory and secondary memory

Which component does the actual computation of a computer system? The processor chip

Which type of memory is most closely connected to the processor? Main memory

Where are programs and data kept while the processor is using them? Main memory

What is an embedded system? A computer and software system that controls a machine or appliance.

How is it possible that both programs and data can be store on the same floppy disk? Programs and data are both software, and both can be stored on any memory device.

What are the two general types of programs? System software and Application software

What is an operating system?Systems software that coordinates the hardware and software components of a computer system.

What is a computer network? Two or more computers connected together to exchange data and programs.

Programs and Processes 1.2.2

Binary Numbers 1.2.2decimal
(base 10)binary
(base 2)

0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
160
1
10
11
100
101
110
111
1000
1001
1010
1011
1100
1101
1110
1111
100000 ones
1 one
1 two and zero ones
1 two and 1 one
1 four, 0 twos, and 0 ones
1 four, 0 twos, and 1 one
1 four, 1 two, and 0 ones
1 four, 1 two, and 1 one
1 eight, 0 fours, 0 twos, and 0 ones
1 eight, 0 fours, 0 twos, and 1 one
1 eight, 0 fours, 1 two, and 0 ones
1 eight, 0 fours,1 two, and 1 one
1 eight, 1 four, 0 twos, and 0 ones
1 eight, 1 four, 0 twos, and 1 one
1 eight, 1 four, 1 two, and 0 ones
1 eight, 1 four, 1 two, and 1 one
1 sixteen, 0 eights,0 fours, 0 twos, and 0 ones

Binary / Decimal Conversion Quiz 1.2.2Convert decimal 6 to a binary? 110

Convert decimal 14 to a binary? 1110

Convert decimal 239 to a binary? 11101111

Convert decimal 256 to a binary? 100000000

Convert decimal 1010 to a binary? 1111110010

Convert Binary 100 to a decimal? 4

Convert Binary 1011 to a decimal? 11

Convert Binary 101010 to a decimal? 42

Convert binary 10001000 to a decimal? 136

Convert binary 11001011 to a decimal? 203

The Processor 1.2.2When a program is running on a computer the processor is constantly performing very many tiny electronic operations. For example, one such operation reads one byte of data from main memory into the processor. Another operation tests if one of the bits in a byte is a 1 bit or a 0 bit. Most processors are able to perform several thousand types of tiny operations like these, and can perform billions of them per second.

The purpose of a high-level language like Java is to organize the tiny electronic operations into large, useful units represented by program statements.

Users and programmers of computers usually don't think about the billions of tiny electronic operations that go on each second. The situation is (very roughly) similar to when you are driving your car. You think about the "big operations" it can perform, such as "accelerate", "turn left", "brake", and so on. You don't think about tiny operations, such as the valves in your engine opening and closing 24,000 times per minute or the crankshaft spinning at 3000 revolutions per minute.

Each Tiny electronic operation that a processor core can perform is called a machine operation. A processor (a machine) performs these one at a time, but billions of then in a second.

A machine instruction consists of several bytes in memory that tell the processor to perfom one machine operation. The processor looks at machine instructions in main memory one after another, and performs one machine operation for each machine instructions. The collection of machine instructions in main memory is called a machine language program or (more commonly) an executable program. A typical processor has a thousand or more different machine instructions.

A machine language program is a sequence of machine language instructions in main memory. A machine instruction consists of one or more bytes. The processor runs a program one machine instruction at a time. All the little machine operations ass up to something useful.

The word execute is often to mean perform the machine operation that an instruction asks for. Execute is also used for an entire program or part of a program: to execute the program turn the switch to on.

A group of machine instructions that executes repeatedly is called a loop. A modern processor executes billions of instructions per second. A program without loops instructions per second. A program without loops would execute for only a few seconds even if it had billions of instructions.

A typical processor is made up of millions of transistors on a small wafer of silicon called an integrated circuit ( also called a chip). Integrated circuits are used for other electronic parts of a computer. For example main memory is implementer with memory chips.

Most modern processor ships have two or more processor on them. Each of the processors on the ship is called a processor core of often just called a core.

Each core has the same set of tiny electronic operations and runs programs independently of the other cores. When a program is running it runs on a single core, which performs the tiny electronic operations of the program one at a time.

There are many types of processors used in computer systems. A computer system is designed around its processor. The electronics of a computer system are designed for a particular type of processor. Different types of processors have different machine operations and different machine languages. A machine language program for one type of processor would make no sense to a different processor type. All processor types have enough power in their little machine operations to create the same large applications. Anything one processor can do with its machine language program another processor can do with a program written in its machine language.

The architecture of a processor is the choices that have been made for its machine operations, how they have been organized and implemented and how they interacts with main memory and other components. Architecture is concerned with the general plan and functions of a processor; it is not much concerned with electronic details.

It is rare for programmers to write programs in machine language . The executable files ( the directly runnable machine language programs) for most applications contain hundreds of thousand of machine language instruction. Most programs are created using a high level programming language such as Java, C, C++ or Basic. With a high level language a programer creates a program using powerful, bit operations which will later be converted into many little machine operations. The machine operations that correspond to this big operation set up a part of main memory to hold a number store the numbers zero there and arrange things so other parts of the program can use it.

A source program is a text file that contains instructions written in a high level language. It can not be executed (made to run) by a processor without some additional steps. A source programs is also called a source file, source code or sometimes just source. Source program is translated into a machine language program. An application program called a translator takes a source program as input and produces a machine language program as output.

A machine language program is also called an executable program, executable file to sometimes just executable.

The word compile means the same thins as translate. So one can say that a source program is compiled into a executable program.

The source program is created using a text editor. It contains instructions in a high level language. It contains bytes that represent characters. The Source program is kept on the hard disk. The source program can not be run by the processor.

The translator program translates the source program into an executable program. The source program remains unchanged; a new executable program is created. The executable program contains machine instructions. A translator translate from a specific high level language (like C) into machine instructions for a specific processor type. The executable program is also kept on hard disk.

The program is run by copying machine language from the executable program on disk into main memory. The processor directly executes these machine language instructions.

Once the source program has been translated into machine code ( the executable program) the machine code can be directly executed by the processor. The source program is only a means to create the machine code.

Ideally only one program needs to be written in the high level language. That source field can then be translated into several executable files. Each containing the correct machine instructions for its intended processor.

The idea of using one source file for executable programs that run on different processors is called the software portability. You would like to write a program just once ( in a high level language) and then run it on any computer system by translating it into that systems machine language. Unfortunately thins do not work out that nicely.

Programs written in a high level language are never directly executed by the processor. You have already seen one way to execute such a program: use a translator to create a machine language program that can be executed directly.

Another way to is use an interpreter for the language. An interpreter is an executable program that runs directly on the processor. An interpreter reads through a source program written in a high level language and performs the actions that the source program asks for. It is being interpreted by the BASIC interpreter, which is an executable program running on the processor.

The BASIC interpreter works by reading in commands of the BASIC source program one by one. Each time it reads in a command, the interpreter does what the command asks. A BASIC command might ask to add two numbers together. The BASIC interpreter is a program and programs can easily ass together two numbers. The BASIC program might then ask to write the sum to the monitor. The BASIC interpreter can easily do that. The BASIC interpreter works by reading in commands of the BASIC source program one by one. Each time it reads in a command the interpreter does what the command asks. A BASIC command might ask to add two numbers together. The BASIC interpreter is a program and programs can easily ass together two numbers. The BASIC program might then ask to write the sum to the monitor. The BASIC interpreter uses the fundamental machine operations of the processor to perform the actions requested in the BASIC source program. But the source program itself is not translated into machine language.

When an interpreter is running a BASIC source program, both the interpreter and the source program are in main memory. The interpreter consists of machine instructions that the hardware can execute directly. The BASIC source program consists of commands that the interpreter can perform. BASIC program, it looks like the commands in BASIC are being directly executed by some sort of machine. The combination looks like a machine that can directly execute BASIC commands. It is as if BASIC commands are the machine language for combination of processor and interpreter.

Virtual is used in situations where software has been used to make something look like the real thing. In this case it looks like we have a machine that can directly execute BASIC, so we can say that we have a BASIC virtual machine.

Translator: takes a complete document in one language and translates it into a complete document in a second language, which can then be used by a reader of the second language.

Interpreter:acts as an intermediate between a speaker of one language and a speaker of another language. Usually an interpreter works one sentence at a time. Immediately after a sentence is spoken in the first language, the translator converts it into the second language.

The Quiz on Processor 1.2.2What part of a computer system is most directly concerned with performing the actions called for by a program? The processor

About how many different fundamental operations can most processors perform? A few hundred

What is a machine operation? One of the tiny electronic operations that a processor can perform.

What is a machine instruction? Several bytes in main memory that tells the processor to perform one machine operation.

Which one of the following statements is False? Each machine instruction can be used only once.

How many machine instructions can execute per second on a modern processor? Millions of instructions per second

What is the architecture of a computer ? The choice of machine operstaions and how they are implemented.

What is a source program?A text file created by a programmer containing instructions written in a high level

What does a computer language compiler do? It takes a source file as input ans produces an executable program as output

What is an interpreter? An interpreter is a program that acts like a processor that can directly execute a high level language

The Software Development Cycle 1.2.3

Software goes through various stages from its conception to its end.

Through each takes a different approach, the various phases of the software development process can be broadly summarized as follows: Planning and Analysis; Designing ; Implementation; Testing and Debugging; Deployment and Maintenance.

The first stage of software development is planning and analysis. In this stage a

requirement analysis is done, which includes finding out what the clients needs are.Once the requirements are gathered, the second and third phase of the software

development process begins. In these phases, a simple version of the program isimplemented using a programming language chosen by the team lead. As the softwareis written, it is tested and debugged to eliminate as many bugs as possible.Once the software is tested and works according to specification, it is deployed and

given to the client. In the maintenance stage, the software is enhanced and anynew found bugs are fixed. If there are new requirements at this stage they can be added.One can add additional features and repeat the steps of implementation, testing, and

deployment as often as required.There are several software development models that are used in the industry.

In the maintenance stage, the development process can return to any of the previous stages if s drawback is encountered, so a bug or flaw in a stage can be fixed in the maintenance stage of the SDLC.

The Programming Process 1.2.4

A program is a set of step-by-step instructions that directs the computer to do the tasks you want it to do and produce the results you want.

Programming helps you understand computers. The computer is only a tool. If you learn how to write simple programs, you will gain more knowledge about how a computer works.

Writing a few simple programs increases your confidence level. Many people find great personal satisfaction in creating a set of instructions that solve a problem.

Learning programming lets you find out quickly whether you like programming and whether you have the analytically turn of mind programmers need. Even if you decide that programming is not for you, understanding the process certainly will increase your appreciation of what programmers and computers can do.

A set of rules that provides a way of telling a computer what operations to perform is called a programming language.

Developing a program involves steps similar to any problem-solving task. There are ingredients in the programming process: defining the problem; planning the solutions; coding the program; testing the program and documenting the program.

Defining the problem: consists of identifying what it is you know (input -given data) and what it is you want to obtain.

Two common ways planning the solution to a problem are to draw a flowchart and to write a pseudo-code, or possibly both. Essentially a flowchart is a pictorial representation of a step-by-step solutions. I t consists of arrow representing the direction the program takes and boxes and other symbols representing actions. It is a map of what your program is going to do and how it is going to do it. ANSI( American Nations Standards Institute) has developed a standard set of flowchart symbols.

Pseudo-code is an English-like nonstandard language that lets you state your solution with more precision than you can in plain English but with less precision than is required when using a formal programming language. Pseudo-code permits you to focus on the program logic without having to be concerned just yet about the precise syntax of a particular programming language. However, pseudo-code is not executable on the computer.

As we have already noted, a programming language is a set of rules that provides a way of instructing the computer what operations to perform. There are many programming languages: BASIC, COBOL, Pascal, FORTRAN, and C are some examples. You may find yourself working with one or more of these.

To get your program to work, you have to follow exactly the rules-the syntax-of the language you are using. Of course, using the language correctly is no guarantee that your program will work, any more than speaking grammatically correct English means you know what you are talking about. The point is that correct use of the language is the required first step. Then your coded program must be keyed, probably using a terminal or personal computer, in a form the computer can understand.

Programmers usually use a text editor, which is somewhat like a word processing program, to create a file that contains the program.

Eventually, after coding the program, you must prepare to test it on the computer. This step involves these phases: Desk-checking. This phase, similar to proofreading, is sometimes avoided by the programmer who is looking for a shortcut and is eager to run the program on the computer once it is written. However, with careful desk-checking you may discover several errors and possibly save yourself time in the long run. In desk-checking you simply sit down and mentally trace, or check, the logic of the program to attempt to ensure that it is error-free and workable. Many organizations take this phase a step further with a walk through, a process in which a group of programmers-your peers-review your program and offer suggestions in a collegial way. Translating. A translator is a program that (1) checks the syntax of your program to make sure the programming language was used correctly, giving you all the syntax-error messages, called diagnostics, and (2) then translates your program into a form the computer can understand. A by-product of the process is that the translator tells you if you have improperly used the programming language in some way. These types of mistakes are called syntax errors. The translator produces descriptive error messages. For instance, if in FORTRAN you mistakenly write N=2 *(I+J))-which has two closing parentheses instead of one-you will get a message that says, "UNMATCHED PARENTHESES." (Different translators may provide different wording for error messages.) Programs are most commonly translated by a compiler. A compiler translates your entire program at one time. The translation involves your original program, called a source module, which is transformed by a compiler into an object module. Prewritten programs from a system library may be added during the link/load phase, which results in a load module. The load module can then be executed by the computer. Debugging. A term used extensively in programming, debugging means detecting, locating, and correcting bugs (mistakes), usually by running the program. These bugs are logic errors, such as telling a computer to repeat an operation but not telling it how to stop repeating. In this phase you run the program using test data that you devise. You must plan the test data carefully to make sure you test every part of the program.

Documenting is an ongoing, necessary process, although, as many programmers are, you may be eager to pursue more exciting computer-centered activities. Documentation is a written detailed description of the programming cycle and specific facts about the program. Typical program documentation materials include the origin and nature of the problem, a brief narrative description of the program, logic tools such as flowcharts and pseudo-code, data-record descriptions, program listings, and testing results. The wise programmer continues to document the program throughout its design, development and testing. Documentation is needed to supplement human memory and to help organize program planning. Documentation is critical to communicate with others who have an interest in the program, especially other programmers who may be part of a programming team.

Java 1.3Java is an object-oriented programming language developed by James Gosling and colleagues at Sun Micro systems in the early 1990s. Unlike conventional languages which are generally designed either to be to be compiled to native (machine ) code, to be interpreted from source code at runtime. Java is intended to be compiled to a bytecode, which is then run ( generally using JIT compilation) by a Java Virtual Machine.

Java was started as a project called "Oak" by James Gosling in June 1991. Gosling's goals were to implement a virtual machine and a language that had a familiar C-like notation but with greater uniformity and simplicity than C/C++. The first public implementation was Java 1.0 in 1995. It made the promise of "Write Once, Run Anywhere", with free run-times on popular platforms. It was fairly secure and its security was configurable, allowing for network and file access to be limited. In 1997, Sun approached the ISO/IEC JTC1 standards body and later the Ecma International to formalize Java, but it soon withdrew from the process. Java remains a proprietary de facto standard that is controlled through the Java Community Process. Sun makes most of its Java implementations available without charge, with revenue being generated by specialized products such as the Java Enterprise System. Sun distinguishes between its Software Development Kit (SDK) and Run time Environment (JRE) which is a subset of the SDK, the primary distinction being that in the JRE the compiler is not present.

There were five primary goals in the creation of the Java Language; It should use the object-oriented programming methodology ; It should allow the same program to be executed on multiple operating systems ; It should contain built-in support for using computer networks ; It should be designed to execute code from remote sources securely ; It should be easy to use by selecting what was considered the good parts of other object-oriented languages.

The first characteristic, object orientation ("OO"), refers to a method of programming and language design. Although there are many interpretations of OO, one primary distinguishing idea is to design software so that the various types of data it manipulates are combined together with their relevant operations. Thus, data and code are combined into entities called objects. An object can be thought of as a self-contained bundle of behavior (code) and state (data).

The principle is to separate the things that change from the things that stay the same; often, a change to some data structure requires a corresponding change to the code that operates on that data, or vice versa.

This separation into coherent objects provides a more stable foundation for a software system's design. The intent is to make large software projects easier to manage, thus improving quality and reducing the number of failed projects.

Another primary goal of OO programming is to develop more generic objects so that software can become more reusable between projects. A generic "customer" object, for example, should have roughly the same basic set of behaviors between different software projects, especially when these projects overlap on some fundamental level as they often do in large organizations. In this sense, software objects can hopefully be seen more as pluggable components, helping the software industry build projects largely from existing and well-tested pieces, thus leading to a massive reduction in development times. Software reusability has met with mixed practical results, with two main difficulties: the design of truly generic objects is poorly understood, and a methodology for broad communication of reuse opportunities is lacking. Some open source communities want to help ease the reuse problem, by providing authors with ways to disseminate information about generally reusable objects and object libraries.

The second characteristic, platform independence, means that programs written in the Java language must run similarly on diverse hardware. One should be able to write a program once and run it anywhere. This is achieved by most Java compilers by compiling the Java language code "halfway" to bytecode (specifically Java bytecode)simplified machine instructions specific to the Java platform. The code is then run on a virtual machine (VM), a program written in native code on the host hardware that interprets and executes generic Java bytecode. Further, standardized libraries are provided to allow access to features of the host machines (such as graphics, threading and networking) in unified ways.

Although there's compiling stage at some point the Java bytecode is interpreted or converted to native machine instructions by the JIT compiler. The first implementations of the language used an interpreted virtual machine to achieve portability. These implementations produced programs that ran more slowly than programs compiled to native executable s, for instance written in C or C++, so the language suffered a reputation for poor performance. More recent JVM implementations produce programs that run significantly faster than before, using multiple techniques. The first technique is to simply compile directly into native code like a more traditional compiler, skipping bytecodes entirely. This achieves good performance, but at the expense of portability. Another technique, known as just-in-time compilation (JIT), translates the Java bytecodes into native code at the time that the program is run which results in a program that executes faster than interpreted code but also incurs compilation overhead during execution. More sophisticated VMs use dynamic recompilation, in which the VM can analyze the behavior of the running program and selectively recompile and optimize critical parts of the program. Dynamic recompilation can achieve optimizations superior to static compilation because the dynamic compiler can base optimizations on knowledge about the runtime environment and the set of loaded classes. JIT compilation and dynamic recompilation allow Java programs to take advantage of the speed of native code without losing portability.

One idea behind Java's automatic memory management model is that programmers should be spared the burden of having to perform manual memory management. In some languages the programmer allocates memory to create any object stored on the heap and is responsible for later manually deallocating that memory to delete any such objects. If a programmer forgets to deallocate memory or writes code that fails to do so in a timely fashion, a memory leak can occur: the program will consume a potentially arbitrarily large amount of memory. In addition, if a region of memory is deallocated twice, the program can become unstable and may crash. Finally, in non garbage collected environments, there is a certain degree of overhead and complexity of user-code to track and finalize allocations. Comparing Java and C++, it is possible in C++ to implement similar functionality (for example, a memory management model for specific classes can be designed in C++ to improve speed and lower memory fragmentation considerably), with the possible cost of extra development time and some application complexity. In Java, garbage collection is built-in and virtually invisible to the developer. That is, developers may have no notion of when garbage collection will take place as it may not necessarily correlate with any actions being explicitly performed by the code they write. Depending on intended application, this can be beneficial or disadvantageous: the programmer is freed from performing low-level tasks, but at the same time loses the option of writing lower level code.

The syntax of Java is largely derived from C++. However unlike C++ which combines the syntax for structured generic and OOP; Java was built for the ground u to be virtually fully OOP; everything in Java is an object with the exception of atomic dataypes.

Java applets are programs that are embedded in other applications typically in a web page displayed in a web browser. An applet is placed in an HTML document using the applet HTML element. The applet tag has three attributes set: Code specifies the name of the applet class and width and height sets the pixel width and height of the applet.

The import statements direct the Java compiler to include all of the public classes and interfaces from the java.io and javax.servlet packages in the compilation. The Hello class extends the GenericServlet class; the GenericServlet class provides the interface for the server to forward requests to the servlet and control the servlet's life-cycle. The service() method is passed a ServletRequest object that contains the request from the client and a ServletResponse object used to create the response returned to the client. The service() method declares that it throws the exceptions ServletException and IOException if a problem prevents it from responding to the request. Java servlets are server-side Java EE components that generate responses to requests from clients.

Swing is the advanced graphical user interface library for the Java SE platform. The import statement directs the Java compiler to include all of the public classes and interfaces from the javax.swing package in the compilation. Note that once the frame is displayed, exiting the main method does not cause the program to terminate because the AWT event dispatching thread remains active until all of the Swing top-level windows have been disposed.

The default look and feel of GUI application written in Java using the swing toolkit is very different from native applications. It is possible to specify a different look and feel through the pluggable look and feel system of Swing.

Java primitive types are not objects. Primitive types hold their values in the stack rather than being references to value. This was a conscious decision by Java's designers for performance reasons. Java is not considered to be a pure OOP language. However as of Java 5.0 auto-boxing enables programmers to write as if primitive types are their wrapper classes and freely interchange between them for improved flexibility. Java designers decided not to implement certain features present in other OO languages to include multiple inheritance; operator overloading; class properties and tuples.

High-Level vs. Low-Level Programming Languages 1.3.2Languages are used to communicate between different entities. Computer language makes it possible to talk to the computers and ask the computer to perform specific work. Computer languages produces programs which are executed by CPU and then only understand programs in their own machine language. Machine language is their language of 0s and 1s, It is difficult to write program in machine language so what is the solution to this dilemma? The answer is in high-level languages.

HLLs are programming languages that look like natural language text. Their advantages are they make programming easier and more abstract IE. the programmer does not need to come up with the detailed machine instructions. HLL programs are machine independent . They can run on different hardware platforms( different computers with different instruction sets).

To run a HLL program on a specific machine, it has to be translated to it's machine language. This is done through the use of a compiler. A compiler is a program that translates a HLL program produced by the compiler is usually referred to as the executable program.

Translating HLL programs to machine language programs is not a one to one mapping. A HLL instruction (usually called a statement) will be translated to one of more machine language instructions. The number of mapped machine instructions depends on the efficiency of the compiler in producing optimized machine language programs from the HLL programs. A machine language program produced by a compiler or an assembler. Usually machine language programs produced by compilers are not efficient contain many unnecessary instructions that increase processing and slow down execution.

Assembly language is the most basic programming language available for any processor. A programmer works only with operations implemented directly on the physical CPU. Assembly language lacks high-level conveniences such as variables and functions and it is not portable between various families of processors. Assembly language is the most powerful computer programming language available and it gives programmers the insight required to write effective code in high-level languages.

Advantages to learning assembly language: very useful for making efficient and fast running programs; very useful for making small programs for embedded system applications; writing compact code.

Compiler is a program that translates the high level programs to machine code either directly or via assembler. It allows the programmer to specify the memory locations for his data and programs and symbolically refer to them in his assembly code. It will translate there symbolic addresses to actual addresses in the produced machine code.

This is the program that is used to link together separately assembled/ compiled programs into a single executable code which finally runs on the CPU.

Assembly programmers use debugger and monitor to alter the contents of memory and registers while running their code. To perform disassemble of their machine code. Permit them to run their programs, stop them , run them step-by-step or insert break points. Break pints are positions in the program that if are encountered during run time, the program will be halted so the programmer can examine the memory and registers contents ans determine what went wrong.

Interpreter vs. Complied Languages 1.3.3A compiler is a computer program that implements a programming language specification to translate programs usually as a set of files which constitute the source code written in source language into their equivalent machine readable instructions.

The source language is always a higher-level language in comparison to machine code, written using some mixture of English words and mathematical notation, assembly language being the lowest compilable language (an assembler being a special case of a compiler that translates assembly language into machine code). Higher-level languages are the most complex to support in a compiler/interpreter, not only because they increase the level of abstraction between the source code and the resulting machine code, but because increased complexity is required to formalize those abstract structures.

The target language is normally a low-level language such as assembly, written with somewhat cryptic abbreviations for machine instructions, in this cases it will also run an assembler to generate the final machine code. But some compilers can directly generate machine code for some actual or virtual computer e.g. byte-code for the Java Virtual Machine. Another common approach to the resulting compilation effort is to target a virtual machine. That will do just-in-time compilation and byte-code interpretation and blur the traditional categorizations of compilers and interpreters.

An interpreter is a computer program which executes the translation of the source program at run-time. It will not generate independent executable programs nor object libraries ready to be included in other programs. A program which does a lot of calculation or internal data manipulation will generally run faster in compiled form than when interpreted. But a program which does a lot of input/output and very little calculation or data manipulation may well run at about the same speed in either case.

Being themselves computer programs, both compilers and interpreters must be written in some implementation language. Up until the early 1970's, most compilers were written in assembly language for some particular type of computer. The advent of C and Pascal compilers, each written in their own source language, led to the more general use of high-level languages for writing compilers. Today, operating systems will provide at least a free C compiler to the user and some will even include it as part of the OS distribution.

At the highest level compilation is broken into a number of parts 1. lexical analysis (tokenizing) 2. syntax analysis (parsings) 3. type checking 4. code generation

any compiler has some essential requirements, which are perhaps more stringent that for most programs: any valid program must be translated correctly, i.e. no incorrect translation is allowed; Any valid program must be rejected and not translated. There will inevitably be some valid programs which can't be translated due to their size or complexity in relation to the hardware available, for example problems due to memory size. The compiler may also have some fixed-size tables which place limits on what can be compiled (some language definitions place explicit lower bounds on the sizes of certain tables, to ensure that programs of reasonable size/complexity can be compiled).

There are also some desirable requirements, some of which may be mutually exclusive: Errors should be reported in terms of the source language or program. The position at which an error was detected should be indicated; if the actual error probably occurred somewhat earlier then some indication of possible cause(s) should also be provided. Compilation should be fast. The translated program should be fast. The translated program should be small. If the source language has some national or international standard: Ideally the entire standard should be implemented. Any restrictions or limits should be well and clearly documented. If extensions to the standard have been implemented: These extensions to the standard have been implemented: these extensions.

There are also possibly controversial requirements to consider: Eros detected when the translated program is running should still be reported in relation to the original source program e.g. line number. Error detected when the translated program is running should include division by 0, running out of memory, use of an array subscript / index which is too big or too small, attempted use of undefined variable' incorrect use of pointers, etc.

For ease of exposition we will divide the compiler into a front end and a back end. These need not even be written in the same implementation language, providing they can communicate effectively via some intermediate representation. The following list itemizes the task carried out by the front end and the back end. Note that the tasks are not carried out in any particular order, as outlined below, and discussed in more detail in subsequent chapters. Front end: lexical analysis- convert character to tokens; syntax analysis check for valid sequence of tokens; semantic analysis check for meaning; some global/ high level optimization.

Back end: some local optimization; register allocation; peep=hole optimization; code generation; instruction scheduling. Almost all the source-language aspects are handled by the front end. Almost all the machine dependent aspects are handled by the back end. It is possible to have different back ends for different computers so that the compiler can produce code for different computers.

The front end is normally controlled by the syntax analysis processing. As necessary the syntax analysis code will call a routine which performs some lexical analysis and returns the next token. At selected points during syntax analysis, appropriate semantic routines the next token. At selected points during syntax analysis, appropriate routines are called which preform any relevant semantic checked and or add information to internal representation.

A computer is an integrated collection of hardware components, which are capable of executing instructions called object code stored in a computer's memory component.The computer's control component takes the object code stored as a string of binary bits(i.e. 0's and 1's), converts the bits to voltage levels, and transmits the voltage levels toits hardware components which carry out, or execute, operations as directed by thevoltages, as specified in the object code. The steps of conversion, transmission, andexecution by hardware components are called interpretation.

Writing instructions in object code (also called the target language, machine language,

or a low level language for some computer hardware) is not easy for humans to do. Alow level target language is a language appropriate for computer hardware, not for humans. Languages that are appropriate for the problems that humans work on arecalled higher level or source languages. Many higher level source languages have been defined over the years, including Java and C++.Analysis of the source program to check that its grammar or syntax has no errors; parse the source program to identify its syntactic elements, e.g. operations and operands and organize the elements into an overall structure and modify this syntax structure to optimize it.

Java Application Programming Interface (API) 1.3.4.3Java application programming interface (API) is a list of all classes that are part of the Java development kit (JDK). It includes all Java packages, classes, and interfaces,along with their methods, fields, and constructors. These prewritten classes provide a tremendous amount of functionality to a programmer. A programmer should be aware of these classes and should know how to use them. A complete listing of all classes in Java API can be found at Oracles website:

If you browse through the list of packages in the API, you will observe that there are packages written for GUI programming, networking programming, managing input and output, database programming, and many more.

Byte Code vs. Machine Code 1.3.5A source program is a text file that contains a program (such as above) written in a programming language.

Java combines these ideas in a way that will take some explaining. To run Java program the source file is first translated into a file of bytecodes.

Java bytecode is a machine instruction for a Java processor. A file of bytecodes is a machine language program for a Java processor. Conceptually a Java processor is a silicon processor chip that directly executes a machine language called Java bytecodes.

The javac program is a compiler that translates the source program into a bytecode file. The bytecode file will contain exactly the same bytecodes no matter what computer the javac compiler runs on. The architecture of the processor that executes Java bytecodes is well-documented and is available to anyone. The Java compiler on a Macintosh will produce the same bytecodes as the Java compiler on an Intel system.

Any computer system can execute a Java bytecode program by using a Java interpreter. The Java interpreter has to be specifically written for that particular computer system but once that is done, the computer system can become a Java virtual machine. Any computer system can execute a Java bytecode program by using a Java interpreter. The Java interpreter has to be specifically written for that particular computer system, but once that is done, the computer system can become a Java virtual machine. That is, it looks like a computer with a hardware Java processor chip and can run Java bytecodes. When a Java program is translated into bytecodes, the bytecodes are the same no matter what computer system is used. A java source program can be written and compiled on one computer to produce bytecode. Now that bytecode can run on any computer that has a Java interpreter.

Java programs are portable, which means that the same bytecode program can run on any computer system that has a Java Interpreter. A source program can be compiled into bytecodes on any computer that has a Java compiler. The source program does not have to be changed to meet the particular needs of a particular computer system. No matter what computer you have, you ca write the same Java programs.

An applet is a Java bytecode program that runs on a Web browser. Most up-to-date Web browsers include a Java interpreter. A web page may contain an applet, which means that part of what the page displays is controlled by Java bytecodes. The computer that hosts the web page sends Java bytecodes to a client computer that has asked for the page. The web browser on the client runs the Java applet using its built in interpreter. Applets are used for user interaction, graphics and animation.

Introduction to Computer Science Using JAVA 1.3.51. Complete the program so that it writes "Good-by" on the computer monitor.class Bye{ public static void main ( String[] args ) { System.out.println("Good-by"); }}2. The source file that this program is saved in should be call Bye.java (Be sure you use correct upper and lower case characters3. To compile the program, enter this command into the DOS window: C:\SomeDir>javac Bye.java4. The compiler will create a file containing bytecodes. This file will be named Bye.class.5. To run the bytecodes, enter this command into the DOS window: C:\SomeDir> java Bye6. The program that interprets the byte codes on your hardware is called the Java Virtual Machine.7. Although the underlying hardware may be different, the Java Virtual Machine on your computer is the same as that on any other computer, and so can run the same byte codes.8. An applet is a Java bytecode program that runs on a Web browser.9. To create a Java source file, use a program called a text editor such as Notepad.10. The Dir command of DOS is used to examine the files in a directory.Programming Language Design 2.1A class is a set of functions that work together to accomplish a task. It can contain or manipulate data, but it usually does so according to a pattern rather that a specific implementation. An instance of a class is considered an object.

An object receives all of the characteristics of a class, including all of its default data and any actions that can be performed by its functions. The object is for use with specific data or to accomplish particular task. To make a distinction between classes and objects, it might help to think of a class as the ability to do something and the object as the execution of that ability in a distinct setting.

A method simply refers to a function that encased in a class.

A parameter is a variable that is passed into a function that instructs it how to act or gives it information to process. Parameter are also sometimes called arguments.

A property is a default set of data stored in a class. A class can have multiple properties and the properties can be changed dynamically through the methods of the class.

classes can inherit methods and properties from other classes by extending them and each class can be extended by multiple classes. This means that you can start with a base (or parent) class that contains shared characteristics among several classes. That base class can then be extended by other classes (children) that are similar but are meant for slightly different purposes. Any changes in the parent class will automatically cascade to its children.

DRY stands for Don't Repeat Yourself and it means just that. If you write some code, you shouldn't have to repeat that particular code ever again. In practical terms, it means thinking more abstractly and planning a little better at the outset. I'll give an example shortly.

KISS stands for Keep It Simple, Stupid and means that you should try to write code that accomplishes its goal in the simplest manner possible. Simpler means fewer possibilities for errors and easier maintenance. In the context of OOP, this usually means making sure that each method has only one task. If you find that a method does more than one thing, it usually means that it can be re-factored into several smaller methods, each dedicated to a specific task.

Improved software-development productivity: Object-oriented programming is modular, as it provides separation of duties in object-based program development. It is also extensible, as objects can be extended to include new attributes and behaviors. Objects can also be reused within an across applications. Because of these three factors modularity, extensibility, and re-usability object-oriented programming provides improved software-development productivity over traditional procedure-based programming techniques.

Improved software maintainability: For the reasons mentioned above, objectoriented software is also easier to maintain. Since the design is modular, part of the system can be updated in case of issues without a need to make large-scale changes.

Faster development: Reuse enables faster development. Object-oriented programming languages come with rich libraries of objects, and code developed during projects is also reusable in future projects.

Lower cost of development: The reuse of software also lowers the cost of development. Typically, more effort is put into the object-oriented analysis and design, which lowers the overall cost of development.

Higher-quality software: Faster development of software and lower cost of development allows more time and resources to be used in the verification of the software. Although quality is dependent upon the experience of the teams, object oriented programming tends to result in higher-quality software.

Steep learning curve: The thought process involved in object-oriented programming may not be natural for some people, and it can take time to get used to it. It is complex to create programs based on interaction of objects. Some of the key programming techniques, such as inheritance and polymorphism, can be challenging to comprehend initially.

Larger program size: Object-oriented programs typically involve more lines of code than procedural programs.

Slower programs: Object-oriented programs are typically slower than procedure based programs, as they typically require more instructions to be executed.

Not suitable for all types of problems: There are problems that lend themselves well to functional-programming style, logic-programming style, or procedure-based programming style, and applying object-oriented programming in those situations will not result in efficient programs.

Fundamental Concepts of OO Programming 2.2Real-world objects share two characteristics: they all have state and behavior. Dos have state( name color breed, hungry) and behavior ( barking, fetching, wagging tail.)Identifying that state and behavior for real-world objects is a great way to being thinking in terms of object-oriented programming.

a software object.A object stores its state in fields ( variables in some programming languages) and exposes its behavior through methods ( functions in some programming languages). Methods operate on an object's internal state and serve as the primary mechanism for object to object communication.

Hiding internal state and requiring all interaction to be performed through an object's methods is known as data encapsulation.

Bundling code into individual software objects provides a number of benefits, including: modularity: the source code for an object can be written and maintained independently of the source code for other objects. One created, an object can be easily passed around inside the system. Information hiding: By interacting only with an objects methods, the details of its internal implementation remain hidden from the outside world. Code re-use: If an object already exists ( perhaps written by another software developer). You can use that object in your program. This allows specialist to implement/ test/debug complex, task specific objects, which you can then trust to run in your own code. Pluggability and debugging ease: 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 analogous to fixing mechanical problems in the real world. It a bolt breaks you replace it, not the entire machine.

A class is the blue print from which individual object are created.

Software engineering is concerned with the construction of correct, working, well written programs.

The structured programming approach to program design was based on the following advice: to solve a large problem, break the problem into several pieces and work on each piece separately; to solve each piece, treat it as a new problem which can itself be broken down into smaller problems; eventually you will work your way down to problems that can be solved directly, without further decomposition. The approach is called top-down programming. It is a valuable and often-used approach to problem solving. However it is incomplete. It deals almost entirely with producing the instructions necessary to solve a problem yet as time when on people realized that the design of the data structures for the program as a least as important as the design of subroutines and control structures. With strict top down programming is that is makes it difficult to reuse work sone for other projects. By starting with a particular problem and subdividing it into convenient pieces top down programming tends to produce a design that is unique to that problem. It is unlikely that you will be able to take a large chunk of programming from another program and fit it into your project, at least not without extensive modification. Producing high quality programs is difficult and expensive so programmers and the people who employ them are always eager to reuse past work.

In practice top down design is often combined with botton-up designing. In bottom up design the approach is to start at the bottom with problems that you already know how to solve ( and for which you might already reusable software component at hand. From there you can work upwards towards a solution to the overall problem. The reusable components should be modular as possible.

The reusable components should be a modular as possible. A module is a component of a larger system that interacts with the rest of the system in a simple well-defined, straightforward manner. The idea is that a module can be plugged into a system. The details of what goes on inside the module as not important to the system as a whole as long as the module fulfills its assigned role correctly. This is called information hiding, ans it is one of the most important principles of software engineering.

One common format for software modules is to contain some data along with some subroutine for manipulation that data. This protects the data, since it can only be manipulated in know well defined ways. And it makes it easier for programs to use the module. Since they don't have to worry about the details of how the data is represented. Information about the representation of the data is hidden.

OOP is the central concept of object oriented programming is the object which is a kind of module containing data and subroutines. The point of view in OOP is that an object is a kind of self-sufficient entity that has an integrable state and that can respond to messages. The OOP approach to software engineering is to start by identifying the objects involved in a problem and the messages that those objects should responding to. The program that results is a collection of objects each with its own data and its own set of responsibilities. The objects interact by sending messages to each other. There is not much top down in such a program .

You should think of objects as knowing how to respond to certain messages. Different objects might respond to the same message in different ways. This property of objects that different objects can respond to the same message in different ways is called polymorphism.

It is common for objects to bear a kind of family relationship to one another. Objects that contain the same type of data and that respond to the same message in the same way belong to the same class. ( In actual programming the class is primary that is a class created and then one or more objects are created using that class a template.) But objects can be similar without being in exactly the same class.

Consider a drawing program that lets the user draw lines , rectangles, ovals , polygons, and curves on the screen. In the program each visible object on the screen could be represented by a software object in the program. There would be five classes of objects in the program, on for each type of visible object that can be drawn. All the lines would belong to one class, all the rectangles to another class and so on. These classes are obviously related ; all of them represent drawable objects. They would for example all presumable be able to respond to a draw yourself message. Another level of grouping , based on the data needed to represent each type of object, is less obvious, but would be very useful in a program: we can group polygons and curves together as multiple point objects while lines rectangles and ovals are two point objects. ( A line is determined by its endpoints, a rectangle by two of its corners, and an oval by two corners of the rectangle that contains it.) We could diagram these relationships as follows: DrawableObject, MultipointObject, and TwoPointObject would be classes in the program. MultipointObject and TwoPointObject would be subclasses of DrawableObject. The class Line would be a subclass of TwoPointObject and (indirectly) of DrawableObject. A subclass of a class is said to inherit the properties of that class. The subclass can add to its inheritance and it can even "override" part of that inheritance (by defining a different response to some method). Nevertheless, lines, rectangles, and so on are drawable objects, and the class DrawableObject expresses this relationship.

Inheritance is a powerful means of organizing a program. It is also related to the problem of reusing software components. A class is the ultimate reusable component. Not only can it be reused directly if it fits exactly into a program you are trying to write, but if it just almost fits, you can it be reused directly if it fits exactly into a program you are trying to write, but it just almost fits, you can still reuse it by defining a subclass and making only the small changes necessary to adapt it exactly to your needs.

OOP is meant to be both a superior program-development tool and a partial solution to the software reuse problem.

Encapsulation is to put both data, and operations that can be performed on this data, in a single class. The advantages of encapsulation include information hiding, which means the user does not need to know the implementation details of the internal design, but is still be able to access and modify the data through public operations provided.

Inheritance is to reuse the existing classes when creating a new class. The derived class will inherit public operations defined in the base class.

OOP allows classes to inherit commonly used state and behavior from other classes. In the Java programming language each class is allowed to have one direct super-class and each super-class has the potential for unlimited number of subclasses.

The syntax for creating a subclass is simple . At the beginning of your class deceleration use the extends keyword followed by the name of the class to inherit from.

This gives all the same fields and methods of the super-class yet allows its code to focus exclusively on the features that make it unique. The makes code for your subclasses easy to read. However, you must take care to properly document the state and behavior that each super-class defines, since that code will not appear in the source file of each subclass.

Inheritance is the capability of a class to use the properties and methods of another class while its own functionality. The concept of inheritance greatly enhances the ability to reuse code as well as making design a simpler and cleaner process. Java uses the extends keyword to set the relationship between a parent class and child class.

The class assumes or inherit all the properties of the box class and can now add its own properties and methods as well as override existing methods. Overriding means creating a new set of method statements for the same method signature.

Overriding means creating a new set of method statements for the same method signature ( name, number of parameters and parameter types. When extending a class constructor, the super-class constructor and overridden super-class methods can be reused by using the reserved word super. Note that this reference must come first in the subclass constructor. The reserved word this is used to distinguish between the object's property and the passed in parameter. The reserved word this can also be used to reference private constructors which are useful in initializing properties.

The super-class contains properties and methods common to all of the sub-classes. Often the super-class will be set up as an abstract class which does not allow objects of its prototype to be created. In this case only objects of the subclass are used. To do this the reserved word abstract is included in the class definition.

Abstract method are methods with no body specification. Sub-classes must provide the method statements for their specific meaning. If the method was provided by the super-class, it would require overriding in each subclass. And if one forgot to override, the applied method statements may be inappropriate.

Abstract classes and methods force prototype standards to be followed.

Interfaces are similar to abstract classes but all methods are abstract and all properties are static final. Interfaces can be inherited. As with classes the extends keyword is used for inheritance. Java does not allow multiple inheritance for classes (ie. A subclass being the extension of more than one super-class. An interface is used to tie elements of several classes together. Interfaces are also used to compilation and parameter consistency testing prior to the coding phases. Interfaces are also used to set up unit testing frameworks. Since this interface has the method called work(), that method must be defined in any class using the working interface. When a class that uses an interface is created, reference the interface with the phrase implements Interface_list. Interface_list is one or more interfaces as multiple interfaces are allowed. Any class that implements an interface must include code for all methods in the interface. This ensures commonality between interfaced objects.

Polymorphism is the ability of an object to take on many forms. In programming languages polymorphism is the capability of an action of method to do different things based on the object that it is acting upon. This is the third basic principle of OOP. The three types of polymorphism are: ad-hoc (overloading and overriding) parametric (ie generic typing) and dynamic method binding.

Overloaded methods are methods with the same name signature but either a different number os parameters of different types in the parameter list. By defining a method for handling each type of parameter one controls the desired effect.

Over ridden methods are methods that are redefined within an inherited or subclass. They have the same signature and the subclass definition is used.

Dynamic or late method binding is the ability of a program to resolve references to subclass methods at runtime. For example assume that three sub-classes have been crested based on the abstract class each having their one speak() method. Although each method reference is to an super-class the program will resole the correct method reference at runtime.

Once a class has been specified a data-type exists with the same name. Specific instances of discrete copies of a class can be created by the assignment operator and the new memory allocation operator.

To reference object variables and methods use dot notation. Use class_name.variable to class_name.method_name(args) for static variables or methods. Use instance_name.variable or instance_name.method_name(args) for instance objects declared with new.

An object does not need to be destroyed or removed when it is no