CS 18000 Study Guide - Midterm Guide: Square Pyramid, Void Type, Memory Address

45 views15 pages
CS 180 Fall 2008 Exam I
There are 20 multiple choice questions. Each one is worth 2 points. There are 3 programming
questions worth a total of 60 points.
Answer the multiple choice questions on the bubble sheet given and the programming ques-
tions on the exam booklet.
Fill in the Instructor, Course, Signature, Test, and Date blanks. For “Instructor” put your
RECITATION INSTRUCTOR’S LAST NAME GIVEN BELOW. For “Course” put CS 180.
For “Test” put Exam 1.
Fill in the bubbles that correspond to your name, section and Student ID in the bubble sheet.
For your section number, use the SECTION NUMBER for your lab and project turn in. Consult
the following list:
0101 THU 07:30 LWSN 1106 Salman Pervez
0201 FRI 07:30 LWSN B134 Cheng Wang
0301 FRI 03:30 LWSN B134 Salman Pervez
0401 FRI 04:30 HAAS G066 Srinivas Pasupuleti
0501 FRI 09:30 LWSN B134 Ashish Gandhe
0601 FRI 02:30 LWSN 1106 Ashish Gandhe
For your student ID, use the 10 digit ID number on your student ID card. DO NOT USE YOUR
SOCIAL SECURITY NUMBER!
Exams without names will be graded as zero. Only the answers on the bubble sheet will be
counted. The questions will be discarded.
Recitation Start Time
Recitation TAs Name
Student Last Name
Student First Name
Unlock document

This preview shows pages 1-3 of the document.
Unlock all 15 pages and 3 million more documents.

Already have an account? Log in
Part I. Multiple Choice Questions (2 points each):
1. Which of the following statements regarding memory is correct?
(a) Main memory is used to store source files.
(b) A byte is a unit of memory. One byte can be used to represent 512 different values.
(c) Programs in machine language are copied from main memory to auxiliary memory before they
can execute.
(d) Auxiliary memory is nonvolatile.
2. Which of the following statements is NOT correct?
(a) The Java statement int value = "10"; leads to a compile time error.
(b) The Java statement int value = Integer.parseInt(10); leads to a compile time
error.
(c) The Java statement int value = 10.8; leads to a compile time error.
(d) The Java statement int value = Integer.parseInt("String"); leads to a com-
pile time error.
3. Which of the following is NOT a valid identifier name in Java?
(a) 5silly
(b) silly$
(c) silly5
(d) $silly
4. What output does the following code snippet produce?
System.out.println("This \tis a \"funny\"" + "\nstring.");
(a) This is a "funny"
string.
(b) This is a "funny" string.
(c) This is a funny string.
(d) This
is a "funny" string.
1
Unlock document

This preview shows pages 1-3 of the document.
Unlock all 15 pages and 3 million more documents.

Already have an account? Log in
5. Given the variable types declared below, which of the following variable assignments is illegal in
Java?
byte b;
int i;
double d;
char c;
(a) i = b;
(b) b = (byte) i;
(c) i = c;
(d) i = d;
6. What is the output of the following program?
public class IntChar
{
public static void main (String[] args)
{
char c = ’C’;
int cValue = c;
char newC = (char) cValue;
if (newC == c)
{
System.out.println("True");
}
else
{
System.out.println("False");
}
}
}
(a) False
(b) True
(c) True False
(d) The program has syntax errors.
7. Given the variable str initialized below, what is the value of str.charAt(str.length() - 2)?
String str = "Java exams are relaxing";
(a) ’i’
(b) This statement produces an error.
(c) ’g’
(d) ’n’
2
Unlock document

This preview shows pages 1-3 of the document.
Unlock all 15 pages and 3 million more documents.

Already have an account? Log in