Should I omit CSC 108 and only take CSC 148?
To omit CSC 108 and take only CSC 148, you should be able to
write object-oriented programs, including your own classes. It
is also expected that you know how to program in Java, which is
the language that is used in CSC 148.
Topics
If you are considering omitting CSC 108 and taking CSC 148, then
you should know the following topics:
- Writing, compiling and running programs.
You should know how to write Java classes. You should be able
to compile and run your programs.
- Import Declarations (i.e.,
import javax.swing.*; )
- Primitive expressions and variables (
int, double, char, boolean )
- You should be familiar with the Java API
- Classes
- You should be able to write classes and use existing classes.
- Constructors
this
- Members (
public or private )
static
- subclasses
- Naming Conventions
- Testing (in particular, using
JUnit )
- Variable declarations, initializationsa andassignments
String, StringTokenizer
boolean expressions
if statements
while loops, for loops
- One and two dimensional arrays
- GUIs in Java (i.e., getting user input from a window)
- Searching algorithms
- Sorting algorithms
- Overloading methods
- Inheritance
- Polymorphism
Exercises
In order to take CSC 148, you will need a strong programming background
and you should be able to complete ALL of the following exercises, using
your favourite programming language. Note: you will be expected to write
programs more complicated than these in Java at the beginning of CSC 148.
- In 15 minutes or less, write and debug a program to read a list of
numbers and then print all the numbers, with an asterisk beside the
largest one.
- A palindrome is a word that reads the same forward as it does backwards.
Examples of palindromes are hannah, bob, did, peep and noon. Write and
debug a program that takes a word (as a string) and returns true if the
word is a palindrome, and returns false otherwise. (You can assume that
a word that is a single character is a palindrome.)
- Write and debug a program that takes a list of characters, and prints the
elements with even indices on a single line with a space between characters.
Quiz
If you think that you know most of these topics and you can do the exercises,
then you may want to take the quiz below to test your knowledge. It order to
omit CSC 108H and take only CSC 148H, it is not enough to have just heard of
these topics. You should thouroughly understand the topics and be able to apply
them. Try the quiz (give yourself 1 point for each correct answer):
1. |
What kind of information does a reference to an object contain? |
|
Show Answer
It contains the memory address of the object.
|
2. |
What is the difference between a class and an object? |
|
Show Answer
An object is an instance of a class, and is created
while a program is running; a class is a blueprint of an object.
|
3. |
What does the 'new' operator do? |
|
Show Answer
Instantiates (creates) a new object and returns a reference to it.
|
4. |
What are the parts of a class that determine the behaviour of an object? |
|
Show Answer
The methods defined in the class associated with the object.
|
5. |
What is an instance variable? |
|
Show Answer
A value that belongs to a particular object of a class;
every object of the class has its own value for each instance variable,
and the values are generally different between different objects.
|
6. |
What is the difference between public and private methods? |
|
Show Answer
Public methods can be accessed by any class; private methods
are only accessible by the class containing them.
|
7. |
What is the output from the following Java program?
public class Example {
public static void main (String[] args) {
int x;
ObscureType y = new ObscureType (3);
x = y.action();
System.out.println ("Result = " + x);
}
}
class ObscureType {
public int data;
public ObscureType (int value) {
data = value;
}
public int action () {
int i = 0;
int sum = 0;
while (i <= data) {
sum = sum + i;
i = i + 1;
}
return sum;
}
}
|
|
Show Answer
Result = 6. But even if you get it wrong, give yourself a
mark for this question if you now understand why the answer is 6.
|
Scoring
Give yourself 1 point for each correct answer.
- 6 to 7: You are probably ready to take CSC 148.
- 4 to 5: If you take CSC 148 without 108 first, be prepared for extra work.
- 3 or fewer: You should take CSC 108 before trying 148.
If you know the topics and you have done well on the exercises and quiz,
then you may want to omit CSC 108H and take CSC 148H.
If you are not famililar with these topics or if you did not do well on
the quiz, then you should take CSC 108H.
|