/******************************************************************/
This document is subject to change. Please monitor regularly.
Please report any errors or omissions in this document:
anne.dawson@gmail.com
This document is current at: Sunday 17th February 2008, 10:12 PT, AHD
/******************************************************************/
CSCI102 students:
THE MIDTERM EXAM
================
The date of the midterm exam is shown on the C4 system.
The exam is in Room 1, at the regular class time.
For exam results, see below...
****************************************************************
Unauthorised absence from the Midterm exam is an automatic fail.
****************************************************************
The midterm exam is a 2 hour written exam.
*** Students must bring their student cards
for inspection before the exam. ***
The midterm exam is worth 25% of the final grade.
Students must attain an overall passing grade on
the weighted average of the two exams in the course
in order to obtain a clear pass (C or better).
You should focus on the page numbers listed under the "Reading" column
on the course schedule
for Chapters 1,2,3 and 4 (4th Ed) or Chapters 1 through 5 (5th Ed)
see C4 main page for page references.
The midterm exam will be composed of a mix of questions:
Part 1 of the exam is made up of
50 multiple choice or true/false questions
worth 1% each. (50%)
Part 2 of the exam is composed of
a number of predict-the-output-of-programs questions
worth a total of 30% and 2 written questions
worth 10% each. Marks will be awarded for
partially correct answers in Part 2.
********************************************************************************
Example multiple choice question:
Input to the java compiler is called:
A. byte-code B. source code C. executable code D. object code
********************************************************************************
Example multiple choice question:
Output from the java compiler is called:
A. byte-code B. source code C. executable code D. object code
********************************************************************************
Example multiple choice question:
Which of the following is one kind of branching statement?
A. compound statement B. for statement
C. break statement D. switch statement
********************************************************************************
Example short-answer question:
Evaluate the following expression: !((6 * - 5 / 4) >= (5 * (4 - 3) % 2))
********************************************************************************
Example short-answer question:
In Java, a library of classes is called a ______________
********************************************************************************
Example short-answer question:
The term __________ refers to a way of organizing classes that share properties.
A. object-oriented B. encapsulation C. polymorphism D. inheritance
********************************************************************************
Example predict the output question:
What is the output of this Java program?
public class Program1
{
public static void main(String[] args)
{
int x = 4;
while ( x <= 8 )
{
for ( int y = x; y > 1; y = y - 1 )
{
if ( y % 2 == 0 )
System.out.print( "x" );
else
System.out.print( "y" );
}
System.out.println();
x = x + 1;
}
}
}
********************************************************************************
Example predict the output question:
What is the output of this Java program?
public class Program4
{
public static void main(String[] args)
{
int n = -23;
while ((n % 2) == -1)
{
if (n == 2)
break;
n = n + 2;
System.out.println("n = " + n);
}
}
}
********************************************************************************
Example written question:
Consider the following two Java files.
One of them compiles with no errors,
the other generates compilation errors.
Which one compiles, and which does not?
Explain your answers.
public class Program2
{
private String x;
private int y;
private double z;
public void assignValues()
{
x = "Anne";
y = 10;
z = 3.142;
}
}
public class Program2Demo
{
public static void main(String[] args)
{
Program2 object1 = new Program2();
object1.assignValues();
System.out.println("The values are:");
System.out.println(object1.x);
System.out.println(object1.y);
System.out.println(object1.z);
}
}
********************************************************************************
Example written question:
The following code compiles with no errors, but contains a logic error:
public class Program3
{
public static final double PI = 3.142;
public static void main(String[] args)
{
double radius = 3.0;
double area = PI * radius * radius;
double semi_area = area * (1/2);
System.out.println("The area of semicircle of radius 3.0 is: "
+ semi_area);
}
}
Write a Java statement to replace the statement which contains the logic error,
so that the program will run as intended.
********************************************************************************
EXAM RESULTS
------------
All exam results are entered into Gradebook asap.
The instructor will see each student individually
to return written exam papers and bring grades up-to-date.
Your attendance, conduct and progress are monitored throughout the course.
You may inspect your status report at any time using the online Gradebook
/************************************************************/
Good Luck!
AHD
/************************************************************/
End of document