Chapter 1 Chapter 2 Chapter 3 Code Gone Wrong Random 5 pt 5 pt 5 pt Eleanor M. Savko Chapter 1 Chapter 2 Chapter 3 4/11/2017 Code Gone Wrong Random 5 pt 5 pt 5 pt 5 pt 5 pt 10 pt 10 pt 10 pt 10 pt 10 pt 15 pt 15 pt 15 pt 15 pt 15 pt 20 pt 20 pt 20 pt 20 pt 20 pt 25 pt 25 pt 25 pt 25 pt 25 pt
What is the difference between Application and System Software What is the difference between Application and System Software? Give one example of each.
System: supports basic operations examples: operating system, compiler Application: accomplish specialized tasks examples: word processor, spreadsheet, etc
Convert to base 10: 0011 1001
57
What is the difference between ASCII and Unicode?
ASCII = 1 byte per character Unicode = 2 bytes per character
Which is oldest? (i) Assembly Language (ii) High-Level Language (iii) Machine Language
Machine Language
Name the stages of the Software Development Life Cycle (in order)
1) Customer Request 2) Analysis 3) Design 4) Implementation 5) Integration 6) Maintenance
What is the JVM, and what does it do?
Java Virtual Machine. It acts as an interpreter for the machine.
What is source code? What is byte code? What are their extensions?
Source Code: file written by programmer ( Source Code: file written by programmer (.java extension) Byte Code: created by compiler (.class extension)
Give an example of “storage” and an example of “memory”
Storage: hard drive, floppy, cd-rom, etc. Memory: RAM, ROM
Name three primitive data types.
int, double, boolean
Declare and instantiate an object of class KeyboardReader.
KeyboardReader reader = new KeyboardReader();
Declare three integer variables (a,b,c) in a single declaration and initialize b to 4.
int a, b=4, c;
What is wrong with this code. How can you fix it What is wrong with this code? How can you fix it? int inches; inches = reader.readInt(); double feet = inches/12;
int/int = int Fixed with casting
String x = “number “ + 3 + 4; String y = “number “ + 3 String x = “number “ + 3 + 4; String y = “number “ + 3 * 4; String z = “number “ + (3 + 4);
x = “number 34” y = “number 12” z = “number 7”
What is the value of s2? int x = 8, y=10; String s1 = “hey”; x = x + y; String s2; s2 = x + y + s1 + x + y;
28hey1810
double z = 9. 0; int x=4, y=13; double a, b, c; a = y / x double z = 9.0; int x=4, y=13; double a, b, c; a = y / x * z; b = (double) (y / x) * z; c = y % x / 3;
a = 27.0 b = 27.0 c = 0.0
Find the Syntax Error int x = 20, y = 15, z; double u=2. 1, v=33 Find the Syntax Error int x = 20, y = 15, z; double u=2.1, v=33.3; z = x/y; u = x; z = (int)(u/v); w = u + v; u = x/y*u*v;
w is not declared
Find the Syntax Error: int a=5, b=10, c=2; double d=2. 2, e=33 Find the Syntax Error: int a=5, b=10, c=2; double d=2.2, e=33.1; String s=“bob”; a = a/b; d = a/b; b = c/b + e; s = a + s + e;
b = c/b + e; double assigned to int
Find the Syntax Error: String one = “you”; String two = “smell”; String three = “funny”; String four; four = one + two + three; four = “four”+“four”+four; four = one + two + three + too!; four = two;
four = one + two + three + too!; String literal not in quotes!!!
Find the Syntax Error: int x =5, y=10, z; double a=1. 2, b=2, c=4 Find the Syntax Error: int x =5, y=10, z; double a=1.2, b=2, c=4.1; a = x/y; x = (int)c / b + y; a = (double)(x/y); c = c + y; z = (int)c / x;
x = (int)c / b + y; Assigning double into int variable!
Find the Syntax Error: int x =5, y=10, z; double a=1. 2, b=2, c=4 Find the Syntax Error: int x =5, y=10, z; double a=1.2, b=2, c=4.1; a = x/y; x = (int)(c / b) + y; a = (double)(x/y); c = c + z; z = (int)c / x;
c = c + z; z has not been initialized
double x =(double) (1/4) * 4; System.out.println(x);
0.0
Convert to Base 10 1000 1111
143
String blah = “I”; String blah2 = “Can”; String blah3 = “Program”; blah = blah + blah2; blah2 = blah; System.out.println(blah + “\n” + blah3 + “\n” + blah2 );
ICan Program ICan
Convert from hexadecimal to base 10: 59AF
22959
Which of the following expressions does NOT evaluate to 0. 4 Which of the following expressions does NOT evaluate to 0.4? (A) (int)4.5 / (double)10; (B) (double)(4/10); (C) 4.0 / 10.0; (D) 4 / 10.0; (E) (double)4 / (double)10;
(B) (double)(4/10);