Code Animation Examples

Slides:



Advertisements
Similar presentations
Continuation of chapter 6…. Nested while loop A while loop used within another while loop is called nested while loop. Q. An illustration to generate.
Advertisements

1 Classes and Objects in Java Parameter Passing, Delegation, Visibility Control, and Object Cleanup.
Picture It Very Basic Game Picture Pepper. Original Game import java.util.Scanner; public class Game { public static void main() { Scanner scan=new Scanner(System.in);
1 Calling within Static method /* We can call a non static method from a static method but by only through an object of that class. */ class Test1{ public.
Övning 4. Repetition göra egna klasser class Rektangel { private double längd; private double bredd; public Rektangel(double l, double b) { this.längd.
1. 2 Introduction to Methods  Type of Variables  Static variables  Static & Instance Methods  The toString  equals methods  Memory Model  Parameter.
Polymorphism. Legal assignments Widening is legal Narrowing is illegal (unless you cast) class Test { public static void main(String args[]) { double.
Review. By the end of today you should be able to- Know how to use args Know how to use the JOptionPane Know how to convert a String to a number.
Writing methods. Calling Methods nameOfMethod(parameters) if method returns something, use that value Math.pow(2, 3) returns 8 System.out.println(Math.pow(2,
Methods & Activation Record. Recap: what’s a method?
16-Aug-15 Java Puzzlers From the book Java Puzzlers by Joshua Bloch and Neal Gafter.
Introduction to Objects A way to create our own types.
College Board A.P. Computer Science A Topics Program Design - Read and understand a problem's description, purpose, and goals; Apply data abstraction.
INPUT/OUTPUT STATEMENT ADDITION SLIDES. Console.ReadLine() – Use to get the input (String) from user Convert string to other data type – int.Parse() 
Control Structures if else do while continue break switch case return for.
Computer Programming 12 Mr. Jean April 24, The plan: Video clip of the day Upcoming Quiz Sample arrays Using arrays More about arrays.
The 1 st and 2 nd tutoring session of CSc2310 Fall, 2012 Haidong Xue.
Classes. Student class We are tasked with creating a class for objects that store data about students. We first want to consider what is needed for the.
Indentation & Readability. What does this program do? public class Hello { public static void main ( String[] args ) { //display initial message System.out.println(
The Math class Java provides certain math functions for us. The Math class contains methods and constants that can be very useful. The Math class is like.
Take out a piece of paper and PEN. The quiz starts ONE minute after the tardy bell rings. You will have 45 – 90 seconds per question. Determine the output.
FOR LOOP WALK THROUGH public class NestedFor { public static void main(String [] args) { for (int i = 1; i
COMP 110 Static variables and methods Luv Kohli October 29, 2008 MWF 2-2:50 pm Sitterson 014.
A: A: double “4” A: “34” 4.
1 Advanced Programming Examples Output. Show the exact output produced by the following code segment. char[,] pic = new char[6,6]; for (int i = 0; i
Methods What is a method? Main Method the main method is where a stand alone Java program normally begins execution common compile error, trying.
Output Programs These slides will present a variety of small programs. Each program has a compound condition which uses the Boolean Logic that was introduced.
JAVA METHODS (FUNCTIONS). Why are they called methods? Java is a strictly object-oriented programming language Methods are functions inside of objects.
CMSC 150 ARRAYS CS 150: Fri 10 Feb Motivation  Consider a list of your contact addresses: String Zero = String.
Variables, Types, Operations on Numbers CSE 1310 – Introduction to Computers and Programming Vassilis Athitsos University of Texas at Arlington 1.
Programming in Java Transitioning from Alice. Becomes not myFirstMethod but …. public static void main (String[] arg) { // code for testing classes goes.
Import javax.swing.JOptionPane; public class Rectangle { public static void main(String[] args) { double width, length, area, perimeter; String lengthStr,
Staples are our staple Building upon our solution.
Sadegh Aliakbary Sharif University of Technology Fall 2010.
Methods Matthew Harrison. Overview ● There are five main aspects of methods... ● 1) Modifiers – public, private ● 2) Method Name ● 3) Parameters ● 4)
Web Design & Development Lecture 9
Chapter 2 Clarifications
Lecture 6 Object Oriented Programming Using Java
Inheritance class TwoDShape { private double width;
AKA the birth, life, and death of variables.
using System; namespace Demo01 { class Program
Formatted Output (printf)
Chapter 2 Elementary Programming
Interface.
Function Call Trace public class Newton {
Something about Java Introduction to Problem Solving and Programming 1.
Interfaces and an Array List
Review Operation Bingo
Functions Used to write code only once Can use parameters.
Computing Adjusted Quiz Total Score
TO COMPLETE THE FOLLOWING:
Stack Memory 2 (also called Call Stack)
Advanced Programming Behnam Hatami Fall 2017.
160 Exam 2 Prep.
Assignment 7 User Defined Classes Part 2
Java Lesson 36 Mr. Kalmes.
Example with Static Variable
Recursive GCD Demo public class Euclid {
Variables, Types, Operations on Numbers
Variables, Types, Operations on Numbers
References and Objects
class PrintOnetoTen { public static void main(String args[]) {
Basics of OOP A class is the blueprint of an object.
Java Programming with Multiple Classes
if-else if (condition) { statements1 } else { statements2
Scope of variables class scopeofvars {
Object-Oriented Programming and class Design
Chapter 9 Objects and Classes Part 01
6.2 for Loops Example: for ( int i = 1; i
MIS 222 – Lecture 12 10/9/2003.
Presentation transcript:

Code Animation Examples Steve Bruemmer

public static void main(String [] args) { int i; i = 3; int m = 4; i = i + m; i memory 3 main 4 m 3 + 7 System.out.println(i); } 4

public static void main(String [] args) { double radius = 4 public static void main(String [] args) { double radius = 4.0; double area = circleArea(radius); System.out.println(area); } public static double circleArea(double r) { return Math.PI * r * r; radius 4.0 area r 4.0 4.0 3.14 * * 50.24 main 4.0 50.24

{ private final String MANU; private final int SIZE; … TV wall; wall = new TV(“Sony”, 52); wall.setChannel(5); public class TV { private final String MANU; private final int SIZE; private int channel; public TV(String m, int s) { MANU = m; SIZE = s; channel = 2; } wall Sony null 52 memory main MANU SIZE channel TV object, address 104B2 104B2 2