Final Exam (corrected)

Size: px
Start display at page:

Download "Final Exam (corrected)"

Transcription

1 Final Exam (corrected) CSC 2/ December 2015 Directions; PLEASE READ This exam comprises 33 multiple-choice questions and 2 essay-style extra-credit questions. Multiplechoice questions?? through?? are worth one point each; the others are worth two points each. You also get 3 points for putting your name on every page, for a total of 62 points. The extra credit questions, together, are worth up to 10 additional points; they won t factor into your exam score, but they may help to raise your end-of-semester letter grade. This is a closed-book exam: you must put away all books, cellphones, and notes. Please confine your answers to the space provided. For multiple choice questions, darken the circle next to the single best answer. Be sure to read all candidate answers before choosing. No partial credit will be given on the multiple-choice questions. In the interest of fairness, the proctor has been instructed not to try to explain anything on the exam. If you are unsure what a question is asking, make a reasonable assumption and state it as part of your answer. You will have a maximum of 3 hours to complete the exam, though it should take substantially less than that. The proctor will collect any remaining exams promptly at 7:00 pm. Good luck! 1. (required) Per college policy, please write out the following statement and add your signature: I affirm that I will not give or receive any unauthorized help on this exam, and that all work will be my own. 2. (3 points) Put your name on each of the remaining pages (so if I lose a staple I won t lose your answers). 1

2 Multiple Choice 3. The grammars used in many production compilers contain error productions, which allow the parser to accept certain input programs that are, according to the manual, syntactically invalid. What purpose do these error productions serve? They improve compilation speed by catching common errors more quickly than a generalpurpose error recovery scheme would. b. They support language features that can be parsed bottom-up, but not top-down. c. They provide more helpful error messages than a general-purpose error recovery scheme would. d. none of the above 4. Consider the following program fragment, written in no particular language: string tag = "b" // global declaration function print_formatted_string(string s) print "<", tag, ">", s, "</", tag, ">" function emphasize (string s) string tag = "i" print_formatted_string(s) begin // main program emphasize("hi, mom") What does this program print? a. It prints <b>hi, mom</b> if the language uses static (lexical) scoping, and <i>hi, mom</i> if the language uses dynamic scoping. b. It prints <b>hi, mom</b> if the language uses dynamic scoping, and <i>hi, mom</i> if the language uses static (lexical) scoping. c. It prints <b>hi, mom</b> regardless of scope rules. d. It prints <i>hi, mom</i> regardless of scope rules. 5. Why do most languages not allow the bounds or increment of an enumeration-controlled (for) loop to be floating-point numbers? a. Because the number of iterations could depend on round-off errors, leading to unpredictable behavior. b. Because floating-point arithmetic is so much more expensive than integer arithmetic. c. Because loop control instructions would have to be executed in the floating point unit, and communication between the integer and floating-point ALUs would slow the pipeline down. d. Because floating point numbers cover a dramatically wider range of values, and loops might run too long. 2

