0% found this document useful (0 votes)
11 views

Unit 2 Test Review ICS3U 2025

The document outlines the format and content of the Unit 2 Test for ICS3U, including guidelines for study materials and types of questions. Key concepts covered include data types, control structures, error types, arrays, and methods, along with examples of pseudocode. A terminology list is also provided for essential programming terms that students should understand and identify.

Uploaded by

anisamalik08
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views

Unit 2 Test Review ICS3U 2025

The document outlines the format and content of the Unit 2 Test for ICS3U, including guidelines for study materials and types of questions. Key concepts covered include data types, control structures, error types, arrays, and methods, along with examples of pseudocode. A terminology list is also provided for essential programming terms that students should understand and identify.

Uploaded by

anisamalik08
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 15

Unit 2 Test Review

ICS3U
The Format
• You can prepare a study guide to bring in (1 double sided page).
• No access to google, ChatGPT, etc…
• No coding for the test.
Definition Sections (roughly 5 questions)
• Matching
• Multiple Choice
• Few short answer
Code Identification Sections (roughly 5 questions)
• Identifying usage of programming concepts in code examples
• Identifying the purpose of code examples
• Identifying the output of code examples
• Labeling code examples
Pseudocode (2 questions)
• Reading a pseudocode plan and determining the purpose and output of it.
• Creating a code outline/plan for how you would create a program.
Concepts: Data Types and Variables
• Primitive Data Types: int, double, Boolean, character
• Objects: Strings, Scanners, etc…
Data types define what kind of data can be placed inside a variable.
The type must be declared when the variable is first created.

Variables have a scope: the scope of a variable are the areas of the
programs that a variable exists in. The scope of a variable is defined by
where in the program the variable is defined:
Variables only exist in the control structure in which they are defined.
Control Structures
Used to control the flow of a program.
• If
• Based around Booleans statements. If this is true … then do this …
• Switch//Case
• Uses case matching to execute code.
• For
• Used to loop a countable number of times
• Do
• Used to loop while a Boolean statement is true: checks at the end of the loop.
• While
• Used to loop while a Boolean statement is true: checks at the start of the
loop.
• Try//Catch
• Used to catch errors. Code is tried and will be caught if it throws an exception
If Statements
if (Boolean == true){
//do this code
} else if (Boolean == true){
//do this code (if the above did not happen)
} else if (Boolean == true){
//do this code (if the above did not happen)
}…
}else{
//do this code (if none of the above did not happen)
}
If Statements Statement Operator Statement Outcome
True && True True
Comparison (aka Relational) Operators
True && False False
False && True False
False && False False

Statement Operator Statement Outcome


True || True True
True || False True
Logical (aka Conditional) Operators False || True True
! not False || False False

&& and Operator Statement Outcome


|| or ! True False
! False True
Switch Cases
switch (variable){
case 1:
//this will happen if variable matches 1
break;
case 2:
//this will happen if variable matches 2
break;
case 3:
case 4:
//this will happen if variable matches case 3 or 4 (fall through)
break;
default:
//this will happen if none of the cases matched
break;
}
For Loops
for (iterator; conditional; increment){
// this will loop as long as the conditional statement is true.
// iterator is the counter used to control the loop (typically part
// of the conditional).
// it changes by the increment each time the loop loops.
}
Do Loops

do{
//this will repeat as long as the conditional is true
//the conditional is only checked at the end of the loop
//this guarantees that the loop will run at least once
} while(conditional);
While Loops
while(conditional){
//this will repeat as long as the conditional is true
//the conditional is checked at the start of the loop
//the loop might not run
}
Errors
• Syntax: These errors occur from typos or mistakes in the code you
write. It makes code uncompilable and, therefore, not runnable. They
are caught by the IDE with a red underline (usually).
• Runtime: These errors occur while the program is running. They will
crash the program, throwing an Exception. There are many different
kinds of Exceptions (like IOException, ArithmeticException, etc..)
• Logic: These types of errors don’t cause the program to crash. They
won’t be underlined by the IDE. Instead they cause the code to have
unexpected or unplanned outcomes.
Arrays
An array is a type of data structure—that is a way of orgnaizing and
representing information. In Java an array is a collection of variables that
share a type.
Element: Each variable within an array is called an element. An element is
made of both a value and an index.
Index: The index of an element refers to its position within the array.
Each array starts counting indexes at 0, and the indexes increase by 1
reaching up to the length of the array – 1.
Value: A value is the actual information stored at the index.

dataType arrayName[] = new datatype[arrayLength]


Element
Value “Apple” “Orange” “Potato” “Banana” “Football”
Index 0 1 2 3 4
Methods
Methods are small sub programs that are part of a class. They only run
when they are called.
Parameter: Variables that are local to the method. They are provided
with values when the method is called.
Return Statement: This is the value that is returned to the location of
the method call. It must match the datatype of the method (and must
be blank if the datatype is void)
public static dataType methodName (parameters){
//code for the method goes here
return dataType; //only allowed if dataType is not void.
}
Pseudo Code Example (From Last Year’s Test)
MAIN START
LOOP 1 START
print "Please enter an integer"
input -> length
if length is less than or equal to 0 or greater than 26 or not integer then
print "invalid input, please try again"
repeat LOOP 1
else
continue past LOOP 1
LOOP 1 END

counter = 0
for 1 to length
increase counter by 1
call ALPHABET pass counter as parameter
MAIN END

FUNCTION ALPHABET (parameters: counter)


print letter that matches counter
Terminology List (Concepts/Terms that you
should know and be able to identify)

Declaration Control Structure Syntax Error


Assignment Boolean statement Run Time Error
Data Type Logical Operator Logic Error
Variable Name Comparison Operator Array
Variable Scope Exception Element
Primitive Fall Through Index
Object Iterator Parameter
Class Import Increment Return Statement
Overloading

You might also like