100e Hosted by vhs

Download Report

Transcript 100e Hosted by vhs

100e
Jeopardy
Hosted by vhs
© Don Link, Indian Creek School, 2004
Data
Potpourri
Structures
Code
Recursion
Objects
$200
$200
$200
$200
$200
$400
$400
$400
$400
$400
$600
$600
$600
$600
$600
$800
$800
$800
$800
$800
$1000
$1000
$1000
$1000
$1000
What are the values of:
(((14 >= 0) || (4 != 3)) && (22 % 7 == 1)
and
7 * 8 % 10 / (-2 * -2.0)
Code for $200
True and 1.5
What is wrong with the
following code that converts
Celcius to Farenheit?
Code for $400
Casting error.
Always == 0
These are the values of m and n
after the following code executes.
Code for $600
m == 987654321
n == 0
This is the output of the following code.
Code for $800
The program doesn’t print
anything. (Why?)
Write the following function:
Start with 2 int arrays (a and b).
Return the array which has the
largest sum. In the event of a
tie, return a.
Code for $1000
Answer
This is the definition of
a recursive function.
Recursion for $200
Function that calls itself
All recursive functions
have these 2 parts.
Recursion for $400
Base case and recursion w/
changing measure
This is the fatal flaw in the call
badRecurse(5);
Recursion for $600
Doesn’t converge on base
case => infinite recursion
This is the output of
mystery(2,3)
Recursion for $800
Returns 5. More generally,
the sum of a and b.
This is the output of the call
printMe(“”, “two”);
Recursion for $1000
Anagrams
In the class Soup, identify the:
a) instance variables
b) constructor
c) methods.
Objects for $200
myPeas, myCarrots, myBrand, myCalories
Soup(int peas, int carrots, String brand)
getPeas(), getCarrots(), getCalories(), toString(),
calories()
All classes in Java inherit
from this superclass
Objects for $400
Object
When working with an object, the
keyword “this” performs
this function.
Objects for $600
Way to reference the object
whose name was used to
invoke the method.
These are the two other functions
Soup needs to override be
considered an example of
“good” subclass.
Objects for $800
hashCode() & equals()
Implement a robust equals()
for Soup
Objects for $1000
Answer
An alternate way of referring
to this data structure is a
“LIFO” array.
Data Structures for $200
Stack
This is the output of the code below:
Data Structures for $400
Hello
I am
This is the problem with the code below:
Data Structures for $600
Adding objects of wrong
type to ArrayList
??? Should be replaced with
this to make this 2D
array function properly.
Data Structures for $800
data[row].length
Given an array int[] a, calculate
the sum of the odd numbers in
the array.
Data Structures for $1000
Answer
These are 4 of the 8 true
primitive data types in Java
Potpourri for $200
Short, long, double, float,
int, byte, char, boolean
This is a java literal
that means “no object”
Potpourri for $400
null
Arithmetic operators (like +, -, *, /)
have _____ precedence than logical
operators (like ||, &&, !) so
arithmetic is done _____.
Potpourri for $600
Higher, first
Rewrite the following code
using a for loop.
Potpourri for $800
for (int count =7; count >= 4; count--)
{
System.out.println(count + “ “);
}
This is the output of the
code snippet below:
Potpourri for $1000
1,2,3,4,5,6,7,8,9,10