CIS 120: Problem Solving and Programming Concepts I Study Guide for Test 1 – Fall 2007 Reading Carefully review all handouts. Read our textbook chapters 1, 2, 3, 4.1, 4.2. At the end of each chapter you should do the review questions! (They are all fair game for the test questions!!) The answers to the review questions (and other good stuff) can be found at http://www.cs.armstrong.edu/liang/intro6e/intro6estudentsolution.html Fundamental Concepts Computers: hardware and software o What is the difference between hardware and software? o How is information stored in a computer? o What is the difference between a bit, a byte, and a kilobyte? Polya’s problem-solving methodology o What are the four basic steps? o How do they relate to programming? Software Development Life Cycle o What are the six basic steps? o How do they relate to Polya’s problem solving steps? Documentation and Design o Why do we need documentation? What is its purpose? o Be able to write pseudocode. o How does the top-down (decomposition) approach to creating pseudocode work? Algorithm o What is an algorithm? Binary representation of characters (Unicode and ASCII) o Be able to convert from binary to decimal and vice-versa o How are ASCII and Unicode different? How are they alike? o Which does Java use to represent characters? Generations of programming languages o What are the three generations of programming languages? o What do example lines of code from each look like? o What generation does Java belong to? The Java Programming Language Platform independence of the Java language and Java Environment o What does it mean that Java is platform independent? o What are Java bytecodes? Where do they come from? o What do javac.exe and java.exe do? Classes o 3 things that make up a .java file Optional package statement 0 or more import statements 1 or more class /interface definitions o Applications or resources are called what in Java? o 5 things that make up a class definition. o What is meant by a method in Java? o Name three classes that are provided by Java language (in java.lang). o Main Method – What is it? How many can we have in one application? Types, Identifiers, Variables, Literals o What are the 8 primitive data types in Java? And how many bytes are allocated for each? o What is an identifier? o What is a variable? o What is a literal? o Difference between variables and literals o What is a constant? General Programming Concepts Errors: syntax, run-time, and logic o What is an error? o What are the differences between syntax, run-time, and logic errors? What are they caused by? When are they caught? Operations o What is the order of operations? o What are the arithmetic operators? How are they used? What do they calculate? o What are the relational operators? How are they used? What do they calculate? ==, !=, >, >=, <. <= o What are Logical operators? How are they used? What do they calculate? &&, ||, ! o Be able to calculate the values that statements using these operators evaluate down to (e.g. expressions using integer division and modulus operator) o Understand implicit type conversion (type widening) and when it occurs o Understand explicit type conversion (casting/type narrowing) and when it is needed o Understand the subtleties of integer division o Operator Associtivity o What is Boolean short circuiting? Coding Convention and Identifiers o What is meant by coding convention? o Be able to tell the difference between a valid identifier and an invalid one. o What conventions are used for various kinds of identifiers: method names, variables, constants, class names? o Proper spacing and indentation o Proper use of comments/self documenting code (single and multi-line styles) Control Structures o What are the three basic control structures? Sequence, Selection and Repetition o How do we implement the selection control structure? o How do we implement the repetition control structure? Programming in Java (be able to create Java code based on the following concepts) Java keywords o What are the common keywords that we use in Java? Creating input and output o What does the method call System.out.print (“…”) and System.out.println (“…”) do? o What method in class JOptionPane do we use to produce output? What parameters does it take? o What method in class JOptionPane do we use to receive input? What parameters does it take? Data types o How do we declare and intialize variables of a particular type? o How are constants declared? (final) o Understand the difference between primitive data types and reference types (for referencing objects of a particular class). If a data type is not one of our 8 primitive data types then it must be a reference type. Strings o String is not one of Java’s 8 primitive data types! But rather, as suggested by its spelling with an “S” is a _________? o What are Strings made of? o How do we concatenate information onto a String? o Where does the String class come from? Operators o Assignment operator What symbol do we use to assign a value to a variable? o Shortcuts How do the following expression evaluate? y = x++; x += 20; y = ++x; y = x--; y = --x; If-statements o What is the syntax for an if-statement? Why is it beneficial to use curly braces to specify a block of code for an ifstatement? If there are no curly braces, how many statements can the if-statement contain? o What is the dangling-else problem? What is it caused by? How can it be fixed? o What happens if the condition in the if-statement is evaluated to true? o What happens if the condition in the if-statement is evaluated to false? o What does an else-clause to an if-statement signify? o What is a nested if-statement? Switch-statement o What is the syntax of a switch statement? o In the line “switch (someVariable) { “ what data types can the someVariable be and what types can it not be? o What is meant by: “case 1 : case 2: “? o What is the nature of the optional default clause in a switch statement? o Where to we use the break command and why? o Is the switch-statement actually NEEDED in Java? (explain) While-loops o What is the syntax of a while loop? o What happens if the condition of the loop is evaluated to true? o What happens if the condition of the loop is evaluated to false? o What is the difference between a sentinel-controlled loop and a counter-controlled loop? What is an example when one should be used over another? o Which kind of loop is a while-loop, pretest-loop or a post-test loop? o How many times does the loop body of a while statement get executed? (0 or more times) Java code: declaring variables (ints, doubles, Strings, booleans), JOptionPane (input and output), applications and main method, selection: if statements, if-else statements, switch statements, repetition: while loops, the use of conditions, mathematical operations, assignment (=) operator, auto-increments (x++ or x--), import statements, comments (single and multi-line), String to numeric conversions (i.e. Integer.parseInt(___) ...). Terms: algorithm, ASCII, assignment statement, binary, binary counting, bit, boolean, byte, class, compiler, 8 primitive data types, new operator, constructor, Java keyword “static” and its use, CPU, final, float/double, flow charts, hard disk drive, I/O, IDE, identifiers, int/bye/short/long, integer division, interpreter, java.lang, Java, java, Java application, javac, JDK, kilobyte, logic error, main memory, megabyte, megahertz, modulus operator, object, object code, Object Oriented Programming, order of operations, output device, overflow, programming comments, Polya problem solving, program, programming languages, pseudo-code, RAM, ROM, roundoff error, run-time error, secondary memory, SLC, source code, syntax error, system clock, Unicode, variable, variable declaration. debugging, data dictionary, meaningful identifiers, pre-test loop, bytecode, software, hardware, editor, keyword parameter, dangling else, selection, nesting, repetition, iteration, sequence. Programming skills: writing code, filling in blanks in code, error detection for given code, tracing the effects of code, explaining the effects of code, input and output, control structures (if and while statements), problem solving.