DOC PREVIEW
UMD CMSC 330 - Quiz 1 Answers

This preview shows page 1 out of 2 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 2 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 2 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

CMSC330 Summer 2009 Quiz 1 Name: __________Answer_______________________________ 1. Compilation and Interpretation (4 points) a. What is the difference between compilation and interpretation? Compilation converts source code into machine code and attempts to optimize/process during this step, examining the entire code; interpretation executes a single instruction at a time without this analysis b. Give an instance where you would use one over the other. If we care about runtime performance we would likely use a compiled language 2. What are 4 attributes of a good programming language (list and BRIEFLY explain each in one sentence or phrase)? (4 points) Look at slides 26-28 from first day of class3. Give the output for the following Ruby programs or write FAIL if they would not execute or if they would produce an error. (10 points) a. x = "string" y = "string" puts "yes" if x == y x = 'hello' y = 'world' puts x + y b. x = "My phone number is (301)-555-5555." regex1 = /phone.*/ regex2 = '\((\d{3})\)-\d{3}-\d{4}' regex3 = '$' if x =~ regex1 puts "1" puts $1 end if x =~ Regexp.new('phone.*' + regex2) puts "2" puts $1 end if x =~ Regexp.new(regex2 + regex3) puts "3" puts $1 end 4. Complete the Ruby method below to print all integers from 0 to x that are odd. (x is a variable that is passed in). Hint: use %. (4 points) def printOdd(x) for i in (0..x) if (i % 2 != 0) then puts i end end end yes helloworld 1 nil 2


View Full Document

UMD CMSC 330 - Quiz 1 Answers

Documents in this Course
Exam #1

Exam #1

6 pages

Quiz #1

Quiz #1

2 pages

Midterm 2

Midterm 2

12 pages

Exam #2

Exam #2

7 pages

Ocaml

Ocaml

7 pages

Parsing

Parsing

38 pages

Threads

Threads

12 pages

Ruby

Ruby

7 pages

Quiz #3

Quiz #3

2 pages

Threads

Threads

7 pages

Quiz #4

Quiz #4

2 pages

Exam #2

Exam #2

6 pages

Exam #1

Exam #1

6 pages

Threads

Threads

34 pages

Quiz #4

Quiz #4

2 pages

Threads

Threads

26 pages

Exam #2

Exam #2

9 pages

Exam #2

Exam #2

6 pages

Load more
Download Quiz 1 Answers
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Quiz 1 Answers and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Quiz 1 Answers 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?