3 The next four questions are worth one point each. Characterize the polymorphism in each example. 6. In C: a = b * c; /* integer or floating point multiplication? */ b. subtype polymorphism c. explicit parametric polymorphism d. implicit parametric polymorphism 7. In Java: ad hoc polymorphism (overloading) Iterator it = my_gui_set.iterator(); while (iterator.hasnext()) { Object elem = it.next(); elem.display(); // which "display" method? ad hoc polymorphism (overloading) b. subtype polymorphism c. explicit parametric polymorphism d. implicit parametric polymorphism 8. In C++: stack<int> int_stack; stack<double> double_stack; int_stack.push(3); double_stack.push( ); // both use library stack abstraction ad hoc polymorphism (overloading) b. subtype polymorphism c. explicit parametric polymorphism d. implicit parametric polymorphism 9. In Scheme: (define sort (L)... (sort ("these" "are" "a" "bunch" "of" "strings")) (sort ( )) ; and these are a bunch of ints ad hoc polymorphism (overloading) b. subtype polymorphism c. explicit parametric polymorphism d. implicit parametric polymorphism 3

4 10. In C++, the static_cast operator can be used to perform an explicit, unchecked type conversion. It is roughly equivalent to the parenthesized typename casts of C. The compiler will generate code to convert values when appropriate. The dynamic_cast operator can be used to convert pointers the wrong way in a polymorphic class hierarchy. The compiler will generate code to perform a run-time check of the concrete type of the referred-to object. The reinterpret_cast operator can be used to look at the underlying bits of an object as if they represented an object of a different type. Which of these three operators is type-safe? static_cast b. dynamic_cast c. reinterpret_cast d. none of the above; all are unsafe 11. Consider the following C++ code fragment: int a = 3; int b = 2; double r = a/b; Suppose we want r to have the value 1.5, rather than 1. Which cast operator can be used in the third line to achieve this effect? static_cast b. dynamic_cast c. reinterpret_cast d. none of the above 12. Why won t C++ allow you to apply a dynamic_cast operator to an object of a class that has no virtual functions? Because there is no reason one would ever need to convert the wrong way in a class hierarchy without virtual functions. b. Because objects without virtual functions have no vtables, and the language implementation has no way to determine their concrete type at run time. c. Because the dynamic_cast operator itself is implemented with virtual functions. d. Because the whole point of objects without virtual functions is to minimize run-time costs, and dynamic_cast imposes run-time costs. 4

5 13. Suppose we are compiling for a machine with 1-byte characters, 2-byte shorts, 4-byte integers, and 8-byte reals, and with alignment rules that require the address of every primitive data element to be an integer multiple of the element s size. Suppose further that the compiler is not permitted to reorder fields. How much space will be consumed by the following array? A : array [0..9] of record s : short; c : char; t : short; d : char; r : real; i : integer; end; 150 bytes b. 320 bytes c. 240 bytes d. 200 bytes 14. In which of the following situations is a spin lock an appropriate mechanism for mutual exclusion? a. synchronization among threads of a scientific simulation, running on a parallel supercomputer b. synchronization between a graphical program and its signal handlers c. synchronization between processes connected by a Unix pipe (as in grep foo *.c less) d. control of access to a critical section that writes data to a shared file 15. Consider a C program that contains a switch statement with 8 arms, labeled with the values 1, 2, 3, 4, 5, 7, 8, and 9 (no 6, no default). Suppose that our compiler has decided to implement the statement with a characteristic array (jump table). What should it put in the 6th entry of the table? a pointer to the code for the 7 case, since that is the sixth alternative b. a pointer to the code for the 5 case, since 6 is between 5 and 7, and switch statements in C fall through to the next case by default c. a pointer to code that announces a run-time error d. a pointer to the code that comes after the switch statement 5

6 The next 2 questions assume the following Java code: class A { private int a;... class B extends A implements Runnable { private int b; ExecutorService pool = Executors.newCachedThreadPool();... B b = new B();... pool.execute(b);... Recall that Runnable is a library interface that defines a zero-argument run method. ExecutorService is also a library interface; it defines an execute method that takes a single Runnable argument. You may assume that the compiler lays out data structures as follows: p1 p2 d data for object b a p3 b B Runnable vtable d main B vtable code for run() 16. What value will the compiler pass as the explicit parameter to execute? p1 b. p2 c. p3 d. d 17. What value will execute pass to run as its implicit this parameter? p1 b. p2 c. p3 d. d 6

7 18. Consider the following code in some unspecified language, where a, b, c, x, and y are distinct local variables of floating-point type: x = (c + a) + b y = (d + a) + b Here are two possible translations into assembly language: r1 = a r2 = b r3 = c r3 += r1 r3 += r2 x = r3 r3 = d r3 += r1 r3 += r2 y = r3 r1 = a r1 += b r3 = c r3 += r1 x = r3 r3 = d r3 += r1 y = r3 Most compilers will generate the version on the left, even though it s longer. Why? Most compilers are not smart enough to recognize that the two uses of (a + b) are redundant. b. The sum of a and b might overflow, leading to incorrect results. c. The version on the left is likely to have better cache behavior. d. The store to x might change the value of a or b. 19. Consider the following code sequences in C++, where foo is a user-defined class type: foo a, b; foo a; b = a; foo b = a; Are these two sequences (the one on the left and the one on the right) guaranteed to produce the same behavior? Yes: the one on the right is just syntactic sugar for the one on the left. b. No: foo s default constructor and its assignment operator may exhibit different behavior. c. No: the code on the right may access a or b before it has been initialized. d. No: the code on the left may execute the a and b constructors in either order, and they may have side effects. 7

8 20. Consider the following code in an unspecified language, where a, b, and c are distinct integer variables: for i := a to b by c // body Here are two possible translations into assembly language: r1 = a r1 = a r2 = (b a + c) / c goto L2 is r2 0? L1: // body if so, goto L3 r1 += c L1: // body L2: is r1 b? r1 += c if so, goto L1 L2: if --r2 > 0 goto L1 L3: The second line on the right will require multiple instructions; every other line is a single instruction. Why might the compiler prefer the version on the right? It doesn t depend on c being positive. b. It doesn t depend on the body of the loop leaving b unchanged. c. It s likely to be faster. d. all of the above The next 2 questions assume the following OCaml code: let rec foo n l = match (n, l) with (1, h :: t) -> Some h (_, h :: t) -> foo (n - 1) t _ -> None ;; 21. What is the type of foo? int -> a list -> a option b. a * b list -> b list c. int * int list -> int option d. a -> b list -> b option 22. What does foo do? It counts the number of elements in a given list. b. It returns the last n elements of a given list. c. It reverses the first n elements of a given list. d. It returns the nth element of a given list, if there is such an element. 8

9 23. Consider the following programs in Java (left) and C++ (right): class A { public void foo() { System.out.println("A"); class B extends A { public void foo() { System.out.println("B"); class Dispatch { public static void main(string[] args) { A obj = new B(); obj.foo(); What do these two programs print? #include <iostream> struct A { void foo() { std::cout << "A\n"; ; struct B : A { void foo() { std::cout << "B\n"; ; int main() { A* obj = new B(); obj->foo(); A in Java, B in C++ b. A in both c. B in Java, A in C++ d. B in both 24. In many cases, local variables and other stack data can be found using offsets from the stack pointer (sp) register. Compilers often employ a separate frame pointer (fp), for this purpose, however, even on 32-bit x86 machines, where registers are an extremely scarce resource. What is the most compelling reason for having a separate fp? to support dynamic arrays b. to support displacement addressing with limited offsets c. to avoid the complexity of changing offsets when pushing and popping arguments d. to distinguish between local variables (at negative offsets) and parameters (at positive offsets) 25. Recall that call-by-name parameters are implemented as thunks (parameter-less subroutines) that can be called to force evaluation. Call-by-need parameters add a memo to hold the value once it is evaluated, so the thunk never has to be called more than once. Under what circumstances may call-by-name and call-by-need yield different results? when there isn t enough room to hold the memo in the current stack frame b. when the thunk may raise an exception c. when the thunk depends on data that is modified by the called routine, or by another thread d. when the value of the parameter is never actually needed 9

10 26. What is the principal insight behind generational garbage collection? Garbage collection is most likely to be productive at the end of some logical program phase. b. Many programs operate in a pipelined fashion; the objects most likely to be garbage are those created long ago. c. Most dynamically created objects don t live very long. d. Fragmentation can be reduced by copying objects to new, adjacent locations during garbage collection. 27. Why is garbage collection difficult in C? Because C was designed for systems programming, and can t tolerate hidden fields in objects. b. Because C is often used for real-time programming, and can t tolerate performance hiccups. c. Because pointers can be created not only to objects in the heap, but to static and stack objects as well. d. Because the language isn t type-safe; we don t know where all the pointers are. 28. C++11 provides so-called smart pointers, which overload the various dereference and assignment operators to augment the functionality of pointers with automatic storage management. In particular, objects of class std::shared_ptr implement automatic reference counting. All shared_ptrs that refer logically to the same object O are implemented as pointers to a hidden, dynamically allocated object (essentially, a tombstone) that in turn contains a pointer to O. Why do you suppose the implementation needs this extra level of indirection? to avoid the need to reserve space for a reference count in every heap object b. to prevent the creation of circular references c. to catch dangling references d. to allow O itself to be copied to a new location, thereby reducing fragmentation 29. Which of the following is not true of generics (explicit parametric polymorphism) in Java? They can be type-checked once, at declaration time, ensuring that no additional errors will be announced when an instance of the generic is instantiated. b. They allow a single copy of the code for a generic to be shared among all instantiations. c. They avoid the need to put explicit type checks into one s source code when removing objects from a generic container. d. They avoid the run-time cost of type checks when removing objects from a generic container. 10

11 30. When using condition synchronization in Java (and most other modern languages), one must generally write while (! desired_condition ) { wait() rather than if (! desired_condition ) { wait() Why must one check the condition again after waiting? Because some other thread may have executed since the corresponding notify, and may have made the condition false again. b. Because other threads may call notify when the condition isn t actually true. c. Because the virtual machine is allowed to perform occasional spurious wakeups. d. all of the above 31. Consider the following Java code, where thread 1 and thread 2 execute in parallel: // shared variables: Object o; volatile int a = 0; int b = 0; int c = 0; volatile int d = 0; // thread 1: // thread 2: synchronized(o) { int x; // local variable a++; synchronized(o) { b++; x = b; c++; int y = a + x + c + d; d++; Which shared variable(s) are properly synchronized (free of data races)? variables a, b, and d b. variables a and d only c. variable c only d. variables a and b only 11

12 32. An action routine, as you may recall, is a semantic function together with an explicit indication of when it should be called during parsing. Action routines in a top-down context-free grammar constitute an ad hoc implementation of the semantic functions of an L-attributed attribute grammar. What data cannot accessed in such ad hoc routines? inherited attributes of the symbol on the left-hand side of the current production b. global variables c. synthesized attributes of symbols to the right of the action routine in the right-hand side of the current production d. none of the above all are fair game in an action routine 33. Which of the following is not an accurate statement regarding the layout of multidimensional arrays? In the general case, access to an element of an array requires fewer multiplications with row-pointer layout than it does with contiguous layout. b. Row-pointer layout is less vulnerable to memory fragmentation, since it allocates the array in pieces. c. For an N M array, row-pointer layout generally requires more space than contiguous layout. d. When one or more index is known at compile time, row-pointer layout leads to faster code than contiguous layout, because more of the address calculation can be pre-computed. 34. Dope vectors (run-time descriptors) are needed for arrays that are allocated in the heap instead of the stack. b. use row-pointer layout. c. have statically unknown bounds. d. contain elements of multiple types. 35. On 64-bit x86 processors, the stack pointer (sp) is said to protect not only all data below it (i.e., at higher addresses), but a 128-byte red zone of data above it as well (i.e., at lower addresses). If they require less than 128 bytes of stack frame, leaf routines (subroutines that call no other subroutines) can avoid updating the sp. What is the threat to data in the stack? Against what does the sp protect it? concurrent access in other threads b. iterators placed above the current stack frame c. arrays whose size increases during execution d. signal handlers 36. (Extra Credit up to 4 points) Discuss what you consider to be one of the most interesting interactions between language design and language implementation. 37. (Extra Credit up to 6 points) Discuss the interaction of exceptions and threads. Possible questions you might want to consider include: Does the existence of threads complicate the implementation of exceptions? Should one thread be able to explicitly raise an exception in another? What should happen if an exception escapes the outermost scope of a thread? Should an exception be allowed to escape a monitor? 12

language 1 (source) compiler language 2 (target) Figure 1: Compiling a program

language 1 (source) compiler language 2 (target) Figure 1: Compiling a program CS 2112 Lecture 27 Interpreters, compilers, and the Java Virtual Machine 1 May 2012 Lecturer: Andrew Myers 1 Interpreters vs. compilers There are two strategies for obtaining runnable code from a program

More information

Semantic Analysis: Types and Type Checking

Semantic Analysis: Types and Type Checking Semantic Analysis Semantic Analysis: Types and Type Checking CS 471 October 10, 2007 Source code Lexical Analysis tokens Syntactic Analysis AST Semantic Analysis AST Intermediate Code Gen lexical errors

More information

Java Interview Questions and Answers

Java Interview Questions and Answers 1. What is the most important feature of Java? Java is a platform independent language. 2. What do you mean by platform independence? Platform independence means that we can write and compile the java

More information

Semester Review. CSC 301, Fall 2015

Semester Review. CSC 301, Fall 2015 Semester Review CSC 301, Fall 2015 Programming Language Classes There are many different programming language classes, but four classes or paradigms stand out:! Imperative Languages! assignment and iteration!

More information

1 The Java Virtual Machine

1 The Java Virtual Machine 1 The Java Virtual Machine About the Spec Format This document describes the Java virtual machine and the instruction set. In this introduction, each component of the machine is briefly described. This

More information

Programming Language Pragmatics

Programming Language Pragmatics Programming Language Pragmatics THIRD EDITION Michael L. Scott Department of Computer Science University of Rochester ^ШШШШШ AMSTERDAM BOSTON HEIDELBERG LONDON, '-*i» ЩЛ< ^ ' m H NEW YORK «OXFORD «PARIS»SAN

More information

Moving from CS 61A Scheme to CS 61B Java

Moving from CS 61A Scheme to CS 61B Java Moving from CS 61A Scheme to CS 61B Java Introduction Java is an object-oriented language. This document describes some of the differences between object-oriented programming in Scheme (which we hope you

More information

Stack Allocation. Run-Time Data Structures. Static Structures

Stack Allocation. Run-Time Data Structures. Static Structures Run-Time Data Structures Stack Allocation Static Structures For static structures, a fixed address is used throughout execution. This is the oldest and simplest memory organization. In current compilers,

More information

Crash Course in Java

Crash Course in Java Crash Course in Java Based on notes from D. Hollinger Based in part on notes from J.J. Johns also: Java in a Nutshell Java Network Programming and Distributed Computing Netprog 2002 Java Intro 1 What is

More information

Object-Oriented Design Lecture 4 CSU 370 Fall 2007 (Pucella) Tuesday, Sep 18, 2007

Object-Oriented Design Lecture 4 CSU 370 Fall 2007 (Pucella) Tuesday, Sep 18, 2007 Object-Oriented Design Lecture 4 CSU 370 Fall 2007 (Pucella) Tuesday, Sep 18, 2007 The Java Type System By now, you have seen a fair amount of Java. Time to study in more depth the foundations of the language,

More information

Java Application Developer Certificate Program Competencies

Java Application Developer Certificate Program Competencies Java Application Developer Certificate Program Competencies After completing the following units, you will be able to: Basic Programming Logic Explain the steps involved in the program development cycle

More information

Fundamentals of Java Programming

Fundamentals of Java Programming Fundamentals of Java Programming This document is exclusive property of Cisco Systems, Inc. Permission is granted to print and copy this document for non-commercial distribution and exclusive use by instructors

More information

Chapter 5 Names, Bindings, Type Checking, and Scopes

Chapter 5 Names, Bindings, Type Checking, and Scopes Chapter 5 Names, Bindings, Type Checking, and Scopes Chapter 5 Topics Introduction Names Variables The Concept of Binding Type Checking Strong Typing Scope Scope and Lifetime Referencing Environments Named

More information

Scoping (Readings 7.1,7.4,7.6) Parameter passing methods (7.5) Building symbol tables (7.6)

Scoping (Readings 7.1,7.4,7.6) Parameter passing methods (7.5) Building symbol tables (7.6) Semantic Analysis Scoping (Readings 7.1,7.4,7.6) Static Dynamic Parameter passing methods (7.5) Building symbol tables (7.6) How to use them to find multiply-declared and undeclared variables Type checking

More information

Lab Experience 17. Programming Language Translation

Lab Experience 17. Programming Language Translation Lab Experience 17 Programming Language Translation Objectives Gain insight into the translation process for converting one virtual machine to another See the process by which an assembler translates assembly

More information

Embedded Systems. Review of ANSI C Topics. A Review of ANSI C and Considerations for Embedded C Programming. Basic features of C

Embedded Systems. Review of ANSI C Topics. A Review of ANSI C and Considerations for Embedded C Programming. Basic features of C Embedded Systems A Review of ANSI C and Considerations for Embedded C Programming Dr. Jeff Jackson Lecture 2-1 Review of ANSI C Topics Basic features of C C fundamentals Basic data types Expressions Selection

More information

Implementation Aspects of OO-Languages

Implementation Aspects of OO-Languages 1 Implementation Aspects of OO-Languages Allocation of space for data members: The space for data members is laid out the same way it is done for structures in C or other languages. Specifically: The data

More information

CS 141: Introduction to (Java) Programming: Exam 1 Jenny Orr Willamette University Fall 2013

CS 141: Introduction to (Java) Programming: Exam 1 Jenny Orr Willamette University Fall 2013 Oct 4, 2013, p 1 Name: CS 141: Introduction to (Java) Programming: Exam 1 Jenny Orr Willamette University Fall 2013 1. (max 18) 4. (max 16) 2. (max 12) 5. (max 12) 3. (max 24) 6. (max 18) Total: (max 100)

More information

Glossary of Object Oriented Terms

Glossary of Object Oriented Terms Appendix E Glossary of Object Oriented Terms abstract class: A class primarily intended to define an instance, but can not be instantiated without additional methods. abstract data type: An abstraction

More information

C++ INTERVIEW QUESTIONS

C++ INTERVIEW QUESTIONS C++ INTERVIEW QUESTIONS http://www.tutorialspoint.com/cplusplus/cpp_interview_questions.htm Copyright tutorialspoint.com Dear readers, these C++ Interview Questions have been designed specially to get

More information

Advanced Computer Architecture-CS501. Computer Systems Design and Architecture 2.1, 2.2, 3.2

Advanced Computer Architecture-CS501. Computer Systems Design and Architecture 2.1, 2.2, 3.2 Lecture Handout Computer Architecture Lecture No. 2 Reading Material Vincent P. Heuring&Harry F. Jordan Chapter 2,Chapter3 Computer Systems Design and Architecture 2.1, 2.2, 3.2 Summary 1) A taxonomy of

More information

Habanero Extreme Scale Software Research Project

Habanero Extreme Scale Software Research Project Habanero Extreme Scale Software Research Project Comp215: Java Method Dispatch Zoran Budimlić (Rice University) Always remember that you are absolutely unique. Just like everyone else. - Margaret Mead

More information

Getting Started with the Internet Communications Engine

Getting Started with the Internet Communications Engine Getting Started with the Internet Communications Engine David Vriezen April 7, 2014 Contents 1 Introduction 2 2 About Ice 2 2.1 Proxies................................. 2 3 Setting Up ICE 2 4 Slices 2

More information

COMP 356 Programming Language Structures Notes for Chapter 10 of Concepts of Programming Languages Implementing Subprograms.

COMP 356 Programming Language Structures Notes for Chapter 10 of Concepts of Programming Languages Implementing Subprograms. COMP 356 Programming Language Structures Notes for Chapter 10 of Concepts of Programming Languages Implementing Subprograms 1 Activation Records activation declaration location Recall that an activation

More information

Memory Allocation. Static Allocation. Dynamic Allocation. Memory Management. Dynamic Allocation. Dynamic Storage Allocation

Memory Allocation. Static Allocation. Dynamic Allocation. Memory Management. Dynamic Allocation. Dynamic Storage Allocation Dynamic Storage Allocation CS 44 Operating Systems Fall 5 Presented By Vibha Prasad Memory Allocation Static Allocation (fixed in size) Sometimes we create data structures that are fixed and don t need

More information

C++ Programming Language

C++ Programming Language C++ Programming Language Lecturer: Yuri Nefedov 7th and 8th semesters Lectures: 34 hours (7th semester); 32 hours (8th semester). Seminars: 34 hours (7th semester); 32 hours (8th semester). Course abstract

More information

Handout 1. Introduction to Java programming language. Java primitive types and operations. Reading keyboard Input using class Scanner.

Handout 1. Introduction to Java programming language. Java primitive types and operations. Reading keyboard Input using class Scanner. Handout 1 CS603 Object-Oriented Programming Fall 15 Page 1 of 11 Handout 1 Introduction to Java programming language. Java primitive types and operations. Reading keyboard Input using class Scanner. Java

More information

2) Write in detail the issues in the design of code generator.

2) Write in detail the issues in the design of code generator. COMPUTER SCIENCE AND ENGINEERING VI SEM CSE Principles of Compiler Design Unit-IV Question and answers UNIT IV CODE GENERATION 9 Issues in the design of code generator The target machine Runtime Storage

More information

Pemrograman Dasar. Basic Elements Of Java

Pemrograman Dasar. Basic Elements Of Java Pemrograman Dasar Basic Elements Of Java Compiling and Running a Java Application 2 Portable Java Application 3 Java Platform Platform: hardware or software environment in which a program runs. Oracle

More information

The C Programming Language course syllabus associate level

The C Programming Language course syllabus associate level TECHNOLOGIES The C Programming Language course syllabus associate level Course description The course fully covers the basics of programming in the C programming language and demonstrates fundamental programming

More information

Sources: On the Web: Slides will be available on:

Sources: On the Web: Slides will be available on: C programming Introduction The basics of algorithms Structure of a C code, compilation step Constant, variable type, variable scope Expression and operators: assignment, arithmetic operators, comparison,

More information

An Overview of Java. overview-1

An Overview of Java. overview-1 An Overview of Java overview-1 Contents What is Java Major Java features Java virtual machine Java programming language Java class libraries (API) GUI Support in Java Networking and Threads in Java overview-2

More information

The programming language C. sws1 1

The programming language C. sws1 1 The programming language C sws1 1 The programming language C invented by Dennis Ritchie in early 1970s who used it to write the first Hello World program C was used to write UNIX Standardised as K&C (Kernighan

More information

Stack machines The MIPS assembly language A simple source language Stack-machine implementation of the simple language Readings: 9.1-9.

Stack machines The MIPS assembly language A simple source language Stack-machine implementation of the simple language Readings: 9.1-9. Code Generation I Stack machines The MIPS assembly language A simple source language Stack-machine implementation of the simple language Readings: 9.1-9.7 Stack Machines A simple evaluation model No variables

More information

Interpreters and virtual machines. Interpreters. Interpreters. Why interpreters? Tree-based interpreters. Text-based interpreters

Interpreters and virtual machines. Interpreters. Interpreters. Why interpreters? Tree-based interpreters. Text-based interpreters Interpreters and virtual machines Michel Schinz 2007 03 23 Interpreters Interpreters Why interpreters? An interpreter is a program that executes another program, represented as some kind of data-structure.

More information

CS412/CS413. Introduction to Compilers Tim Teitelbaum. Lecture 20: Stack Frames 7 March 08

CS412/CS413. Introduction to Compilers Tim Teitelbaum. Lecture 20: Stack Frames 7 March 08 CS412/CS413 Introduction to Compilers Tim Teitelbaum Lecture 20: Stack Frames 7 March 08 CS 412/413 Spring 2008 Introduction to Compilers 1 Where We Are Source code if (b == 0) a = b; Low-level IR code

More information

arrays C Programming Language - Arrays

arrays C Programming Language - Arrays arrays So far, we have been using only scalar variables scalar meaning a variable with a single value But many things require a set of related values coordinates or vectors require 3 (or 2, or 4, or more)

More information

Static vs. Dynamic. Lecture 10: Static Semantics Overview 1. Typical Semantic Errors: Java, C++ Typical Tasks of the Semantic Analyzer

Static vs. Dynamic. Lecture 10: Static Semantics Overview 1. Typical Semantic Errors: Java, C++ Typical Tasks of the Semantic Analyzer Lecture 10: Static Semantics Overview 1 Lexical analysis Produces tokens Detects & eliminates illegal tokens Parsing Produces trees Detects & eliminates ill-formed parse trees Static semantic analysis

More information

Computing Concepts with Java Essentials

Computing Concepts with Java Essentials 2008 AGI-Information Management Consultants May be used for personal purporses only or by libraries associated to dandelon.com network. Computing Concepts with Java Essentials 3rd Edition Cay Horstmann

More information

Java SE 8 Programming

Java SE 8 Programming Oracle University Contact Us: 1.800.529.0165 Java SE 8 Programming Duration: 5 Days What you will learn This Java SE 8 Programming training covers the core language features and Application Programming

More information

J a v a Quiz (Unit 3, Test 0 Practice)

J a v a Quiz (Unit 3, Test 0 Practice) Computer Science S-111a: Intensive Introduction to Computer Science Using Java Handout #11 Your Name Teaching Fellow J a v a Quiz (Unit 3, Test 0 Practice) Multiple-choice questions are worth 2 points

More information

Compiling Object Oriented Languages. What is an Object-Oriented Programming Language? Implementation: Dynamic Binding

Compiling Object Oriented Languages. What is an Object-Oriented Programming Language? Implementation: Dynamic Binding Compiling Object Oriented Languages What is an Object-Oriented Programming Language? Last time Dynamic compilation Today Introduction to compiling object oriented languages What are the issues? Objects

More information

09336863931 : provid.ir

09336863931 : provid.ir provid.ir 09336863931 : NET Architecture Core CSharp o Variable o Variable Scope o Type Inference o Namespaces o Preprocessor Directives Statements and Flow of Execution o If Statement o Switch Statement

More information

Computer Programming I

Computer Programming I Computer Programming I COP 2210 Syllabus Spring Semester 2012 Instructor: Greg Shaw Office: ECS 313 (Engineering and Computer Science Bldg) Office Hours: Tuesday: 2:50 4:50, 7:45 8:30 Thursday: 2:50 4:50,

More information

AP Computer Science Java Subset

AP Computer Science Java Subset APPENDIX A AP Computer Science Java Subset The AP Java subset is intended to outline the features of Java that may appear on the AP Computer Science A Exam. The AP Java subset is NOT intended as an overall

More information

Tutorial on C Language Programming

Tutorial on C Language Programming Tutorial on C Language Programming Teodor Rus rus@cs.uiowa.edu The University of Iowa, Department of Computer Science Introduction to System Software p.1/64 Tutorial on C programming C program structure:

More information

C++FA 3.1 OPTIMIZING C++

C++FA 3.1 OPTIMIZING C++ C++FA 3.1 OPTIMIZING C++ Ben Van Vliet Measuring Performance Performance can be measured and judged in different ways execution time, memory usage, error count, ease of use and trade offs usually have

More information

what operations can it perform? how does it perform them? on what kind of data? where are instructions and data stored?

what operations can it perform? how does it perform them? on what kind of data? where are instructions and data stored? Inside the CPU how does the CPU work? what operations can it perform? how does it perform them? on what kind of data? where are instructions and data stored? some short, boring programs to illustrate the

More information

Organization of Programming Languages CS320/520N. Lecture 05. Razvan C. Bunescu School of Electrical Engineering and Computer Science bunescu@ohio.

Organization of Programming Languages CS320/520N. Lecture 05. Razvan C. Bunescu School of Electrical Engineering and Computer Science bunescu@ohio. Organization of Programming Languages CS320/520N Razvan C. Bunescu School of Electrical Engineering and Computer Science bunescu@ohio.edu Names, Bindings, and Scopes A name is a symbolic identifier used

More information

CSE 373: Data Structure & Algorithms Lecture 25: Programming Languages. Nicki Dell Spring 2014

CSE 373: Data Structure & Algorithms Lecture 25: Programming Languages. Nicki Dell Spring 2014 CSE 373: Data Structure & Algorithms Lecture 25: Programming Languages Nicki Dell Spring 2014 What is a Programming Language? A set of symbols and associated tools that translate (if necessary) collections

More information

The Sun Certified Associate for the Java Platform, Standard Edition, Exam Version 1.0

The Sun Certified Associate for the Java Platform, Standard Edition, Exam Version 1.0 The following applies to all exams: Once exam vouchers are purchased you have up to one year from the date of purchase to use it. Each voucher is valid for one exam and may only be used at an Authorized

More information

Memory management. Announcements. Safe user input. Function pointers. Uses of function pointers. Function pointer example

Memory management. Announcements. Safe user input. Function pointers. Uses of function pointers. Function pointer example Announcements Memory management Assignment 2 posted, due Friday Do two of the three problems Assignment 1 graded see grades on CMS Lecture 7 CS 113 Spring 2008 2 Safe user input If you use scanf(), include

More information

Embedded Programming in C/C++: Lesson-1: Programming Elements and Programming in C

Embedded Programming in C/C++: Lesson-1: Programming Elements and Programming in C Embedded Programming in C/C++: Lesson-1: Programming Elements and Programming in C 1 An essential part of any embedded system design Programming 2 Programming in Assembly or HLL Processor and memory-sensitive

More information

Programming Language Features (cont.) CMSC 330: Organization of Programming Languages. Parameter Passing in OCaml. Call-by-Value

Programming Language Features (cont.) CMSC 330: Organization of Programming Languages. Parameter Passing in OCaml. Call-by-Value CMSC 33: Organization of Programming Languages Programming Language Features (cont.) Names & binding Namespaces Static (lexical) scopes Dynamic scopes Polymorphism Parametric Subtype Ad-hoc Parameter Passing

More information

Overview. CISC Developments. RISC Designs. CISC Designs. VAX: Addressing Modes. Digital VAX

Overview. CISC Developments. RISC Designs. CISC Designs. VAX: Addressing Modes. Digital VAX Overview CISC Developments Over Twenty Years Classic CISC design: Digital VAX VAXÕs RISC successor: PRISM/Alpha IntelÕs ubiquitous 80x86 architecture Ð 8086 through the Pentium Pro (P6) RJS 2/3/97 Philosophy

More information

Real Time Programming: Concepts

Real Time Programming: Concepts Real Time Programming: Concepts Radek Pelánek Plan at first we will study basic concepts related to real time programming then we will have a look at specific programming languages and study how they realize

More information

CHAPTER 7: The CPU and Memory

CHAPTER 7: The CPU and Memory CHAPTER 7: The CPU and Memory The Architecture of Computer Hardware, Systems Software & Networking: An Information Technology Approach 4th Edition, Irv Englander John Wiley and Sons 2010 PowerPoint slides

More information

picojava TM : A Hardware Implementation of the Java Virtual Machine

picojava TM : A Hardware Implementation of the Java Virtual Machine picojava TM : A Hardware Implementation of the Java Virtual Machine Marc Tremblay and Michael O Connor Sun Microelectronics Slide 1 The Java picojava Synergy Java s origins lie in improving the consumer

More information

Name: Class: Date: 9. The compiler ignores all comments they are there strictly for the convenience of anyone reading the program.

Name: Class: Date: 9. The compiler ignores all comments they are there strictly for the convenience of anyone reading the program. Name: Class: Date: Exam #1 - Prep True/False Indicate whether the statement is true or false. 1. Programming is the process of writing a computer program in a language that the computer can respond to

More information

1) The postfix expression for the infix expression A+B*(C+D)/F+D*E is ABCD+*F/DE*++

1) The postfix expression for the infix expression A+B*(C+D)/F+D*E is ABCD+*F/DE*++ Answer the following 1) The postfix expression for the infix expression A+B*(C+D)/F+D*E is ABCD+*F/DE*++ 2) Which data structure is needed to convert infix notations to postfix notations? Stack 3) The

More information

Android Application Development Course Program

Android Application Development Course Program Android Application Development Course Program Part I Introduction to Programming 1. Introduction to programming. Compilers, interpreters, virtual machines. Primitive data types, variables, basic operators,

More information

Part I. Multiple Choice Questions (2 points each):

Part I. Multiple Choice Questions (2 points each): Part I. Multiple Choice Questions (2 points each): 1. Which of the following is NOT a key component of object oriented programming? (a) Inheritance (b) Encapsulation (c) Polymorphism (d) Parallelism ******

More information

MPLAB TM C30 Managed PSV Pointers. Beta support included with MPLAB C30 V3.00

MPLAB TM C30 Managed PSV Pointers. Beta support included with MPLAB C30 V3.00 MPLAB TM C30 Managed PSV Pointers Beta support included with MPLAB C30 V3.00 Contents 1 Overview 2 1.1 Why Beta?.............................. 2 1.2 Other Sources of Reference..................... 2 2

More information

Bachelors of Computer Application Programming Principle & Algorithm (BCA-S102T)

Bachelors of Computer Application Programming Principle & Algorithm (BCA-S102T) Unit- I Introduction to c Language: C is a general-purpose computer programming language developed between 1969 and 1973 by Dennis Ritchie at the Bell Telephone Laboratories for use with the Unix operating

More information

Class 16: Function Parameters and Polymorphism

Class 16: Function Parameters and Polymorphism Class 16: Function Parameters and Polymorphism SI 413 - Programming Languages and Implementation Dr. Daniel S. Roche United States Naval Academy Fall 2011 Roche (USNA) SI413 - Class 16 Fall 2011 1 / 15

More information

A TOOL FOR DATA STRUCTURE VISUALIZATION AND USER-DEFINED ALGORITHM ANIMATION

A TOOL FOR DATA STRUCTURE VISUALIZATION AND USER-DEFINED ALGORITHM ANIMATION A TOOL FOR DATA STRUCTURE VISUALIZATION AND USER-DEFINED ALGORITHM ANIMATION Tao Chen 1, Tarek Sobh 2 Abstract -- In this paper, a software application that features the visualization of commonly used

More information

Lecture 18-19 Data Types and Types of a Language

Lecture 18-19 Data Types and Types of a Language Lecture 18-19 Data Types and Types of a Language April 29, 2014 Data Types and Types of a Language Data, Data Types and Types Type: Generalities Type Systems and Type Safety Type Equivalence, Coercion

More information

CS 111 Classes I 1. Software Organization View to this point:

CS 111 Classes I 1. Software Organization View to this point: CS 111 Classes I 1 Software Organization View to this point: Data Objects and primitive types Primitive types operators (+, /,,*, %). int, float, double, char, boolean Memory location holds the data Objects

More information

Instruction Set Architecture (ISA)

Instruction Set Architecture (ISA) Instruction Set Architecture (ISA) * Instruction set architecture of a machine fills the semantic gap between the user and the machine. * ISA serves as the starting point for the design of a new machine

More information

General Introduction

General Introduction Managed Runtime Technology: General Introduction Xiao-Feng Li (xiaofeng.li@gmail.com) 2012-10-10 Agenda Virtual machines Managed runtime systems EE and MM (JIT and GC) Summary 10/10/2012 Managed Runtime

More information

1/20/2016 INTRODUCTION

1/20/2016 INTRODUCTION INTRODUCTION 1 Programming languages have common concepts that are seen in all languages This course will discuss and illustrate these common concepts: Syntax Names Types Semantics Memory Management We

More information

Symbol Tables. Introduction

Symbol Tables. Introduction Symbol Tables Introduction A compiler needs to collect and use information about the names appearing in the source program. This information is entered into a data structure called a symbol table. The

More information

Java (12 Weeks) Introduction to Java Programming Language

Java (12 Weeks) Introduction to Java Programming Language Java (12 Weeks) Topic Lecture No. Introduction to Java Programming Language 1 An Introduction to Java o Java as a Programming Platform, The Java "White Paper" Buzzwords, Java and the Internet, A Short

More information

The Java Virtual Machine (JVM) Pat Morin COMP 3002

The Java Virtual Machine (JVM) Pat Morin COMP 3002 The Java Virtual Machine (JVM) Pat Morin COMP 3002 Outline Topic 1 Topic 2 Subtopic 2.1 Subtopic 2.2 Topic 3 2 What is the JVM? The JVM is a specification of a computing machine Instruction set Primitive

More information

Java Memory Model: Content

Java Memory Model: Content Java Memory Model: Content Memory Models Double Checked Locking Problem Java Memory Model: Happens Before Relation Volatile: in depth 16 March 2012 1 Java Memory Model JMM specifies guarantees given by

More information

Database Programming with PL/SQL: Learning Objectives

Database Programming with PL/SQL: Learning Objectives Database Programming with PL/SQL: Learning Objectives This course covers PL/SQL, a procedural language extension to SQL. Through an innovative project-based approach, students learn procedural logic constructs

More information

UIL Computer Science for Dummies by Jake Warren and works from Mr. Fleming

UIL Computer Science for Dummies by Jake Warren and works from Mr. Fleming UIL Computer Science for Dummies by Jake Warren and works from Mr. Fleming 1 2 Foreword First of all, this book isn t really for dummies. I wrote it for myself and other kids who are on the team. Everything

More information

University of Toronto Department of Electrical and Computer Engineering. Midterm Examination. CSC467 Compilers and Interpreters Fall Semester, 2005

University of Toronto Department of Electrical and Computer Engineering. Midterm Examination. CSC467 Compilers and Interpreters Fall Semester, 2005 University of Toronto Department of Electrical and Computer Engineering Midterm Examination CSC467 Compilers and Interpreters Fall Semester, 2005 Time and date: TBA Location: TBA Print your name and ID

More information

A Comparison Of Shared Memory Parallel Programming Models. Jace A Mogill David Haglin

A Comparison Of Shared Memory Parallel Programming Models. Jace A Mogill David Haglin A Comparison Of Shared Memory Parallel Programming Models Jace A Mogill David Haglin 1 Parallel Programming Gap Not many innovations... Memory semantics unchanged for over 50 years 2010 Multi-Core x86

More information

Introduction to Data Structures

Introduction to Data Structures Introduction to Data Structures Albert Gural October 28, 2011 1 Introduction When trying to convert from an algorithm to the actual code, one important aspect to consider is how to store and manipulate

More information

public static void main(string[] args) { System.out.println("hello, world"); } }

public static void main(string[] args) { System.out.println(hello, world); } } Java in 21 minutes hello world basic data types classes & objects program structure constructors garbage collection I/O exceptions Strings Hello world import java.io.*; public class hello { public static

More information

University of Twente. A simulation of the Java Virtual Machine using graph grammars

University of Twente. A simulation of the Java Virtual Machine using graph grammars University of Twente Department of Computer Science A simulation of the Java Virtual Machine using graph grammars Master of Science thesis M. R. Arends, November 2003 A simulation of the Java Virtual Machine

More information

www.virtualians.pk CS506 Web Design and Development Solved Online Quiz No. 01 www.virtualians.pk

www.virtualians.pk CS506 Web Design and Development Solved Online Quiz No. 01 www.virtualians.pk CS506 Web Design and Development Solved Online Quiz No. 01 Which of the following is a general purpose container? JFrame Dialog JPanel JApplet Which of the following package needs to be import while handling

More information

Chapter 7D The Java Virtual Machine

Chapter 7D The Java Virtual Machine This sub chapter discusses another architecture, that of the JVM (Java Virtual Machine). In general, a VM (Virtual Machine) is a hypothetical machine (implemented in either hardware or software) that directly

More information

Department of Electrical Engineering and Computer Science MASSACHUSETTS INSTITUTE OF TECHNOLOGY. 6.828 Operating System Engineering: Fall 2005

Department of Electrical Engineering and Computer Science MASSACHUSETTS INSTITUTE OF TECHNOLOGY. 6.828 Operating System Engineering: Fall 2005 Department of Electrical Engineering and Computer Science MASSACHUSETTS INSTITUTE OF TECHNOLOGY 6.828 Operating System Engineering: Fall 2005 Quiz II Solutions Average 84, median 83, standard deviation

More information

core. Volume I - Fundamentals Seventh Edition Sun Microsystems Press A Prentice Hall Title ULB Darmstadt

core. Volume I - Fundamentals Seventh Edition Sun Microsystems Press A Prentice Hall Title ULB Darmstadt core. 2008 AGI-Information Management Consultants May be used for personal purporses only or by libraries associated to dandelon.com network. Volume I - Fundamentals Seventh Edition CAY S. HORSTMANN GARY

More information

A deeper look at Inline functions

A deeper look at Inline functions A deeper look at Inline functions I think it s safe to say that all Overload readers know what C++ inline functions are. When we declare a function or member function as inline we are trying to avoid the

More information

Storage Classes CS 110B - Rule Storage Classes Page 18-1 \handouts\storclas

Storage Classes CS 110B - Rule Storage Classes Page 18-1 \handouts\storclas CS 110B - Rule Storage Classes Page 18-1 Attributes are distinctive features of a variable. Data type, int or double for example, is an attribute. Storage class is another attribute. There are four storage

More information

CORBA Programming with TAOX11. The C++11 CORBA Implementation

CORBA Programming with TAOX11. The C++11 CORBA Implementation CORBA Programming with TAOX11 The C++11 CORBA Implementation TAOX11: the CORBA Implementation by Remedy IT TAOX11 simplifies development of CORBA based applications IDL to C++11 language mapping is easy

More information

Object Oriented Software Design

Object Oriented Software Design Object Oriented Software Design Introduction to Java - II Giuseppe Lipari http://retis.sssup.it/~lipari Scuola Superiore Sant Anna Pisa October 28, 2010 G. Lipari (Scuola Superiore Sant Anna) Introduction

More information

C++FA 5.1 PRACTICE MID-TERM EXAM

C++FA 5.1 PRACTICE MID-TERM EXAM C++FA 5.1 PRACTICE MID-TERM EXAM This practicemid-term exam covers sections C++FA 1.1 through C++FA 1.4 of C++ with Financial Applications by Ben Van Vliet, available at www.benvanvliet.net. 1.) A pointer

More information

Designing with Exceptions. CSE219, Computer Science III Stony Brook University http://www.cs.stonybrook.edu/~cse219

Designing with Exceptions. CSE219, Computer Science III Stony Brook University http://www.cs.stonybrook.edu/~cse219 Designing with Exceptions CSE219, Computer Science III Stony Brook University http://www.cs.stonybrook.edu/~cse219 Testing vs. Debugging Testing Coding Does the code work properly YES NO 2 Debugging Testing

More information

Classes and Objects in Java Constructors. In creating objects of the type Fraction, we have used statements similar to the following:

Classes and Objects in Java Constructors. In creating objects of the type Fraction, we have used statements similar to the following: In creating objects of the type, we have used statements similar to the following: f = new (); The parentheses in the expression () makes it look like a method, yet we never created such a method in our

More information

Syllabus for CS 134 Java Programming

Syllabus for CS 134 Java Programming - Java Programming Syllabus Page 1 Syllabus for CS 134 Java Programming Computer Science Course Catalog 2000-2001: This course is an introduction to objectoriented programming using the Java language.

More information

Monitors, Java, Threads and Processes

Monitors, Java, Threads and Processes Monitors, Java, Threads and Processes 185 An object-oriented view of shared memory A semaphore can be seen as a shared object accessible through two methods: wait and signal. The idea behind the concept

More information

VHDL Test Bench Tutorial

VHDL Test Bench Tutorial University of Pennsylvania Department of Electrical and Systems Engineering ESE171 - Digital Design Laboratory VHDL Test Bench Tutorial Purpose The goal of this tutorial is to demonstrate how to automate

More information

Application Note C++ Debugging

Application Note C++ Debugging Application Note C++ Debugging TRACE32 Online Help TRACE32 Directory TRACE32 Index TRACE32 Documents... High-Level Language Debugging... Application Note C++ Debugging... 1 Sample Code used by This Application

More information

PART IV Performance oriented design, Performance testing, Performance tuning & Performance solutions. Outline. Performance oriented design

PART IV Performance oriented design, Performance testing, Performance tuning & Performance solutions. Outline. Performance oriented design PART IV Performance oriented design, Performance testing, Performance tuning & Performance solutions Slide 1 Outline Principles for performance oriented design Performance testing Performance tuning General

More information

KITES TECHNOLOGY COURSE MODULE (C, C++, DS)

KITES TECHNOLOGY COURSE MODULE (C, C++, DS) KITES TECHNOLOGY 360 Degree Solution www.kitestechnology.com/academy.php info@kitestechnology.com technologykites@gmail.com Contact: - 8961334776 9433759247 9830639522.NET JAVA WEB DESIGN PHP SQL, PL/SQL

More information

Exceptions in MIPS. know the exception mechanism in MIPS be able to write a simple exception handler for a MIPS machine

Exceptions in MIPS. know the exception mechanism in MIPS be able to write a simple exception handler for a MIPS machine 7 Objectives After completing this lab you will: know the exception mechanism in MIPS be able to write a simple exception handler for a MIPS machine Introduction Branches and jumps provide ways to change

More information