06.06.2013 Views

Computer Programming with GNU Smalltalk - Free

Computer Programming with GNU Smalltalk - Free

Computer Programming with GNU Smalltalk - Free

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Appendix C: Answers of Review Questions<br />

Chapter 1<br />

Answers of Review Questions 89<br />

1. Because of the hardware design, computers can only understand two states. We represent this two<br />

states <strong>with</strong> digits 0 and 1. Combinations of zeros and ones generate some commands that computer<br />

hardware understands. We call these command groups which provide a communication between us<br />

and computer hardware as programming language.<br />

We need them to communicate <strong>with</strong> computer hardware, because computer hardware can<br />

understand only two states and the programming language we use is eventually translated into the<br />

sum of combinations of this two states which is called machine language.<br />

2. Programs written in a compiled language should be translated into machine language by other<br />

programs called compiler before the execution by the user.<br />

Programs written in an interpreted language is converted to machine code during the execution time<br />

by other programs called interpreter. They do not need a compilation process before they can be<br />

executed by the user but they are a little bit slower than compiled machines, though this is mostly<br />

not a problem anymore for modern computers and for not-so-performance sensitive projects.<br />

Although <strong>Smalltalk</strong> is designed as a language which uses a virtual machine to work, <strong>GNU</strong> <strong>Smalltalk</strong><br />

acts more like an interpreted language.<br />

3. A programming paradigm is how a programming language looks at the problems to be solved.<br />

4. Yes. Such programming languages are called multi-paradigm programming languages.<br />

No, <strong>GNU</strong> <strong>Smalltalk</strong> allows programmers to use only object-oriented programming paradigm.<br />

5. From decimal to binary:<br />

So the answer is: 1000011111<br />

From decimal to octal:<br />

543/2=271 remainder 1<br />

271/2=135 remainder 1<br />

135/2=67 remainder 1<br />

67/2=33 remainder 1<br />

33/2=16 remainder 1<br />

16/2=8 remainder 0<br />

8/2=4 remainder 0<br />

4/2=2 remainder 0<br />

2/2=1 remainder 0

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!