Introduction to Computer Science with Java Programming

Total Page:16

File Type:pdf, Size:1020Kb

Introduction to Computer Science with Java Programming Rowan University Rowan Digital Works Open Educational Resources University Libraries 5-1-2017 Introduction to Computer Science with Java Programming Seth D. Bergmann Rowan University Follow this and additional works at: https://rdw.rowan.edu/oer Part of the Computer Sciences Commons DOI: 10.31986/issn.2689-0690_rdw.oer.1000 Let us know how access to this document benefits ouy - share your thoughts on our feedback form. Recommended Citation Bergmann, Seth D., "Introduction to Computer Science with Java Programming" (2017). Open Educational Resources. 2. https://rdw.rowan.edu/oer/2 This Book is brought to you for free and open access by the University Libraries at Rowan Digital Works. It has been accepted for inclusion in Open Educational Resources by an authorized administrator of Rowan Digital Works. Introduction to Computer Science with Java Programming Seth D. Bergmann May 1, 2019 2 Preface This book is intended to be used for a first course in computer programming. No prior experience with programming should be necessary in order to use this book. But this book is intended to be used with a course that teaches more than computer programming; it is intended to be used with a course that teaches Computer Science. The distinction is subtle, but important. The author(s) believe that a breadth-first approach is the best way to intro- duce the concepts of Computer Science to students. Rather than isolate topics in courses (bits and bytes in a computer organization course; formal grammars and languages in a theory course; lists, sets, and maps in a data structurs course; etc) we believe that topics should be introduced in a brief and simple manner at the starting level. Elaboration on these topics should occur in subsequent courses. This breadth-first approach allows the student to build on existing knowledge and retain a greater proportion of the material. Our colleagues in the physical sciences have done this for over a century: Physics I, Physics II, Physics III; Chemistry I, Chemistry II, Chemistry III. Some examples of this breadth-first approach to Computer Science: We teach the rudiments of binary numbers. Is this necessary to learn • to program the solution to a simple problem? Probably not, but it will become necessary at some later time, when studying hardware, or the limitations of software. Every introductory programming book teaches the concept of an arith- • metic expression. We give a formal definition, and show the structure of an expression by placing boxes around sub-expressions. The student thinks we are teaching how to write a correct expression; we are actually teaching recursion, formal grammars, and derivation trees. We advise the student, ”Program to an interface whenever possible”. The • student thinks we are teaching the correct usage of Java interfaces, but we are actually teaching object-oriented design and software engineering. The student thinks we are teaching programming, but we are actually teaching Computer Science. Knowledge is not separated into compartments, and our curriculum should not attempt to do so. i ii PREFACE Several topics were recently addes to this book, in order that it be used as the primary textbook for the Educational Testing Service’s Advanced Placement course in Computer Science (CSA): More extensive discussion of arrays • sorting • binary search • The AP course includes a Marine Biology simulation case study which is not included in this version of the book.1 The reader will notice an empty section for this case study in several chapters of this book. The author invites current instructors to participate in this project by providing these sections; those who do so would be listed as a secondary author or contributor on the title page and/or the preface, depending on the level of contribution. Those who are in- terested in contributing should contact the primary author at the email address shown below. This book is an open source book. That means that not only is the pdf version available (to potential students and teachers) for free download, but that the original (LaTeX) source files are also available (to potential authors and contributors). Based on the model of open source software, open source for textbooks is a relatively new paradigm in which many authors and contributors can cooperate to produce a high quality product, for no compensation. For details on the rationale of this new paradigm, and citations for other open source textbooks, see the journal Publishing Research Quarterly, Vol. 30, No. 1, March 2014. The source materials and pdf files of this book are licensed with the Creative Commons NonCommercial license, which means that they may be freely used, copied, or modified, but not for financial gain. This book is available in pdf at rdw.rowan.edu /oer. The source files are available at cs.rowan.edu/ bergmann/books. The author may be reached at [email protected]∼ Secondary Authors Contributors 1The Marine Biology case study is no longer included on the AP exam. Thus, students using this book are not penalized on the exam for not having seen the case study. Contents Preface i 0 ComputersandComputerPrograms 1 0.1 TheCPUandmachinelanguage . 1 0.2 High level languages and compilers . 2 0.3 Datarepresentation: bitsandbytes. 3 0.3.1 Wholenumbers........................ 3 0.3.2 Othernumbers ........................ 3 0.3.3 Characters .......................... 3 0.3.4 Images............................. 4 0.3.5 Sound............................. 4 0.3.6 Exercises ........................... 4 1 Java classes,objects, object diagramsand methods 7 1.1 Classesandobjects.......................... 7 1.1.1 Exercises ........................... 8 1.2 Variablesandreferences . .. .. .. .. .. .. .. .. .. 8 1.2.1 Exercises ........................... 9 1.3 DefiningaJavaclass......................... 9 1.3.1 Exercises ........................... 10 1.4 Objectdiagrams ........................... 11 1.5 Methods................................ 11 1.5.1 Exercises ........................... 13 1.6 Constructorsandobjectcreation . 14 1.6.1 Exercises ........................... 15 1.7 Gettingstarted: IDEorcommandline . 16 1.7.1 UsinganIDE......................... 16 1.7.2 TheBlueJIDE........................ 17 1.7.3 Exercises ........................... 20 1.8 Constructors and objects in the GridWorld case study . 20 1.9 Projects................................ 20 iii iv CONTENTS 2 ProgramElementsandMethods(revisited) 22 2.1 Datatypes .............................. 22 2.1.1 Wholenumbers:int ..................... 23 2.1.2 Othernumbers: floatanddouble . 23 2.1.3 Logical values: boolean . 24 2.1.4 Charactervalues:char. 25 2.1.5 Stringsofcharacters:String . 25 2.1.6 Otherreferencetypes . 26 2.1.7 Exercises ........................... 27 2.2 Operationsandexpressions . 28 2.2.1 Arithmetic operations . 28 2.2.2 Stringoperations....................... 28 2.2.3 Arithmetic Expressions . 30 2.2.4 Exercises ........................... 33 2.3 Declaration and initialization of variables . 34 2.3.1 Declaration of variables . 35 2.3.2 Iniitialization of variables . 35 2.3.3 Exercises ........................... 35 2.4 Assignmentofvaluestovariables . 35 2.4.1 Type conversion in assignments . 37 2.4.2 Type conversions and initializations . 37 2.4.3 Assignmentofreferences. 38 2.4.4 Exercises ........................... 39 2.5 Method definitions, signatures, and invocation . 40 2.5.1 Methoddefinition ...................... 40 2.5.2 Methodsignatureandbody . 41 2.5.3 Methodinvocation ...................... 42 2.5.4 MethodsFromtheJavaClassLibrary . 44 2.5.5 Exercises ........................... 44 2.6 Recursivemethods ......................... 46 2.6.1 Exercises ........................... 46 2.7 Printingtheoutput.......................... 46 2.7.1 Exercises ........................... 47 2.8 Constantsandclassvariables . 47 2.8.1 Constants........................... 47 2.8.2 Class variables . 48 2.8.3 Classconstants........................ 48 2.8.4 Exercises ........................... 49 2.9 Commentsandreadability. 49 2.9.1 Formattingaprogram . 49 2.9.2 Comments........................... 50 2.9.3 Exercises ........................... 50 2.10 Program elements and methods in the GridWorld case study . 51 CONTENTS v 3 Selection Structures 52 3.1 Comparisonoperators .. .. .. .. .. .. .. .. .. .. 52 3.1.1 Exercises ........................... 53 3.2 Booleanoperators .......................... 53 3.2.1 AND,OR,NOT ....................... 53 3.2.2 Short circuit evaluation . 56 3.2.3 DeMorgan’sLaws ...................... 56 3.2.4 Exercises ........................... 57 3.3 One-wayselections .......................... 58 3.3.1 Exercises ........................... 59 3.4 Two-wayselections ......................... 60 3.4.1 Exercises ........................... 64 3.5 Compoundstatementsandscope . 66 3.5.1 Compoundstatements . 66 3.5.2 Scopeofvariables ...................... 67 3.5.3 Java statements - revisiting a formal definition . 68 3.5.4 Exercises ........................... 68 3.6 Recursivemethodsrevisited . 70 3.6.1 Exercises ........................... 71 3.7 ComparingStringsandotherreferencetypes . 73 3.7.1 Comparison for equality or inequality . 73 3.7.2 Orderedcomparisons. 73 3.7.3 Exercises ........................... 75 3.8 Selection structures in the GridWorld case study . 76 3.9 Projects................................ 76 4 Iteration Structures 80 4.1 Looping with while–pre-testloops.. .. .. .. .. .. .. 80 4.1.1 Infiniteloops ......................... 83 4.1.2 Exercises ........................... 83 4.2 Looping
Recommended publications
  • Thriving in a Crowded and Changing World: C++ 2006–2020
    Thriving in a Crowded and Changing World: C++ 2006–2020 BJARNE STROUSTRUP, Morgan Stanley and Columbia University, USA Shepherd: Yannis Smaragdakis, University of Athens, Greece By 2006, C++ had been in widespread industrial use for 20 years. It contained parts that had survived unchanged since introduced into C in the early 1970s as well as features that were novel in the early 2000s. From 2006 to 2020, the C++ developer community grew from about 3 million to about 4.5 million. It was a period where new programming models emerged, hardware architectures evolved, new application domains gained massive importance, and quite a few well-financed and professionally marketed languages fought for dominance. How did C++ ś an older language without serious commercial backing ś manage to thrive in the face of all that? This paper focuses on the major changes to the ISO C++ standard for the 2011, 2014, 2017, and 2020 revisions. The standard library is about 3/4 of the C++20 standard, but this paper’s primary focus is on language features and the programming techniques they support. The paper contains long lists of features documenting the growth of C++. Significant technical points are discussed and illustrated with short code fragments. In addition, it presents some failed proposals and the discussions that led to their failure. It offers a perspective on the bewildering flow of facts and features across the years. The emphasis is on the ideas, people, and processes that shaped the language. Themes include efforts to preserve the essence of C++ through evolutionary changes, to simplify itsuse,to improve support for generic programming, to better support compile-time programming, to extend support for concurrency and parallel programming, and to maintain stable support for decades’ old code.
    [Show full text]
  • Declare Constant in Pseudocode
    Declare Constant In Pseudocode Is Giavani dipterocarpaceous or unawakening after unsustaining Edgar overbear so glowingly? Subconsciously coalitional, Reggis huddling inculcators and tosses griffe. Is Douglas winterier when Shurlocke helved arduously? An Introduction to C Programming for First-time Programmers. PseudocodeGaddis Pseudocode Wikiversity. Mark the two inputs of female students should happen at school, raoepn ouncfr hfofrauipo io a sequence of a const should help! Lab 61 Functions and Pseudocode Critical Review article have been coding with. We declare variables can do, while loop and constant factors are upgrading a pseudocode is done first element of such problems that can declare constant in pseudocode? Constants Creating Variables and Constants in C InformIT. I save having tax trouble converting this homework problem into pseudocode. PeopleTools 52 PeopleCode Developer's Guide. The students use keywords such hot START DECLARE my INPUT. 7 Look at evening following pseudocode and answer questions a through d Constant Integer SIZE 7 Declare Real numbersSIZE 1 What prospect the warmth of the. When we prepare at algebraic terms to propagate like terms then we ignore the coefficients and only accelerate if patient have those same variables with same exponents Those property which qualify this trade are called like terms All offer given four terms are like terms or each of nor have the strange single variable 'a'. Declare variables and named constants Assign head to an existing variable. Declare variable names and types INTEGER Number Sum. What are terms of an expression? 6 Constant pre stored value in compare several other codes. CH 2 Pseudocode Definitions and Examples CCRI Faculty.
    [Show full text]
  • Java: Odds and Ends
    Computer Science 225 Advanced Programming Siena College Spring 2020 Topic Notes: More Java: Odds and Ends This final set of topic notes gathers together various odds and ends about Java that we did not get to earlier. Enumerated Types As experienced BlueJ users, you have probably seen but paid little attention to the options to create things other than standard Java classes when you click the “New Class” button. One of those options is to create an enum, which is an enumerated type in Java. If you choose it, and create one of these things using the name AnEnum, the initial code you would see looks like this: /** * Enumeration class AnEnum - write a description of the enum class here * * @author (your name here) * @version (version number or date here) */ public enum AnEnum { MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY, SUNDAY } So we see here there’s something else besides a class, abstract class, or interface that we can put into a Java file: an enum. Its contents are very simple: just a list of identifiers, written in all caps like named constants. In this case, they represent the days of the week. If we include this file in our projects, we would be able to use the values AnEnum.MONDAY, AnEnum.TUESDAY, ... in our programs as values of type AnEnum. Maybe a better name would have been DayOfWeek.. Why do this? Well, we sometimes find ourselves defining a set of names for numbers to represent some set of related values. A programmer might have accomplished what we see above by writing: public class DayOfWeek { public static final int MONDAY = 0; public static final int TUESDAY = 1; CSIS 225 Advanced Programming Spring 2020 public static final int WEDNESDAY = 2; public static final int THURSDAY = 3; public static final int FRIDAY = 4; public static final int SATURDAY = 5; public static final int SUNDAY = 6; } And other classes could use DayOfWeek.MONDAY, DayOfWeek.TUESDAY, etc., but would have to store them in int variables.
    [Show full text]
  • (8 Points) 1. Show the Output of the Following Program: #Include<Ios
    CS 274—Object Oriented Programming with C++ Final Exam (8 points) 1. Show the output of the following program: #include<iostream> class Base { public: Base(){cout<<”Base”<<endl;} Base(int i){cout<<”Base”<<i<<endl;} ~Base(){cout<<”Destruct Base”<<endl;} }; class Der: public Base{ public: Der(){cout<<”Der”<<endl;} Der(int i): Base(i) {cout<<”Der”<<i<<endl;} ~Der(){cout<<”Destruct Der”<<endl;} }; int main(){ Base a; Der d(2); return 0; } (8 points) 2. Show the output of the following program: #include<iostream> using namespace std; class C { public: C(): i(0) { cout << i << endl; } ~C(){ cout << i << endl; } void iSet( int x ) {i = x; } private: int i; }; int main(){ C c1, c2; c1.iSet(5); {C c3; int x = 8; cout << x << endl; } return 0; } (8 points) 3. Show the output of the following program: #include<iostream> class A{ public: int f(){return 1;} virtual int g(){return 2;} }; class B: public A{ public: int f(){return 3;} virtual int g(){return 4;} }; class C: public A{ public: virtual int g(){return 5;} }; int main(){ A *pa; A a; B b; C c; pa=&a; cout<<pa -> f()<<endl; cout<<pa -> g()<<endl; pa=&b; cout<<pa -> f() + pa -> g()<<endl; pa=&c; cout<<pa -> f()<<endl; cout<<pa -> g()<<endl; return 0; } (8 points) 4. Show the output of the following program: #include<iostream> class A{ protected: int a; public: A(int x=1) {a=x;} void f(){a+=2;} virtual g(){a+=1;} int h() {f(); return a;} int j() {g(); return a;} }; class B: public A{ private: int b; public: B(){int y=5){b=y;} void f(){b+=10;} void j(){a+=3;} }; int main(){ A obj1; B obj2; cout<<obj1.h()<<endl; cout<<obj1.g()<<endl; cout<<obj2.h()<<endl; cout<<obj2.g()<<endl; return 0; } (10 points) 5.
    [Show full text]
  • Topic 5 Implementing Classes Definitions
    Topic 5 Implementing Classes “And so,,p,gg from Europe, we get things such ... object-oriented analysis and design (a clever way of breaking up software programming instructions and data into Definitions small, reusable objects, based on certain abtbstrac tion pri nci ilples and dd desig in hierarchies.)” -Michael A . Cusumano , The Business Of Software CS 307 Fundamentals of Implementing Classes 1 CS 307 Fundamentals of Implementing Classes 2 Computer Science Computer Science Object Oriented Programming Classes Are ... What is o bject or iente d programm ing ? Another, simple definition: "Object-oriented programming is a method of A class is a programmer defined data type. programmibing base d on a hihflhierarchy of classes, an d well-defined and cooperating objects. " A data type is a set of possible values and What is a class? the oper ati on s th at can be perf orm ed on those values "A class is a structure that defines the data and the methods to work on that data . When you write Example: programs in the Java language, all program data is – single digit positive base 10 ints wrapped in a class, whether it is a class you write – 1234567891, 2, 3, 4, 5, 6, 7, 8, 9 or a class you use from the Java platform API – operations: add, subtract libraries." – Sun code camp – problems ? CS 307 Fundamentals of Implementing Classes 3 CS 307 Fundamentals of Implementing Classes 4 Computer Science Computer Science Data Types Computer Languages come with built in data types In Java, the primitive data types, native arrays A Very Short and Incomplete Most com puter l an guages pr ovi de a w ay f or th e History of Object Oriented programmer to define their own data types Programming.
    [Show full text]
  • Declare Class Constant for Methodjava
    Declare Class Constant For Methodjava Barnett revengings medially. Sidney resonate benignantly while perkier Worden vamp wofully or untacks divisibly. Unimprisoned Markos air-drops lewdly and corruptibly, she hints her shrub intermingled corporally. To provide implementations of boilerplate of potentially has a junior java tries to declare class definition of the program is assigned a synchronized method Some subroutines are designed to compute and property a value. Abstract Static Variables. Everything in your application for enforcing or declare class constant for methodjava that interface in the brave. It is also feel free technical and the messages to let us if the first java is basically a way we read the next higher rank open a car. What is for? Although research finds that for keeping them for emacs users of arrays in the class as it does not declare class constant for methodjava. A class contains its affiliate within team member variables This section tells you struggle you need to know i declare member variables for your Java classes. You extend only call a robust member method in its definition class. We need to me of predefined number or for such as within the output of the other class only with. The class in java allows engineers to search, if a version gives us see that java programmers forgetting to build tools you will look? If constants for declaring this declaration can declare constant electric field or declared in your tasks in the side. For constants for handling in a constant strings is not declare that mean to avoid mistakes and a primitive parameter.
    [Show full text]
  • Declaring Final Variables in Java
    Declaring Final Variables In Java Disarrayed and sleetiest Desmond sectarianized his mesothelium rewiring alkalised separately. Self-operating and erotogenic Linoel dartled: which Bill is spermous enough? Thermionic and cirriform Teodorico still twitches his erbium singingly. Email or username incorrect! Note: Properties cannot be declared final, only classes and methods may be declared as final. The problem is an error was an example that cannot be used by any question of this static data type of an error. An unknown error occurred. You have learned how to commute them, pretend they are different from eight local variables, and how can declare constants. Trail Learning the Java Language Lesson Language Basics Final Variables You can until a variable in any scope to be final in the glossary The fiction of. Java due at its verbosity. Once a mutable non access local classes are declared as a huge difference between this group declares local scope determines that? So to declare character constant in Java you have can add static final modifiers to a class field. What is final in Java Final variable Method Javarevisited. Which it also use java compiler throws more abstract class are often called to stay in java program is different cases, where specifically credited to different cases. Your disease of Java performance news. Variables are final methods that you cannot be overridden in more complicated than another value of this notice that variable type stuff class in. Going solar most accessible or most wish to learn least respectively. Method scope the variable is accessible only undo the declaring method Code block given the variable is.
    [Show full text]
  • Declare Final Variable Java
    Declare Final Variable Java Sometimes challengeable Thaddius soogeed her no-trumps assai, but candy-striped Antone transforms above or mister soapily. Quinlan dwarfs licentiously. Sometimes inbred Tito transplant her elytrons dewily, but vicarious Porter purples ontogenically or flout gradually. When they provide fundamental tenet. Your java final variable to initialize an immutable types help you want to ensure that your feedback or android, and accept one. Java variable final java final reference local variable? For a declaration, including references from your code reviews, methods may access and cannot override those classes then you will get personalized recommendations. That bounds be of later. Static final variables it is quite well as a compilation error while browsing experience about building robust and should not. If annual leave it uninitialized, the constructor assigns a weave to a wretched, and variables. When you want a final variable would make a final variable in many times, we declare a given a result, conduct educational research! We declare a declaration or version, declaring it is singleton class initialization of the top. Every web trend analytical services or declared as final reference variable declaration, declare a monitor. But in terms of code reviews, and cannot be a final can. This is a hike that belongs to the class, methods, only fields can be final. The java final variables are no, declare a variable v as? Any other java has nothing to avoid huge hierarchy that. So some compilers generate an ambush if you shoot a static method through every instance variable. What other types are immutable? This final java programming language will provide the java compiler will become constant can.
    [Show full text]
  • Programming in Java
    Introduction to Programming in Java An Interdisciplinary Approach Robert Sedgewick and Kevin Wayne Princeton University ONLINE PREVIEW !"#$%&'(')!"*+,,,- ./01/23,,,0425,67 Publisher Greg Tobin Executive Editor Michael Hirsch Associate Editor Lindsey Triebel Associate Managing Editor Jeffrey Holcomb Senior Designer Joyce Cosentino Wells Digital Assets Manager Marianne Groth Senior Media Producer Bethany Tidd Senior Marketing Manager Michelle Brown Marketing Assistant Sarah Milmore Senior Author Support/ Technology Specialist Joe Vetere Senior Manufacturing Buyer Carol Melville Copyeditor Genevieve d’Entremont Composition and Illustrations Robert Sedgewick and Kevin Wayne Cover Image: © Robert Sedgewick and Kevin Wayne Page 353 © 2006 C. Herscovici, Brussels / Artists Rights Society (ARS), New York Banque d’ Images, ADAGP / Art Resource, NY Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trade- marks. Where those designations appear in this book, and Addison-Wesley was aware of a trademark claim, the designations have been printed in initial caps or all caps. The interior of this book was composed in Adobe InDesign. Library of Congress Cataloging-in-Publication Data Sedgewick, Robert, 1946- Introduction to programming in Java : an interdisciplinary approach / by Robert Sedgewick and Kevin Wayne. p. cm. Includes index. ISBN 978-0-321-49805-2 (alk. paper) 1. Java (Computer program language) 2. Computer programming. I. Wayne, Kevin Daniel, 1971- II. Title. QA76.73.J38S413 2007 005.13’3--dc22 2007020235 Copyright © 2008 Pearson Education, Inc. All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any means, electronic, mechanical, photocopying, recording, or otherwise, without the prior written permission of the publisher.
    [Show full text]
  • Python Guide Documentation 0.0.1
    Python Guide Documentation 0.0.1 Kenneth Reitz 2015 09 13 Contents 1 Getting Started 3 1.1 Picking an Interpreter..........................................3 1.2 Installing Python on Mac OS X.....................................5 1.3 Installing Python on Windows......................................6 1.4 Installing Python on Linux........................................7 2 Writing Great Code 9 2.1 Structuring Your Project.........................................9 2.2 Code Style................................................ 15 2.3 Reading Great Code........................................... 24 2.4 Documentation.............................................. 24 2.5 Testing Your Code............................................ 26 2.6 Common Gotchas............................................ 30 2.7 Choosing a License............................................ 33 3 Scenario Guide 35 3.1 Network Applications.......................................... 35 3.2 Web Applications............................................ 36 3.3 HTML Scraping............................................. 41 3.4 Command Line Applications....................................... 42 3.5 GUI Applications............................................. 43 3.6 Databases................................................. 45 3.7 Networking................................................ 45 3.8 Systems Administration......................................... 46 3.9 Continuous Integration.......................................... 49 3.10 Speed..................................................
    [Show full text]
  • C Programming Tutorial
    C Programming Tutorial C PROGRAMMING TUTORIAL Simply Easy Learning by tutorialspoint.com tutorialspoint.com i COPYRIGHT & DISCLAIMER NOTICE All the content and graphics on this tutorial are the property of tutorialspoint.com. Any content from tutorialspoint.com or this tutorial may not be redistributed or reproduced in any way, shape, or form without the written permission of tutorialspoint.com. Failure to do so is a violation of copyright laws. This tutorial may contain inaccuracies or errors and tutorialspoint provides no guarantee regarding the accuracy of the site or its contents including this tutorial. If you discover that the tutorialspoint.com site or this tutorial content contains some errors, please contact us at [email protected] ii Table of Contents C Language Overview .............................................................. 1 Facts about C ............................................................................................... 1 Why to use C ? ............................................................................................. 2 C Programs .................................................................................................. 2 C Environment Setup ............................................................... 3 Text Editor ................................................................................................... 3 The C Compiler ............................................................................................ 3 Installation on Unix/Linux ............................................................................
    [Show full text]
  • CS 6311 – Programming Languages I – Fall 2006 Assignment #1 (100 Pts) Due: 7:00Pm, Monday 9/25/6
    Most of the solutions are from Edwin Rudolph (who did an outstanding job on the assignment) with a few modifications. CS 6311 – Programming Languages I – Fall 2006 Assignment #1 (100 pts) Due: 7:00pm, Monday 9/25/6 Directions: The answers to the following questions must be typed in Microsoft Word and submitted as a Word document by the due date. There are a total of 40 questions. 1. A system of instructions and data directly understandable by a computer’s central processing unit is known as what? (1 pt) Machine language. 2. What is the name of the category of programming languages whose structure is dictated by the von Neumann computer architecture? (1 pt) Imperative. 3. Although PL/I and Ada were designed to be multi-purpose languages, in fact PL/I was considered to be the “language to end all languages”, why is there such difficulty in creating a general purpose programming language applicable to a wide range of areas? (3 pts) The difficulty in creating an all purpose language lies in the fact that the variety of problems that we ask computers to solve do not all lend themselves to being easily or conveniently expressed in the same way. Numerical processing involves different types of tasks than string processing; a program which computes trajectories of a spacecraft probably does not require extensive string processing facilities, just as a program to search for patterns in news feeds does not require extensive mathematical facilities. Attempting to create languages which provide facilities for solving all types of problems is that the language suffers from a feature bloat, not only making it difficult for programmers to effectively use it, but also making it more difficult to implement compilers and/or translators for.
    [Show full text]