CSC 533: Organization of Programming Languages
Spring 2005

Test 2 Review

TEST 1 MATERIAL Object-Oriented Programming object-based programming: program is a collection of interacting objects natural approach to design, modular (allows for reuse) object-oriented programming: OBP + inheritance + dynamic binding can build new classes on top of existing classes IS_A relationship enables generic functions (requires dynamic binding) polymorphism: same name can refer to diff. code for diff. objects OOP in C++: hybrid language, combines procedural code with objects specify inheritance with " : ParentClass" in class definition private vs. protected scope resolution operator can specify member functions from parent virtual member function specifies dynamic binding multiple inheritance (using ::), abstract member functions (using = 0) Java design goals: simple, OO, network savvy, robust, secure, portable, arch. neutral, interpreted, high-performance, multi-threaded, dynamic features emphasize ease of programming more than efficiency based on C++ syntax, but removed many confusing/redundant features name resolution at link time, automatic memory reclamation, ... execution model: compile into byte code, then interpret with JVM language basics primitive types: stack-dynamic, passed by-value e.g., int, double, char, boolean, ... reference types: heap-dynamic, passed by-value but can alter state e.g., String, Math, Random, Date, Array, ArrayList, Set, ... implicitly inherit from Object type, boxing/unboxing primitives control structures & operators similar to C++ OOP in Java pure OO language, but static methods provide loophole specify inheritance with "extends ParentClass" in class definition can call methods from parent class by specifying super all methods are dynamically bound by default (can override via static) no multiple inheritance, but multiple interfaces OK interface specifies required methods, but no implementation abstract classes (similar to C++ but cleaner) Java vs. JavaScript JavaScript designed as scripting language for Web browsers retained syntactic similarity to C++/Java different design goals led to different features scripting language -> interpreted by browser, code embedded in HTML applications are quick & dirty -> implicit, dynamic variables applications are small -> useful objects provided, creation is crude user security is important -> can't access client files, but open code