150 likes | 285 Views
FINAL EXAM. Final Exam Wednesday, Dec 14: 8:00 - 10:00 AM (Frny G140) Cumulative (weighted towards recent material) 40 MC (2 points each), 6 programming (20 points each) = 200 points total Old Final Exams Available On Website. Chapter 1: Introduction to Computers and Java. Hardware, memory
E N D
FINAL EXAM • Final Exam • Wednesday, Dec 14: 8:00 - 10:00 AM (Frny G140) • Cumulative (weighted towards recent material) • 40 MC (2 points each), 6 programming (20 points each) = 200 points total • Old Final Exams Available On Website
Chapter 1: Introduction to Computers and Java • Hardware, memory • Object Oriented Programming: Encapsulation, Polymorphism, Inheritance • Java Programs: .java, .class files, byte-code interpreter
Chapter 2: Primitive Types, Strings, and Console I/O • Variables (int, char, float, etc): declarations, assignment, naming • Type Casting: Implicit and Explicit • Integer/Float Division, Parentheses/Precedence Rules • String class: concatenation, indices (0 to n-1) • String methods: length(), equals(), trim(), charAt(), compareTo() • Scanner: need to import java.util.*, next(), nextLine(), nextInt(), etc
Chapter 3: Flow of Control • If-else statements, nested if-else statements • Comparison operators (==, !=, >, <=, etc) • Boolean operators: &&, || • Switch statement (make sure to have “break;”) • While loop: 0 or more iterations • Do-while loop: 1 or more iterations • For loops: for(initialize; boolean_check; update_action) • Nested loops • Boolean type (only “true” or “false” values)
Chapter 4: Defining Classes and Methods • Class definition: “public class Class_name {“ • Public/private data variables • Method definition: “public typemethod_name {“ • Methods return values (int, string, etc) or don’t (null) • Invoking methods: “object_name.method_name();” • Creating objects: “Class_namevariable_name = new class_name();” • The “this” parameter • Information hiding/encapsulation • Objects variables: references (memory address) vs. data • Equals methods for classes
Chapter 5: More About Objects and Methods • Static methods: called without an object (e.g. Integer.parseInt() ) • Wrapper classes: Integer, Double • Automatic boxing and unboxing • Method overloading: different parameters (cannot change return type) • Constructors: default and others
Chapter 6: Arrays • Creating/accessing arrays • Arrays are a reference to memory segment • For loop: stepping through arrays (.length) (watch out for: ArrayIndexOutOfBounds exceptions) • Arrays of objects • Sorting arrays: selection sort • Multi-dimensional arrays
Chapter 7: Inheritance • Declaration: “public class Class_name extends Class_name2” • Overriding method definitions (“final” modifier: method can’t be overridden) • Superclass constructor calls: “super(parameters)” • Interface implementation: “public class Class_name implements Interface_name” • Implement/Extend: can implement multiple interfaces (comma separated) but extend only one class
Chapter 8: Exception Handling • Try/catch/finally block • Throwing exceptions: “throw new Exception(“info”);” • getMessage for exceptions • Defining your own exception classes: “public class Class_name extends Exception” • Methods throwing exceptions: “public void method_name() throws DivideByZeroException” – don’t have to handle exception in this method but must in calling method • Multiple exception handling (hierarchy)
Chapter 9: Streams and File I/O • Need: import java.io.*; • StringTokenizer class (can use split if you want) • Be sure to try/catch IOExceptions • Text Files: - PrintWriter outputStream = new PrintWriter(new FileOutputStream(“filename”); - BufferedReader inputStream = new BufferedReader(new FileReader(“filename”); - reads nothing at end of file (null) • Binary Files: - ObjectOutputStream outputStream = new ObjectOutputStream(new FileOutputStream(“filename”); - ObjectInputStream inputStream = new ObjectInputStream(new FileInputStream(“filename”); - throws EOFException at end of file
Chapter 10: Dynamic Data Structures • Need: import java.util.*; • Vectors: declaring, adding elements, setting elements, retrieving elements • Linked Lists: creating classes (link to object of same type) • Empty List: null pointer (last item always points to null) • Generics: no primitive types, defining classes and methods
Chapter 11: Recursion • Three things needed: 1. Branching statement 2. Recursive call 3. Stopping case (aka “Base case”) • Can always write recursive methods as iterative but not always easier to write/understand • Binary Search • Merge Sort
Chapter 12: Window Interfaces Using Swing • Event-driven programming (button clicks, etc) • Need: import javax.swing.*; import java.awt.*; import java.awt.event.*; • Declaring swing class: “public class Class_name extends JFrame” • JLabel, JButton, JTextArea, JTextField, JPanel, ContentPane • Constructor: set size etc, be sure to “setVisible(true);” • Layout Managers: FlowLayout, BorderLayout, GridLayout • ActionListener method for handling events: “… implements ActionListener”
Chapter 13: Applets and HTML • Same imports needed as swing • Classes: “public class Class_name extends JApplet” • Need: “public void init()” method: no constructor, no setVisible
Chapter 14: More Swing • Menus: JMenu, JMenuItem, JMenuBar • Nesting menus • Icons, JScrollPane • Layout Managers: BoxLayout, CardLayout • Inner classes