CSC 533: Organization of Programming Languages
Fall 2000

Test 2 Review

TEST 1 MATERIAL Abstraction expressions & control structures sub-expression evaluation order, compound statements counter-controlled vs. logic-controlled loops, branching subprograms subprogram linkage parameter passing: by-value, by-result, by-value-result, by-reference, by-name overloading functions/operators, templates Data Abstraction abstract data types: require encapsulation of data & operations + info hiding Modula-2: opaque vs. transparent types (only pointer types can be opaque) C++: must specify type info in class definition (even if private) C++ & Java protection modes: public, protected, private, package-only (Java) object-based programming: program is a collection of interacting objects advantages: natural approach to design, modular (allows for reuse) object-oriented programming: OBP + inheritance + dynamic binding advantages: (1) can build new classes on top of existing classes (2) IS_A relationship allows for generic functions (requires dynamic binding) OOP in C++ hybrid OOP language, combines procedural code with objects can inherit data fields & member functions, override/add features scope resolution operator can specify member functions from parent class virtual member function specifies dynamic binding (implemented using pointer) advanced OOP abstract base class: specifies form & properties of a derived class multiple inheritance: ambiguities must be avoided using :: OOP in Java design goals: simple, object-oriented, network savvy, robust, secure, portable, arch. neutral, interpreted, high-performance, multi-threaded, dynamic easier programming more important than efficiency based on C++ syntax, but removed many confusing/redundant features name resolution at link time, automatic memory reclamation, ... extensive libraries: Math, Stack, HashTable, Random, ... Java execution models application: compile into byte code, execute with an interpreter applet: compile into byte code, execute in Web browser primitive vs. reference types primitive: semi-dynamic (type bound statically, address bound dynamically) passed by-value, can generalize with wrapper classes reference: explicit dynamic, must allocate using new passed by-value, but behaves more like by-reference (since pointer) implicitly inherits from Object type general-purpose, (pure) object-oriented programming language similar to C++, can inherit data fields & methods, override/add features can specify methods from parent class by specifying super all methods are dynamically bound by default (can override with static) advanced OOP generic types via inheritance (e.g., vector of Objects) abstract base class vs. interface no multiple inheritance, but multiple interfaces OK Java vs. JavaScript JavaScript designed as scripting language for Web browsers generates dynamic output in a page controls events in the page (button clicks, text entered, form submit, ...) retained syntactic similarity to C++/Java different design goals led to different features scripting languages --> interpreted by browser, code embedded in HTML applications are quick & dirty --> variables are dynamic for flexibility, don't have to declare variables, no type for functions applications are small --> useful objects provided, rudimentary facility for defining new classes, no info hiding or inheritance user security is important, code security isn't --> can't access client files, can't hide source code