CS 112 Department of Computer Science George Mason University CS 112 Department of Computer Science George Mason University Final Review Lecture 14.

Slides:



Advertisements
Similar presentations
AP Computer Science Anthony Keen. Computer 101 What happens when you turn a computer on? –BIOS tries to start a system loader –A system loader tries to.
Advertisements

Introduction to C Programming
Java Programming, 3e Concepts and Techniques Chapter 3 Section 63 – Manipulating Data Using Methods – Day 2.
Written by: Dr. JJ Shepherd
CERTIFICATION OBJECTIVES Use Class Members Develop Wrapper Code & Autoboxing Code Determine the Effects of Passing Variables into Methods Recognize when.
Chapter 6: Arrays Java Software Solutions for AP* Computer Science
George Blank University Lecturer. CS 602 Java and the Web Object Oriented Software Development Using Java Chapter 4.
CS 206 Introduction to Computer Science II 01 / 21 / 2009 Instructor: Michael Eckmann.
Chapter 5: Keyboard I/O & Simple GUI’s Copyright 2002, Matthew Evett. These slides are based on slides copyrighted by John Lewis and William Loftus, 2002,
1 Chapter 4 Language Fundamentals. 2 Identifiers Program parts such as packages, classes, and class members have names, which are formally known as identifiers.
Wednesday, 12/11/02, Slide #1 CS 106 Intro to Comp. Sci. 1 Wednesday, 12/11/02  QUESTIONS??  Today: CLOSING CEREMONIES!  HW #5 – Back Monday (12/16)
Java Programming, 3e Concepts and Techniques Chapter 3 Manipulating Data Using Methods.
Datalogi A 1: 8/9. Book: Cay Horstmann: Big Java or Java Consepts.
1 CS 177 Week 15 Recitation Slides Review. Announcements Final Exam on Sat. May 8th  PHY 112 from 8-10 AM Complete your online review of your classes.
1 Chapter 2 Introductory Programs. 2 Getting started To create and run a Java program –Create a text file with a.java extension for the source code. For.
Topic R3 – Review for the Final Exam. CISC 105 – Review for the Final Exam Exam Date & Time and Exam Format The final exam is 120-minutes, closed- book,
CS 225 Java Review. Java Applications A java application consists of one or more classes –Each class is in a separate file –Use the main class to start.
Review CSC 171 FALL 2004 LECTURE 21. Topics Objects and Classes Fundamental Types Graphics and Applets Decisions Iteration Designing Classes Testing and.
CS102--Object Oriented Programming Review 1: Chapter 1 – Chapter 7 Copyright © 2008 Xiaoyan Li.
CS 206 Introduction to Computer Science II 01 / 23 / 2009 Instructor: Michael Eckmann.
Aalborg Media Lab 15-Jul-15 Polymorphism Lecture 12 Chapter 9.
March 2005Java Programming1. March 2005Java Programming2 Why Java? Platform independence Object Oriented design Run-time checks (fewer bugs) Exception.
Copyright © 2003 ProsoftTraining. All rights reserved. Sun Certified Java Programmer Exam Preparation Guide.
Principles of Computer Programming (using Java) Review Haidong Xue Summer 2011, at GSU.
Introduction to Java Appendix A. Appendix A: Introduction to Java2 Chapter Objectives To understand the essentials of object-oriented programming in Java.
Java Programming, 2E Introductory Concepts and Techniques Chapter 3 Manipulating Data Using Methods.
1 Course Lectures Available on line:
©2007 · Georges Merx and Ronald J. NormanSlide 1 Chapter 3 The Structure and Syntax of Java.
Operator Precedence First the contents of all parentheses are evaluated beginning with the innermost set of parenthesis. Second all multiplications, divisions,
Chapter 10 Exceptions and File I/O. © 2004 Pearson Addison-Wesley. All rights reserved10-2 Exceptions Exception handling is an important aspect of object-oriented.
Algorithm Programming Bar-Ilan University תשס"ח by Moshe Fresko.
Lecture 2 Object Oriented Programming Basics of Java Language MBY.
Basic Java Programming CSCI 392 Week Two. Stuff that is the same as C++ for loops and while loops for (int i=0; i
Java ProgrammingtMyn1 Java Programming Timo Mynttinen Mikkeli University of Applied Sciences.
Geoff Holmes and Bernhard Pfahringer COMP206-08S General Programming 2.
APCS Java AB 2004 Review of CS1 and CS2 Review for AP test #1 Sources: 2003 Workshop notes from Chris Nevison (Colgate University) AP Study Guide to go.
1 Java: AP Curriculum Focus and Java Subset Alyce Brady.
Hello.java Program Output 1 public class Hello { 2 public static void main( String [] args ) 3 { 4 System.out.println( “Hello!" ); 5 } // end method main.
CS 112 Department of Computer Science George Mason University CS 112 Department of Computer Science George Mason University Writing Graphic Applications.
Chapter 2: Java Fundamentals
More on Hierarchies 1. When an object of a subclass is instantiated, is memory allocated for only the data members of the subclass or also for the members.
Overloading There is another aspect to polymorphism: Overloading Overloading is not overriding. In Turkish: Overridding: eskisini (geçersiz kılmak) Overloading:
Types in programming languages1 What are types, and why do we need them?
Chapter 14 Abstract Classes and Interfaces. Abstract Classes An abstract class extracts common features and functionality of a family of objects An abstract.
Fall 2002CS 150: Intro. to Computing1 Streams and File I/O (That is, Input/Output) OR How you read data from files and write data to files.
Component 4: Introduction to Information and Computer Science Unit 5: Overview of Programming Languages, Including Basic Programming Concepts Lecture 3.
CS1101 Group1 Discussion 10 Lek Hsiang Hui comp.nus.edu.sg
Chapter 8 Class Inheritance and Interfaces F Superclasses and Subclasses  Keywords: super F Overriding methods  The Object Class  Modifiers: protected,
 In the java programming language, a keyword is one of 50 reserved words which have a predefined meaning in the language; because of this,
By Mr. Muhammad Pervez Akhtar
Spring 2009 Programming Fundamentals I Java Programming XuanTung Hoang Lecture No. 8.
Written by: Dr. JJ Shepherd
Chapter 1 Java Programming Review. Introduction Java is platform-independent, meaning that you can write a program once and run it anywhere. Java programs.
© 2006 Pearson Addison-Wesley. All rights reserved 1-1 Chapter 1 Review of Java Fundamentals.
Object-Oriented Programming: Polymorphism Chapter 10.
CS 1428 Final Exam Review. Exam Format 200 Total Points – 60 Points Writing Programs – 45 Points Tracing Algorithms and determining results – 20 Points.
Object Oriented Programming Lecture 2: BallWorld.
Geoff Holmes and Bernhard Pfahringer COMP206-08S General Programming 2.
 It is a pure oops language and a high level language.  It was developed at sun microsystems by James Gosling.
Java Programming: Guided Learning with Early Objects Chapter 9 Inheritance and Polymorphism.
JAVA MULTIPLE CHOICE QUESTION.
“Form Ever Follows Function” Louis Henri Sullivan
Objectives You should be able to describe: Interactive Keyboard Input
Programming in Java Text Books :
Java Programming Language
An overview of Java, Data types and variables
Chap 1 Chap 2 Chap 3 Chap 5 Surprise Me
FINAL EXAM Final Exam Wednesday, Dec 14: 8: :00 AM (Frny G140)
FINAL EXAM Final Exam Tuesday, May 3: 1:00 - 3:00 PM (Phys 112)
Presentation transcript:

CS 112 Department of Computer Science George Mason University CS 112 Department of Computer Science George Mason University Final Review Lecture 14

CS 112 George Mason UniversityLecture 4 Slide 2 Basics Chapter 1 Computer Basics Binary-1s and 0s Bits and Bytes Characters Encryption into binary, ASCII and Unicode(Java) Networks Java language, compilation, interpretation, Java Virtual Machine

CS 112 George Mason UniversityLecture 4 Slide 3 Chapter 2 String class String variables Printing to the monitor, System.out.println Concationation of strings Primitive Variable Types ints, doubles, chars, booleans Arithmetic operators +, - * /, ++ --, -=,+=,*=,/= Chars-uppercase and lower case, subtract 32 from a, get A Wrapper classes Integer, Double, methods, calling methods of class Data conversion -casting Graphics Drawing on screen, coordinate system, drawing methods (drawRect) etc.

CS 112 George Mason UniversityLecture 4 Slide 4 Chapter 3 String class again. String methods -calling them Using classes Random Math Graphics Components and containers-frame and panel Graphics class (paintComponent( Graphics g))

CS 112 George Mason UniversityLecture 4 Slide 5 Chapter 4 Classes Using and Writing Using classes- Jbutton button = new Jbutton(“press me”); declaring and instantiating objects of a class. constructors button.addActionListener(this); calling class methods Class is a template, has variables and methods defined. Writing classes Constructors- default constructors- other constructors Variables-instance-private Methods - non-static, public Methods-non static in classes Void and those that return a value Parameters Accessing with an object of the class Accessing methods of static classes

CS 112 George Mason UniversityLecture 4 Slide 6 Chapter 4 continued Static Static variables Static methods-can’t call non static Variables Global Instance Local Graphics Components interactive (buttons etc) Events Interfaces required to activate components-requires methods of interface to be defined in class that implements interface

CS 112 George Mason UniversityLecture 4 Slide 7 Chapter 5 Control Structures boolean operators, >=, == !=, && || ! boolean expressions structures if if..else switch while do…while for compound statements, blocks

CS 112 George Mason UniversityLecture 4 Slide 8 Chapter 5 continued Graphics Custom panels and listeners Radio buttons, Dialog Boxes Determining event sources with if statements

CS 112 George Mason UniversityLecture 4 Slide 9 Chapter 6 Writing classes, how to Overloading methods Interfaces Abstract methods Implementing interfaces Graphics Layouts

CS 112 George Mason UniversityLecture 4 Slide 10 Chapter 7 Arrays single and double dimensioned Declaring and creating arrays of primitives Declaring and creating arrays of objects Accessing an array element For loops to access all array elements and manipulate them Command Line Arguments Using arrays as parameters of methods Graphics Listener interfaces for mouse,

CS 112 George Mason UniversityLecture 4 Slide 11 Chapter 8 Inheritance-classes Child classes - extends Overriding of methods in child classes Definition, use this super Graphics Timer class paintComponent method

CS 112 George Mason UniversityLecture 4 Slide 12 Chapter 9 Polymorphism- means many forms Polymorphism in Java classes - late binding Classes- Assigning an object of a child class to a parent object Calling methods with this parent object calls the child method of the same name if it exists Book b = new ComicBook(); //assigning a child to a parent object b.method1(); //call to method1 will call ComicBook method1 if it exists. Interfaces Polymorphism Can declare variables with type equal to some interface Can then assign an object of any class that implements that interface to the interface object; Suppose you have an interface Interface and a class implementing that interface ClassB. You can declare a variable Interface I; You can assign to I an object of type ClassB I = new ClassB();

CS 112 George Mason UniversityLecture 4 Slide 13 Chapter 9 continued Sorting Sorting Selection Sort- Order n squared Given list above, go through list and find smallest Swap that with whatever is first in the list now Go through the remainder of the list and get the lowest 3 Swap that with the second element of the list Continue until finished Insertion Sort Order n squared Put first element into sorted list in proper place Put next element into sorted list in proper place Continue until all elements are in sorted list

CS 112 George Mason UniversityLecture 4 Slide 14 Chapter 9 continued Searching looking for a particular element in a list Looking for 8 in this list Linear Search Order n Begin at the beginning and look through the list for 8. Binary Search Order Ln(natural log) n Must first sort the list Then go to the middle of the list say 6 Check if 6 is larger or smaller than your target 8 As it is smaller, drop the first half of the list Go to the middle of what is left say 10 Ask again whether this is bigger or smaller, it’s bigger Drop the last half of the list and continue until you find the element of the list is exhausted.

CS 112 George Mason UniversityLecture 4 Slide 15 Chapter 10 Exception Handling in Java try…catch block throws clause Checked vs unchecked exceptions I/O from files and input from keyboard- checked exceptions Split panes Scroll Panes

CS 112 George Mason UniversityLecture 4 Slide 16 I/O I/O Classes FileReader,BufferedReader FileWriter,BufferedWriter InputStreamReader, BufferedReader Methods readLine(), write() StringTokenizer class Declaring an new object for each line of input, String line = in.readLine(); default uses blanks to separate elements of line StringTokenizer tokenizer=new StringTokenizer(line); Use hasMoreTokens() in a while loop to process all words in each line. While (tokenizer.hasMoreTokens()) Inside the loop use String word = line.nextToken()