Jeopardy $100 VariablesErrorsLoops Classes and Objects Program Structure $200 $300 $400 $500 $400 $300 $200 $100 $500 $400 $300 $200 $100 $500 $400 $300.

Slides:



Advertisements
Similar presentations
Overloading Having more than one method with the same name is known as overloading. Overloading is legal in Java as long as each version takes different.
Advertisements

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.
CPSC 388 – Compiler Design and Construction
This is Java Jeopardy.
Loops –Do while Do While Reading for this Lecture, L&L, 5.7.
A Review. a review of lessons learned so far… ( 2 steps forward - 1 step back) Software Development Cycle: design, implement, test, debug, document Large.
CS 115 OBJECT ORIENTED PROGRAMMING I LECTURE 10 GEORGE KOUTSOGIANNAKIS 1 Copyright: FALL 2014 Illinois Institute of Technology_ George Koutsogiannakis.
10-Jun-15 Just Enough Java. Variables A variable is a “box” that holds data Every variable has a name Examples: name, age, address, isMarried Variables.
1 Control Structures (and user input). 2 Flow of Control The order statements are executed is called flow of control By default, statements in a method.
Loops – While Loop Repetition Statements While Reading for this Lecture, L&L, 5.5.
Primitive Data Types byte, short, int, long float, double char boolean Are all primitive data types. Primitive data types always start with a small letter.
Java An introduction. Example 1 public class Example1 { public static void main (String [] args) { System.out.println (“This is the first example”); int.
Looping Yong Choi School of Business CSU, Bakersfield.
© 2004 Pearson Addison-Wesley. All rights reserved5-1 Iterations/ Loops The while Statement Other Repetition Statements.
CS305j Introduction to Computing While Loops 1 Topic 15 Indefinite Loops - While Loops "If you cannot grok [understand] the overall structure of a program.
Vocabulary Key Terms polymorphism - Selecting a method among many methods that have the same name. subclass - A class that inherits variables and methods.
11 Chapter 4 LOOPS AND FILES. 22 THE INCREMENT AND DECREMENT OPERATORS To increment a variable means to increase its value by one. To decrement a variable.
UNIT 3 TEMPLATE AND EXCEPTION HANDLING. Introduction  Program errors are also referred to as program bugs.  A C program may have one or more of four.
Arrays (Part 1) Computer Science Erwin High School Fall 2014.
Java Programming: From the Ground Up
1 Introduction to Java Brief history of Java Sample Java Program Compiling & Executing Reading: => Section 1.1.
By Nicholas Policelli An Introduction to Java. Basic Program Structure public class ClassName { public static void main(String[] args) { program statements.
Basics of Java IMPORTANT: Read Chap 1-6 of How to think like a… Lecture 3.
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.
1 Debugging. 2 A Lot of Time is Spent Debugging Programs Debugging. Cyclic process of editing, compiling, and fixing errors. n Always a logical explanation.
Chapter 5 Loops.
1 Κατανεμημένες Διαδικτυακές Εφαρμογές Πολυμέσων Γιάννης Πετράκης.
Comments in Java. When you create a New Project in NetBeans, you'll notice that some text is greyed out, with lots of slashes and asterisks:
Using Data Within a Program Chapter 2.  Classes  Methods  Statements  Modifiers  Identifiers.
Methods in Java. Program Modules in Java  Java programs are written by combining new methods and classes with predefined methods in the Java Application.
Chapter 7 LOOPING OPERATIONS: ITERATION. Chapter 7 The Flow of the while Loop.
CSci 111 – computer Science I Fall 2014 Cynthia Zickos WRITING A SIMPLE PROGRAM IN JAVA.
Chapter 5: Control Structures II J ava P rogramming: From Problem Analysis to Program Design, From Problem Analysis to Program Design,
More About Objects and Methods Chapter 5. Outline Programming with Methods Static Methods and Static Variables Designing Methods Overloading Constructors.
AP Computer Science edition Review 1 ArrayListsWhile loopsString MethodsMethodsErrors
Chapter 5 – Part 3 Conditionals and Loops. © 2004 Pearson Addison-Wesley. All rights reserved5-2 Outline The if Statement and Conditions Other Conditional.
Using the while-statement to process data files. General procedure to access a data file General procedure in computer programming to read data from a.
The assignment expressions. The assignment operator in an assignment statement We have seen the assignment statement: Effect: var = expr; Stores the value.
CSC 1051 – Algorithms and Data Structures I Dr. Mary-Angela Papalaskari Department of Computing Sciences Villanova University Course website:
Agenda Perform Quiz #1 (20 minutes) Loops –Introduction / Purpose –while loops Structure / Examples involving a while loop –do/while loops Structure /
Java FilesOops - Mistake Java lingoSyntax
Arrays-. An array is a way to hold more than one value at a time. It's like a list of items.
Chapter 1 Java Programming Review. Introduction Java is platform-independent, meaning that you can write a program once and run it anywhere. Java programs.
Repetition Statements (Loops). 2 Introduction to Loops We all know that much of the work a computer does is repeated many times. When a program repeats.
Array Size Arrays use static allocation of space. That is, when the array is created, we must specify the size of the array, e.g., int[] grades = new int[100];
College Board Topics – A.P. Computer Science A Program Design - Read and understand a problem's description, purpose, and goals; Apply data abstraction.
AP Java Java’s version of Repeat until.
1 Flow of Control Chapter 5. 2 Objectives You will be able to: Use the Java "if" statement to control flow of control within your program.  Use the Java.
FOR LOOPS "LOOP FOR A SET NUMBER OF TIMES.". FOR ( START_VALUE; END_VALUE; INCREMENT_NUMBER ) { //YOUR_CODE_HERE } So after the word "for" (in lowercase)
1 BUILDING JAVA PROGRAMS CHAPTER 5 PROGRAM LOGIC AND INDEFINITE LOOPS.
Programming for Interactivity Professor Bill Tomlinson Tuesday & Wednesday 6:00-7:50pm Fall 2005.
Chapter 5 – Part 3 Conditionals and Loops. © 2004 Pearson Addison-Wesley. All rights reserved2/19 Outline The if Statement and Conditions Other Conditional.
Learning Javascript From Mr Saem
Introduction to Programming G50PRO University of Nottingham Unit 6 : Control Flow Statements 2 Paul Tennent
Variable scope. Variable Scope Variables do not live forever. Failing to take that into account leads to problems. Let's look at an example. Let's write.
Slides by Evan Gallagher
4. Java language basics: Function
CSC111 Quick Revision.
OBJECT ORIENTED PROGRAMMING I LECTURE 10 GEORGE KOUTSOGIANNAKIS
Chapter 7 Part 1 Edited by JJ Shepherd
Chapter 6 More Conditionals and Loops
Loop Structures.
While Statement.
Arrays, For loop While loop Do while loop
Programming Vocabulary.
An Introduction to Java – Part I, language basics
Introduction to Classes and Methods
Introduction to Java Brief history of Java Sample Java Program
LOOPS The loop is the control structure we use to specify that a statement or group of statements is to be repeatedly executed. Java provides three kinds.
Control Statements:.
Presentation transcript:

Jeopardy $100 VariablesErrorsLoops Classes and Objects Program Structure $200 $300 $400 $500 $400 $300 $200 $100 $500 $400 $300 $200 $100 $500 $400 $300 $200 $100 $500 $400 $300 $200 $100 Final Jeopardy Final Jeopardy

Variables - $100 What are variables used for (in Java)? What are variables used for (in Java)? To store information To store information

Variables - $200 Before a variable can be used, it has to be… Before a variable can be used, it has to be… Declared OR Initialized Declared OR Initialized

Variables - $300 Name four data types that variables can have. Name four data types that variables can have. ANY 4 OF THE FOLLOWING: ANY 4 OF THE FOLLOWING: –int-String-double-boolean –char-float

Variables - $400 What will be printed by the following code? int n1 = 25; What will be printed by the following code? int n1 = 25; int n2 = 5; int n2 = 5; String tacos = “burritos”; System.out.println(n1 + n2 + “ fish ” + tacos); String tacos = “burritos”; System.out.println(n1 + n2 + “ fish ” + tacos); 30 fish burritos 30 fish burritos

Variables - $500 Why does the compiler need to know the data type of a variable? Why does the compiler need to know the data type of a variable? To know how much memory space to save for the variable To know how much memory space to save for the variable

Errors - $100 What kind of error can be caused by a misspelled word, and will cause compiler errors? What kind of error can be caused by a misspelled word, and will cause compiler errors? Syntax error Syntax error

Errors - $200 Trying to take the square root of a negative number will cause what kind of error? Trying to take the square root of a negative number will cause what kind of error? Runtime error Runtime error

Errors - $300 What is the error in the code below? system.out.print(“Bazinga.”); What is the error in the code below? system.out.print(“Bazinga.”); “system” should be capitalized “system” should be capitalized

Errors - $400 When you see a “Reached end of file while parsing” error message, what does it usually mean you need to add? When you see a “Reached end of file while parsing” error message, what does it usually mean you need to add? A closing curly brace A closing curly brace

Errors - $500 Why are logical errors harder to find than syntax or runtime errors? Why are logical errors harder to find than syntax or runtime errors? The program will still compile and run—no error messages The program will still compile and run—no error messages (but it won’t do what you want it to do) (but it won’t do what you want it to do)

Loops - $100 Name two types of Java loops. Name two types of Java loops. Any two: Any two: –While loop –Do-while loop –For loop

Loops - $200 What is the difference between a while loop and a do-while loop? What is the difference between a while loop and a do-while loop? A do-while loop will always run at least once. A do-while loop will always run at least once.

Loops - $300 Why would you use a for loop instead of a while loop? Why would you use a for loop instead of a while loop? You want your loop to run a specific number of times You want your loop to run a specific number of times

Loops - $400 Why will the following code run forever (an infinite loop)? Why will the following code run forever (an infinite loop)? int a = 20; int a = 20; while (a != 0) { while (a != 0) { System.out.println(“La la la”); System.out.println(“La la la”); } The loop only ends when a is 0, but a never changes. The loop only ends when a is 0, but a never changes.

Loops - $500 What does the following code do? What does the following code do? for (int a = 10; a >= 0; a--) { for (int a = 10; a >= 0; a--) { System.out.println(a); } System.out.println(a); } Counts down from 10 to 0 Counts down from 10 to 0

Classes and Objects - $100 What is the difference between a class and an object? What is the difference between a class and an object? Class: general category Object: specific item Class: general category Object: specific item

Classes and Objects - $200 What is the difference between a field and a method? What is the difference between a field and a method? Fields: describe a class (nouns/adjectives) Methods: things a class does (verbs) Fields: describe a class (nouns/adjectives) Methods: things a class does (verbs)

Classes and Objects - $300 What is the object in the code below? Superhero CaptainObvious = new Superhero(); What is the object in the code below? Superhero CaptainObvious = new Superhero(); CaptainObvious CaptainObvious

Classes and Objects - $400 In the method below, the part in the parentheses is used to tell the method what kind of data to expect. public int AddThree(int n1, int n2, int n3) In the method below, the part in the parentheses is used to tell the method what kind of data to expect. public int AddThree(int n1, int n2, int n3) What is this part called? argument list argument list

Classes and Objects - $500 Every class has a method that sets up new objects and may assign values to variables. What is this method called? Every class has a method that sets up new objects and may assign values to variables. What is this method called? Constructor Constructor

Program Structure - $100 Name 2 things every program has to have Name 2 things every program has to have Class name, main method, curly braces (other answers possible) Class name, main method, curly braces (other answers possible)

Program Structure - $200 Where in a method are variables usually declared? Where in a method are variables usually declared? At the top At the top

Program Structure - $300 What are the statements called at the very top of a program that tell Java which libraries to use? What are the statements called at the very top of a program that tell Java which libraries to use? Import statements Import statements

Program Structure - $400 What are if statements used for in a Java program? What are if statements used for in a Java program? To make decisions To make decisions

Program Structure - $500 Where is the missing curly brace? public class Thing { public static void main(Sting [] args) { int a; for (a = 0; a < 5; a++) System.out.println(a); Where is the missing curly brace? public class Thing { public static void main(Sting [] args) { int a; for (a = 0; a < 5; a++) System.out.println(a); } } } } } }

Final Jeopardy Write 2 lines of code: Write 2 lines of code: FIRST LINE: Declares a Scanner object called scan FIRST LINE: Declares a Scanner object called scan SECOND LINE: Uses scan to read in an integer from the keyboard SECOND LINE: Uses scan to read in an integer from the keyboard Scanner scan = new Scanner(System.in); Scanner scan = new Scanner(System.in); scan.nextInt(); scan.nextInt();