CS201 Midterm Exam Topics
The CS201 exams are open book and open notes. However,
they are not open-neighbor. You can use a computer to access any notes you may have taken or to read your book (if you purchased it online). However, you are not allowed to use the computer to compile and run programs or to do anything online. You will have a variety of questions on the exam. There will
be a small number of short-answer and multiple choice questions. There will be more
questions where you will be asked to write some code, or you will be
given some code and asked to produce what the output of the code
will be when executed. The topics that will be covered are listed
below:
Computer Programming
Overview
- What an algorithm is, why it is important
- Difference and pro's/con's between a compiler, an interpreter, and an
assembler
- General layout of a Java Program
- e.g main, where import goes, when to use { }, how whitespace is
handled
- How to use comments and when to use comments
- Know how to enter, compile, and execute your program
Input and Output
- How to use System.out.println to output variables,
text
- How to use Scanner for input
- How to use nextInt(), nextDouble(), etc. to convert a
string to a numeric type
- Be aware of problem using nextLine() combined with next() or nextInt()
or nextDouble()...
- Know about the escape characters for output
Identifiers and Variables
- Valid/Invalid identifiers
- Data Types
- Understand the concept of a data type
- Know char, int, float, boolean, long, double, and String
- Variables
- What they are, how to define them
- Assigning values to variables, initialization
- Shorthand notations for assignment, e.g. ++, --, +=, *=
...
Strings
- Use of the dotted notation to invoke string methods
- substring, length, indexOf methods
Expressions and Operators
- Basic operators of +, -, *, /, %
- Operator precedence
- Assignment operator
- Type casting
- Issues in going from float to integer, vice versa
- Boolean Expressions
- ==, != <, >, <=, >=
- Combining with && and || and ! to produce complex logical
expressions
- Precedence in relation to other operators
- Problem with using == with strings
- Generating random numbers
Flow Control
- If-then statement along with if-then-else
- Nested if-statements
- When to use {}
- Short circuit evaluation
- While Loops
- Looping criteria
- Nested loops
- Count-based vs. Event-based loops
- Infinite loops
- Do-while loops
- Concept that the loop body will always be executed
- Break, Continue
- For loops
- General syntax and usage
- Nested loop to process pixels in an image
- Conversion
- Given code written in one type of loop, you should be able to convert it
to another type of loop
- Switch statement
- Subtleties with using break; and what happens without
break;
Misc