Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

CMSC 245 Principles of Programming Languages Exam 1, Exams of Programming Languages

The first exam for the course CMSC 245 Principles of Programming Languages, which was taken in Fall 2020. The exam consists of 10 questions and is designed to be taken in 80 minutes. The exam covers various technical terms and concepts related to programming languages, including CPU and memory connection, machine-level instructions, executable machine code programs, function calls, and more. All resources are permitted, but no assistance from another person is allowed. The exam must be submitted via email by a specific deadline.

Typology: Exams

2019/2020

Uploaded on 05/11/2023

oliver97
oliver97 ๐Ÿ‡บ๐Ÿ‡ธ

4.4

(43)

324 documents

1 / 13

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
1
CMSC 245 Principles of Programming Languages
Fall 2020
Exam 1
This exam contains 10 Questions on pages numbered 1-13. This exam is designed to be taken in
80 minutes.
Please fill in all answers in the space provided in the form. Be sure to save your filled out exam
as First-nameLast-name.pdf. The exam should be e-mailed to your Professor no later than
1:00p Eastern Time on Thursday, October 7, 2020. No credit will be given for exams submitted
late. Your Professor will confirm the receipt of the exam by e-mail.
All resources (text book, class notes, completed labs and assignments, etc.) are permitted, but no
assistance from another person. It is okay to email the Professor if you require a clarification.
Good Luck!
Declaration
Sign the following statement after you have completed the examination by typing your name in
the box provided. Your exam will not be graded without your signature:
I certify that my responses in this examination are solely the product of my own work
and that I have fully abided by the Bryn Mawr College Academic Integrity policy and
instructions stated above while taking this exam.
Name:______________________________
pf3
pf4
pf5
pf8
pf9
pfa
pfd

Partial preview of the text

Download CMSC 245 Principles of Programming Languages Exam 1 and more Exams Programming Languages in PDF only on Docsity!

CMSC 245 Principles of Programming Languages Fall 2020 Exam 1

This exam contains 10 Questions on pages numbered 1-13. This exam is designed to be taken in 80 minutes.

Please fill in all answers in the space provided in the form. Be sure to save your filled out exam as First-nameLast-name.pdf. The exam should be e-mailed to your Professor no later than 1:00p Eastern Time on Thursday, October 7, 2020. No credit will be given for exams submitted late. Your Professor will confirm the receipt of the exam by e-mail.

All resources (text book, class notes, completed labs and assignments, etc.) are permitted, but no assistance from another person. It is okay to email the Professor if you require a clarification.

Good Luck!

Declaration

Sign the following statement after you have completed the examination by typing your name in the box provided. Your exam will not be graded without your signature:

I certify that my responses in this examination are solely the product of my own work and that I have fully abided by the Bryn Mawr College Academic Integrity policy and instructions stated above while taking this exam.

Name:______________________________

For grading purposes only. Go on to next page.

Question Points Max Points

1 10

2 10

3 20

4 10

5 10

6 20

7 10

8 15

9 10

10 10

Total 125

Question 2 (10 points) For each of the following programming languages specify (Yes/No) whether they support object-oriented programming

1. C

2. C++

3. C#

  1. Haskell
  2. Javascript
  3. Lisp
  4. Python
  5. Rust
  6. Smalltalk
  7. Swift

Question 3 (20 points) In the space provided, write down the technical term used that each of the following describes.

  1. Refers to the connection between the CPU and memory that used to access instructions as well as data.
  2. Translates a source code program into equivalent machine-level instructions.
  3. Sews together the program with the libraries it uses to form a complete executable machine code program.
  4. Relocates an executable program into specific locations in memory just prior to running the program.
  5. An interpreter uses this to take a statement in a program and decode and execute it interactively.
  6. Converts a program written an assembly language into an equivalent machine language program.
  7. The mechanism used to keep track of function calls and their referencing environment.
  8. Region of a program where a binding is active.
  9. Functions with no name.
  10. Complete set of bindings at a given point in a program.

Question 4 (5+5 points) What are first-class objects in a programming language?

For each of the following specify whether they are or not first-class objects in Java. Write a Yes/No in the space provided.

int

double

boolean

array

function

class

Question 5 (10 points) What makes a programming language object-oriented? Be specific and describe in no more than 2-4 sentences. Mention three object-oriented programming languages.

Question 6 (20 points) Consider the skeletal program below:

1 program Q5 { 2 char n; 3 int x = 2; 4 function W() { 5 int y; 6 println(n); 7 } // W() 8 9 function D() { 10 char n; 11 int z; 12 n = โ€˜Dโ€™; 13 W(); 14 } // D() 15 16 for (int i = 0; i < x; i++) { 17 println(i); 18 } 19 n = โ€˜Qโ€™; 20 W(); 21 D(); 22 } // Q

Part 1 (5 points): Name all the symbols defined in the program above. Use the line numbers provided to indicate the location of their definition.

Question 7 (10 points) Here is an algorithm for computing the GCD of two numbers a and b :

while (a โ‰  b) if a > b a โ† a โ€“ b else b โ† b - a

Assume that a and b are defined as integers and bound to values greater than 0.

Part 1 (5 points): Code the above steps in Java: ( NOTE: just the steps above)

Part 2 (5 points): Code the above steps in Go:

Question 8 (15 points) Consider the steps below to compute the minimum of two variables a and b :

if (a < b) then min โ† a else min โ† b

Part 1 (5 points) Show how the steps above can be coded using the ternary conditional operator in Java:

Part 2 (5 points) Describe the ternary conditional operator in the Go programming language. Based on your answer, show how the above steps would be coded in Go:

Question 9 (10 points) Define value model and reference model for variables in a programming language. Which model does Java use?

Question 10 (10 points) What are immutable objects? Given an example of an immutable object in Java.