AP Computer Science Summer Packet
AP Computer Science Summer Packet
You are suppose to watch each one of the videos in order and answer the questions as you do so. Make
sure you show your work as it has been done in the video. After you complete all questions you should
then do the practice problems on your own. Read the introduction before the videos.
NUMBER SYSTEMS
Introduction
The key aspect of the number systems that we will look at is the base. The base indicates the number of
digits for each place. The one that we use is base 10 (decimal). The 10 digits that we use in this are 0, 1,
2, 3, 4, 5, 6, 7, 8, and 9. Why do we use this over something else like base 2?..... It is for no other reason
than the fact that we are born with 10 fingers and that is what all humans learn to count with.
A number in base b can be converted to its equivalent in base 10 by using place values.
Likewise, the digits in the base 2 number 110101 represent powers of the base 2.
The same can be done for any other base such as converting 13F16 to base ten.
5: 6: 7: 8:
Video 1: https://www.khanacademy.org/math/algebra-home/alg-intro-to-algebra/algebra-alternate-
number-bases/v/number-systems-introduction
Video 2: https://www.khanacademy.org/math/algebra-home/alg-intro-to-algebra/algebra-alternate-
number-bases/v/hexadecimal-number-system
4) Now try to repeat the steps to convert FF(16) and AF3(16) from hexadecimal to decimal.
Video 3: https://www.khanacademy.org/math/algebra-home/alg-intro-to-algebra/algebra-alternate-
number-bases/v/decimal-to-binary
Video 4: https://www.khanacademy.org/math/algebra-home/alg-intro-to-algebra/algebra-alternate-
number-bases/v/large-number-decimal-to-binary
Video 5: https://www.khanacademy.org/math/algebra-home/alg-intro-to-algebra/algebra-alternate-
number-bases/v/decimal-to-hexadecimal
Video 6: https://www.khanacademy.org/math/algebra-home/alg-intro-to-algebra/algebra-alternate-
number-bases/v/binary-to-hexadecimal
1) Follow the steps in the video to convert 1011011102 from the binary system to the
hexadecimal system.
AP CS A - Summer Work – Part 2
1012 = 10102 =
1011012 = 1101010.112 =
2716 = 13AD16 =
10716 = 9116 =
1011011011101100010110112
1000111010111101011101100100101001012
A7F316
D239AE16
AP CS – Summer Packet – Part 3
5) Complete the chart that represents the communication between the user and the hardware.
8) What are the two specialized units inside the CPU? What tasks do they perform?
11) How are the secondary memories like Hard drives, different from the main memory?
AP CS – Summer Packet – Part 3
Hardware
• The CPU (Central Processing Unit) is made of millions of semiconductor devices, called transistors,
etched into a silicon chip.
Gates
A A
A AND B A OR B A NOT A
B B
A B A AND B A B A OR B A NOT A
T T T T T T T F
T F F T F T F T
F T F F T T
F F F F F F
Hardware Terms
• RAM — Random-Access Memory “random-access” means the CPU can read directly from and write
to any memory location holds both data and CPU instructions
• ROM — Read-Only Memory holds initialization and hardware diagnostic programs • Peripheral
devices (secondary storage, input/output)
Motherboard
AP CS – Summer Packet – Part 3
Numbers in Memory
0 00000000
1 00000001
2 00000010
3 00000011
... ...
255 11111111
• For signed numbers, the most significant bit indicates the sign (the leftmost digit)
• Real numbers are represented as floating-point numbers (similar to scientific notation) with a sign,
binary mantissa (fractional part), and binary exponent.
• Java uses 8 bytes (64 bits) for a “double” (that is, double- precision) floating-point number.
Characters
• ASCII (American Standard Code for Information Interchange) is a subset comprising the first 128
codes of Unicode:
• The first 32 codes are control codes (Carriage Return, Newline, Tab, etc.)
AP CS – Summer Packet – Part 3
________________ fetches and processes instructions and places the result back into
_____________________ .
PROGRAMMING LANGUAGES
Programming Languages
\ C C++ C#
Assembly LISP Scheme
languages Java D Swift
Algol Logo Ada
1940 1950 1960 1970 1980 1990 2000 2010 2015
Fortran Pascal Python
Machine Basic Fortress Hack
code Cobol Groovy
Smalltalk Smalltalk-80
2-2
AP CS – Summer Packet – Part 3
Thousands of programming languages and dialects have been described; many evolved over the years,
others have disappeared, some existed for years but recently gained new popularity (e.g., Perl, Python).
Java was initially meant for embedded systems (like home appliances) and for “interactive TV” but has
survived due to the Internet.
• Low Level Languages (machine language and assembly language) – Humans can’t understand.
Machine code is called “first generation”; Assembly languages are second generation;
• High Level Languages are programming languages that computers can’t understand. They look like
English. Ex: C, C++, Java, Python,… They are third generation.
• A HLL must be translated into machine language. The software that does that is a compiler or an
interpreter.
• Compilers take an ENTIRE program (source code) as input and creates all executable instructions
together and as compiled code (object code)
• Interpreters take single instructions as input, create a corresponding machine instruction that is then
executed.
Compiler
Source Machine
Code Compiler Code
*.exe
2-5
Compiler
A programming language has a strict syntax. A compiler parses the source code and checks the syntax.
• Compilation initially takes time because it has to translate the whole code into machine language and
save it into the hard disk.
• It creates an executable file called object code. Once compiled, the Operational System can executed
the code over and over again without the need of recompiling.
Interpreter
Interpreter
Source
Code
Interpreter OUTPUT
INPUT
2-7
AP CS – Summer Packet – Part 3
• Every time you want to run the program you need to interpret the code again line by line.
Compiled X Interpreted
• Compiler:
checks syntax
• Interpreter:
checks syntax
What is Java?
• Java is a high level, object-oriented computer programming language developed by James Gosling in
the mid 1990’s.
• The major difference from Java to many languages is that it was designed to be machine-independent,
that is, a Java program could be written in any platform (Windows, Mac, Linux,..), and then could run in
any platform. WHY?
• A Java compiler converts Java source code into instructions for the Java Virtual Machine.
• These instructions, called bytecode, are the same for any computer/operating system.
on a particular computer.
J
Editor Source Compiler Object
code code
2-13 2-14
• Editor: programmer writes source code (in a language that the computer can’t understand)
• Compiler: translates the source into object code (instructions specific to a particular CPU – or machine
code)
• Debugger: steps through the program “in slow motion” and helps find logical mistakes (“bugs”).