Sample Computer Science Placement Exams
Sample Placement Exams for Placement out of CSCI-UA.2:
- CSCI-UA.2: Java
- CSCI-UA.2: JavaScript
- CSCI-UA.2: Python
- CSCI-UA.2: C and C++ (Oral Exams)
- If you have experience programming in some language other than Java, C, C++, JavaScript, or Python, it may be possible to arrange for you to take a placement exam. Inquire at the department undergraduate office.
Sample Placement Exams for Placement out of CSCI-UA.4:
Sample Placement Exams for Placement out of CSCI-UA.101:
Sample Placement Exams for Placement out of CSCI-UA.1012:
Topics Covered by the CSCI-UA.0002 Java Placement Exam
The Java version of the placement exam covers the following topics:
- Variables: declaring, initializing, variable scope, mutability and immutability, primitive data types and reference types
- Types: char, float, double, short, int, long, String and arrays
- The arithmetic operators: +, -, *, /
- Increment and decrement operators (e.g. x++)
- The relational operators: <, <=, >, >= and ==<
- The boolean operators: &&, || and !
- Assignment statements and shorthand assignments (e.g. x *= 10). The if / else-if / else statements, including nested if / else-if / else statements
- The switch statements
- The while and do/while statements
- The for loop, including nested for loops
- Functions and methods
- Arrays
- Strings
The Java version of the placement exam does NOT cover:
- The bitwise operators
- Object Oriented Programming
- File I/O
Reference: any book on Java programming.
Exam Format
- Delivery format: Brightspace quiz using Respondus Lockdown Browser
- Time limit: 60 minutes
- Questions: 10 multiple choice, 2 programming
- Closed book / closed notes
Some Sample Questions for the CSCI-UA.2 Java Placement Exam
1. [Multiple Choice] Which of the following are true about how while loops behave in Java? (select all that apply)
- A while loop runs as long as the condition attached to it is true.
- A while loop always runs at least once.
- If the condition is initially false, the loop body does not run.
- You can use the break statement to exit a while loop before the condition becomes false.
- You can use the continue statement to re-evaluate the condition attached to the while loop.
- You can only use numbers in while loop conditions.
2. [Multiple Choice] Which of the following statements about Java arrays are true? (Select all that apply)
- Java arrays can only store elements of a single declared type.
- Java arrays are immutable and cannot be changed after they are created
- You can update an element in an array by assigning a new value to a specific index.
- Java arrays automatically sort themselves when elements are added
- If you pass an array to a method and the method changes its contents, the original array is affected.
- If array1 is an array, the statement int[] array2 = array1; creates a new copy of the array.
3. [Programming Question] Note that you will be given access to a secure web-based IDE during the exam where you will be able to write, run and test your code.
Write a METHOD called convertStringToDate that accepts a String representing a possible calendar date in numeric form. The method should then RETURN a new String that represents the date in human-readable form. For example, calling the method as follows:
convertStringToDate("20240901");
Will return the string "September 1, 2024"
Valid dates will be organized as follows:
YYYYMMDD
For example, "20240901" represents the date "September 1, 2024". "20190517" represents the date "May 17, 2019".
Note that your method should RETURN the string "invalid" if the date is invalid. For the purpose of this program a valid month is any month between 1 and 12 (inclusive) and a valid day is is based on the following:
- September, April, June and November: 30 days
- February: 28 days (your method does not need to handle leap years)
- All other months: 31 days
For example, calling the method with the string "20249999" would result in a return valid of "invalid". Likewise, the strings "0", "apple", "xyz123" and "20240931" will also return "invalid". Note that this is not an exhaustive list of invalid strings, and your method should handle all possible invalid dates.
Topics Covered by the CSCI-UA.0002 JavaScript Placement Exam
The JavaScript version of the placement exam covers the following topics:
- Variables: declaring, initializing, variable scope, let, var, const, mutability and immutability
- Types: numbers, strings, booleans, arrays and objects (e.g. { foo: 5, bar: 10 })
- The arithmetic operators: +, -, *, /
- Increment and decrement operators (e.g. x++)
- The relational operators: <, <=, >, >= and ==<
- The boolean operators: &&, || and !
- Assignment statements and shorthand assignments (e.g. x *= 10)
- The if / else-if / else statements, including nested if / else-if / else statements
- The switch statements
- The while and do/while statements
- The for loop, including nested for loops
- Functions
- Arrays
- Strings
The JavaScript version of the placement exam does NOT cover:
- The bitwise operators
- Object Oriented Programming
- File I/O
- Using JavaScript to manipulate the HTML DOM (Document Object Model)
Reference: any book on JavaScript programming.
Exam Format
- Delivery format: Brightspace quiz using Respondus Lockdown Browser
- Time limit: 60 minutes
- Questions: 10 multiple choice, 2 programming
- Closed book / closed notes
Some Sample Questions for the CSCI-UA.2 JavaScript Placement Exam
1. [Multiple Choice] Which of the following are true about how while loops behave in JavaScript? (select all that apply)
- A while loop runs as long as the condition attached to it is true.
- A while loop always runs at least once.
- If the condition is initially false, the loop body does not run.
- You can use the break statement to exit a while loop before the condition becomes false.
- You can use the continue statement to re-evaluate the condition attached to the while loop.
- You can only use numbers in while loop conditions.
2. [Multiple Choice] Which of the following statements about JavaScript arrays are true? (Select all that apply)
- JavaScript arrays can store elements of different types.
- JavaScript arrays are immutable and cannot be changed after creation.
- You can update an element in an array by assigning a new value to a specific index.
- JavaScript arrays automatically sort themselves when new elements are added.
- If you pass an array to a function and the function changes its contents, the original array is affected.
- Assigning one array to another using let arr2 = arr1 creates a new copy of the array.
3. [Programming Question] Note that you will be given access to a secure web-based IDE during the exam where you will be able to write, run and test your code.
Write a FUNCTION called convertStringToDate that accepts a String representing a possible calendar date in numeric form. The function should then RETURN a new String that represents the date in human-readable form. For example, calling the function as follows:
convertStringToDate("20240901");
Will return the string "September 1, 2024"
Valid dates will be organized as follows:
YYYYMMDD
For example, "20240901" represents the date "September 1, 2024". "20190517" represents the date "May 17, 2019".
Note that your function should return the string "invalid" if the date is invalid. For the purpose of this program a valid month is any month between 1 and 12 (inclusive) and a valid day is is based on the following:
- September, April, June and November: 30 days
- February: 28 days (your function does not need to handle leap years)
- All other months: 31 days
For example, calling the function with the string "20249999" would result in a return valid of "invalid" Likewise, the strings "0", "apple", "xyz123" and "20240931" will also return "invalid". Note that this is not an exhaustive list of invalid strings, and your function should handle all possible invalid dates.
Topics Covered by the CSCI-UA.0002 C and C++ Placement Exam
The Python version of the placement exam covers the following topics:
- variables: declaring, initializing, variable scope
- types: integers, floats, strings, boolean values, lists and dictionaries
- the arithmetic operators: +, -, *, /
- the relational operators: <, <=, >, >=, and ==
- the boolean operators: &&, ||, !
- the conditional control structures (if, if…else…)
- the repetition structure (for and while loops, including nested loops)
- arrays
- string representation (c-strings in C, and String class in C++)
- functions
- standard input and output (using printf/scanf in C, and cin/cout in C++)
Reference: any book on C or C++ programming
Exam Format
- Delivery format: Oral exam scheduled on Zoom with the instructor
- Time limit: 30-45 minutes
- Questions: code reading and code writing questions
- Closed book / closed notes
Some Sample Questions
1. [Code reading] Consider the following code fragment. Explain what the output of that code fragment is when it is embedded in a correct program.
(C code)
int i;
for (i = 1; i <= 5; i++) {
if (i % 2 == 0) {
printf("%d ", i);
}
}
(C++ code)
for (int i = 1; i <= 5; i++) {
if (i % 2 == 0) {
cout << i << " ";
}
}
2. [Code reading] Consider the following program. Explain what the output of that program is.
(C code)
void updateValue(int x) {
x = x * 2;
printf("Inside function: x = %d\n", x);
}
int main() {
int num = 5;
updateValue(num);
printf("In main: num = %d\n", num);
return 0;
}
(C++ code)
void updateValue(int x) {
x = x * 2;
cout << "Inside function: x = " << x <<
endl;
}
int main() {
int num = 5;
updateValue(num);
cout << "In main: num = " << num << endl;
return 0;
}
3. [Code writing] Write a C/C++ program that reads 5 integers into an array from the user, then prints only the positive numbers from the array. Your program must use a loop to read the input values into the array (it cannot prompt the user for 5 values using five separate prompts.
Here is a sample user interaction:
Enter five integers:
4 9 -2 -7 1
The positive integers are:
4 9 1
Topics Covered by the CSCI-UA.0002 Python Placement Exa
The Python version of the placement exam covers the following topics:
- Variables: integers, floats, strings, and boolean values
- The arithmetic operators: +, -, *, /, //
- The relational operators: <, <=, >, >=, and ==
- The boolean operators: and, or
- The if / elif / else statements, including nested if / elif / else statements
- for and while loops, including nested for and while loops
- lists
- strings
- functions and modules
- dictionaries
The Python version of the placement exam does NOT cover:
- The bitwise operators
- Object oriented programming
- File I/O
Reference: any book on Python programming
Exam Format
- Delivery format: Brightspace quiz using Respondus Lockdown Browser
- Time limit: 60 minutes
- Questions: 10 multiple choice, 2 programming
- Closed book / closed notes
Some Sample Questions for the CSCI-UA.2 Python Placement Exam
1. [Multiple Choice] Which of the following are true about how while loops behave in Python? (select all that apply)
- A while loop runs as long as the condition attached to it is True.
- A while loop always runs at least once.
- If the condition is initially False, the loop body does not run.
- You can use the break statement to exit a while loop before the condition becomes False.
- You can use the continue statement to re-evaluate the condition attached to the while loop.
- You can only use numbers in while loop conditions.
2. [Multiple Choice] Which of the following statements about Python lists are true? (Select all that apply)
- Lists can contain elements of different types
- Lists are immutable and cannot be changed after they're created
- You can add elements to a list using .append() or by concatenating another list.
- Lists automatically sort themselves when elements are added
- Assume you have a function that accepts a list as an argument, and the function makes a change to the argument. This action affects the original list without having to return the list.
- Assuming list1 is a list, the code list2 = list1 creates a new copy of the list.
3. [Programming Question] Note that you will be given access to a secure web-based IDE during the exam where you will be able to write, run and test your code.
Write a FUNCTION called convert_string_to_date that accepts a sing string representing a possible calendar date in numeric form. The function should then RETURN a new string that represents the date in human-readable form.
For example, calling the function as follows:
convert_string_to_date("20240901")
Will return the string "September 1, 2024"
Valid dates will be organized as follows:
YYYYMMDD
For example, "20240901" represents the date "September 1, 2024". "20190517" represents the date "May 17, 2019".
Note that your function should RETURN the string "invalid" if the date is invalid. For the purpose of this program a valid month is any month between 1 and 12 (inclusive) and a valid day is is based on the following:
- September, April, June and November: 30 days
- February: 28 days (your function does not need to handle leap years)
- All other months: 31 days
For example, calling the function with the string "20249999" would result in a return valid of "invalid". Likewise, the strings "0", "apple", "xyz123" and "20240931" will also return "invalid". Note that this is not an exhaustive list of invalid strings, and your function should handle all possible invalid dates.
Topics Covered on the CSCI-UA.4 Introduction to Web Design Placement Exam
The Web Design placement exam covers the following topics:
- HTML - page content (text, multimedia, hypertext, tables, lists and other elements that comprise the basic HTML page structure)
- CSS - page layout, formatting content
- Photoshop - image manipulation, preparing images for use on the web
It does NOT cover:
- JavaScript, PHP or other web development languages
- Adobe Creative Suite - InDesign, Flash, etc.
Two Sample Questions for the Introduction To Web Design Placement Exam
-
How is the padding property used in CSS? Describe and illustrate your answer with code.
-
Given the following excerpt from a webpage:
- TRUE/FALSE: It is clear from the code above that there are images in the body of this webpage.
- TRUE/FALSE: It is clear from the code above that the first line in the body of this webpage will read "Come to New York City!"
- TRUE/FALSE: It is clear from the code above that this page contains one in-line style.
- TRUE/FALSE: It is clear from the code above that an external stylesheet is linked from this page.
- TRUE/FALSE: Using
Sample
in the body of this webpage will render the word Sample in small-caps.
Topics Covered by the CSCI-UA.0101 Java Placement Exam
The Java version of the test our exam covers the following topics:
- control structures: if statements, switch statement, for , while and do...while loops.
- simple and multi-dimensional array
- object oriented design
- class design and use
- encapsulation
- reference and object manipulation
- static vs. instance data fields and methods
- arrays of objects
- inheritance and polymorphism
- abstract classes
- interfaces
- exception handling
- file I/O
Reference: any book on Java programming
Exam Format
- Delivery format: Brightspace quiz using Respondus Lockdown Browser
- Time limit: 60 minutes
- Questions: 15 multiple choice, 2 programming
- Closed book / closed notes
Some Sample Questions
1. [Multiple Choice] What are the values of x and y after the following code fragment is executed?
int x = 5;
int y = 10;
swap (x, y);
The function swap is defined as
public static void swap ( int a, int b ) {
int tmp = a;
a = b;
b = tmp'
}
- x = 5, y = 10
- x = 10, y = 5
- x = 5, y = 5
- x = 10, y = 10
- the code has compilation errors
2. [Multiple Choice] Consider the following two classes:
class A extends B {
public String toString() {
return "A";
}
}
class B {
public String toString() {
return "B";
}
}
What is the output when the following code fragment is executed?
B b1 = new B();
B b2 = new A();
A a1 = new A();
System.out.println(b1 + " " + b2 + " " + a1 );
- B A A
- B B A
- B B A A
- B A B A
- some other output
- this code would not compile since the declaration of b2 is invalid
3. [Programming Question] Write a Java class Point that represents (x,y) point in a plane. The class should implement the Comparable<Point> interface. The points should be compared based on their Manhattan distance from the origin (i.e., the point (0,0)). The Manhattan distance from the origin can be computed using distance = |x| + |y| (when the | … | indicates the absolute value).
Your class should implement all methods needed for the following code fragment to compile.
Random r = new Random;
Point [] myPoints = new Point[10];
for (int i = 0; i < myPoints.length; i++)
myPoints[i] = new Point(r.nextDouble(), r.nextDouble() );
Arrays.sort(myPoints);
Topics Covered by the CSCI-UA.0102 Java Placement Exam
The Java version of the placement exam covers the following topics:
- all topics listed in the CSCI-UA.0101 Java Placement Exam
- performance of all algorithms and data structures mentioned below (no proofs)
- recursion
- linear and binary search
- quadratic sort algorithms and selection of O(N logN) algorithms (quicksort and mergesort)
- lists (array-based implementation, reference-based, or linked, representation)
- stacks and queues (array-based implementation, reference-based implementation)
- trees (general trees, binary trees, binary search trees)
- graphs and their representation (adjacency matrix, adjacency list)
- hash tables
Reference: any book on Data Structures that uses Java
Exam Format
- Delivery format: Brightspace quiz using Respondus Lockdown Browser
- Time limit: 75 minutes
- Questions: 15 multiple choice, 2 programming
- Closed book / closed notes
Some Sample Questions
1. [Multiple Choice] Given the following definition of the foo function:
public void foo ( Node head ) {
if (head == null) { return; }
Node cur = head;
while ( cur != null ) {
System.out.print (cur.data + " " );
cur = cur.next;
if (cur != null )
cur = cur.next;
}
}
What is printed by the function when it is called on the head of the linked list shown below? Assume that the Node class definition contains an integer field data and a reference to the next node called next.
head --> | 2 | --> | 5 | --> | 4 | --> | 7 | --> | 3 | --> null
- 2 5 4 7 3
- 2 4 3
- 2 4
- 5 7
- an error will occur
2. [Fill in the Blanks] Consider the following recursive function
int foo ( int x , int a) {
if (x < 0 ) return -1;
if (x == 0 ) return 1;
return a * foo (x-1, a);
}
How many calls to foo are made when we call foo(5, 2) (include this call in your count).
______________ (enter your answer as a single number - no words or spaces)
3. [Programming question] Write a method of a binary search tree class public String toString() that produces string containing all values stored in the tree in the order specified by the preorder traversal of that tree:
- the values stored in the tree are of type String
- the values in the string returned by the toString method should be separated by commas and spaces spaces
- the implementation of the binary search tree has a reference called root
- the Node class for this tree has references for the data (type String ) and the references of the left and right children (both type Node )
When your method is called on the tree below it should returned the string as follows:
leaf
/ \
/ \
flower seed
/ / \
/ / \
arbor petal vine
returned string: leaf, flower, arbor, seed, petal, vine, (note the comma and the space after the last word)
Topics Covered by the CSCI-UA.0102 C++ Placement Exam
The C++ version of the placement exam covers the following topics:
- all topics liste in the CSCI-UA.0101 Java Placement Exam (as they apply to C++)
- performance of all algorithms and data structures mentioned below (no proofs)
- recursion
- linear and binary search
- quaratic sort algorithms and selection of O(N logN) algorithms (quicksort and mergesort)
- lists (array-based implementation, reference-based, or linked, representation)
- stacks and queues (array-based implementation, reference-based implementation)
- trees (general trees, binary trees, binary search trees)
- graphs and their represenation (adjacency matrix, adjacency list)
- hash tables
Reference: any book on Data Structures that uses Java
Exam Format
- Delivery format: Oral exam scheduled on Zoom with the instructor
- Time limit: 30-45 minutes
- Questions: code reading and code writing questions
- Closed book / closed notes
Some Sample Questions
1. [Code reading] Given the following definition of the foo function:
void foo(Node* head) {
if (head == NULL) { return; }
Node* cur = head;
while (cur != NULL) {
cout << cur->data << " ";
cur = cur->next;
if (cur != nullptr)
cur = cur->next;
}
}
Explain what is printed by the function when it is called on the head of the linked list shown below? Assume that the Node class definition contains an integer field data and a reference to the next node called next.
head --> | 2 | --> | 5 | --> | 4 | --> | 7 | --> | 3 | --> null
2. [Code reading] Consider the following recursive function
int foo ( int x , int a) {
if (x < 0 ) return -1;
if (x == 0 ) return 1;
return a * foo (x-1, a);
}
How many calls to foo are made when we call foo(5, 2) (include this call in your count).
______________ (enter your answer as a single number - no words or spaces)
3. [Programming question] Write a method of a binary search tree class in C++ called preorderString() that returns a std::string containing all the values stored in the tree in the order specified by the pre-order traversal of the tree.
- The values stored in the tree are of type std::string.
- The values in the returned string should be separated by commas and spaces (, ).
- The tree has a pointer named root that refers to the root node.
- The Node class has:
- A std::string data field.
- Pointers to the left and right child nodes (both of type Node*).
When your method is called on the tree below it should returned the string as follows:
leaf
/ \
/ \
flower seed
/ / \
/ / \
arbor petal vine
returned string: leaf, flower, arbor, seed, petal, vine, (note the comma and the space after the last word)
For further information, please e-mail the Undergraduate Program Administrator .