







Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
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
1 / 13
This page cannot be seen from the preview
Don't miss anything!
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
Question 3 (20 points) In the space provided, write down the technical term used that each of the following describes.
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.