Back public class HelloWorld { public static void main ( String arg[] ) { Front Basic Setup. Java Quick Sheet. ~ 35 Flashcards. 1 AP CS - Rodriguez

Size: px
Start display at page:

Download "Back public class HelloWorld { public static void main ( String arg[] ) { Front Basic Setup. Java Quick Sheet. ~ 35 Flashcards. 1 AP CS - Rodriguez"

Transcription

1 1 AP CS - Rodriguez Front Basic Setup Java Quick Sheet ~ 35 Flashcards Back public class HelloWorld public static void main ( String arg[] ) // end method main // end class HelloWorld Print Line System.out.println( "Hello everyone out there! "); System.out.print( Hello ); Concatenation System.out.println( "Hello, " + name +! How are you? ); Print Characters Increments/ Decrements Integers \t insert tab \n insert new line \" insert double quote \' insert single quote \\ insert backslash i--; i++; --i; ++i; i+=2; or i = i + 2 i*=3; or i = i * 3 int a = 21; Double Boolean Strings Arrays double b = 2.15 boolean ison = true; String name = new String( "Ms. R" ); String name = ""; int[] ListOfItems = new int[7]; String[] ListOfItems = "zero", "one", "two" boolean[] TFList = true, false, true, true; Array Length MySong[] playlist = new MySong[4]; int listlength = myarray.length; //Number of elements in array Boolean Operators < Less than > Greater than <= Less than or equal to >= Greater than or equal to == Equal to!= Not Equal to Comparison && "and" Both must be true "or" One must me true

2 If-Else Statement Comparing Strings Searching and Comparing Array of Strings Modulus 2 AP CS - Rodriguez if( a < b ) System.out.println( "a is " + a + " and is less than " + b ); else System.out.println( "a is greater or equal to b ); String name = new String( "Ms. R" ); if( name.equals( "Ms. R" ) ) System.out.println( "Username Correct" ); // end if for( int i =0; i<food.length; i++) if( food[index].equals( "Apple" ) ) System.out.println( "We found an apple!" ); // end if % Remainder Ex. 15 % 2 = 1 Ex. 3 % 10 = 3 Ex. 15 % 5 = 0 Ex. 20 % 3 = 2 Even numbers if( num % 2 = 0 ) Odd numbers if( num % 2!= 0 ) For Loop Initial condition increment/decrement i--, --i for(int i = 0; i < max; i++) <Code/statement> Ex. for(int i = 0; i < array.length; i++) System.out.print( array[i] ); While Loop (Array) int i = 0; while( i < songs.length ) System.out.print( songs[index] ); index++; //end while If Else if( counter%2 == 0 ) // System.out.println( counter + " is an even number" ); // end if else System.out.println( counter + " is an odd number" ); // end else

3 3 AP CS - Rodriguez Math Random //Math.random() returns a number from 0 to // Random number between two values (Min and Max) 1-10 int min = 1; int max = 11; //add one more to the max int randomnum = min + (int) ( Math.random() *( max - min ) ); Casting double num = 2.7; int newnum = (int) num; // this would make newnum 2 //it does NOT round up, it casts it off Array lengths Calling items in array Compound Assignment operators int index = 0; while( index < songs.length ) System.out.print( songs[index] ); index++; //end while x += 3; same as x = x + 3; x -= 3; same as x = x - 3; x *= y; same as x = x * y; x /= y; same as x = x / y; x %= y; same as x = x % y; x *= y + 1; same as x = x * (y + 1); String String name = new String( Rodriguez ); //index starts at 0 System.out.print( name.length() ) //prints 9 System.out.print( name.substring(3) ) //prints riguez System.out.print( name.substring(3, 6) )//prints rig (do NOT include 6 th index) System.out.print( name.substring( name.length() 1 ) ) // prints z, the last index System.out.print( name.substring(4, 5) )//prints i (do NOT include 5 th index) For each loop for( Type nickname : Array/List) <Code/statement> Ex. for( doubles num : MyFavNums) <Code/statement>

4 4 AP CS - Rodriguez 2D Array //(2D array with 5 rows and 4 cols) int[][] MyArray = new int[5][4] // The 2D Array is empty //myarray[row][col] //Fill up Array one by one myarray[0][0] = 1; myarray[0][1] = 12; myarray[1][0] = 15; myarray[4][3] = 13; //Access a value in the array System.out.print( myarray[3][4] ); // prints the item in row 3 col 4 int totalrows = myarray.length; // Number of rows int totalcols = myarray[0].length; // Number of columns Filling up a 2D array with Nested for loop Nested Loop (2D Array) Right to left Nested for each loop (2D Arrays) for( int row = 0; row < myarray.length; row++ ) for ( int col = 0; col <myarray[0].length; col++) myarray[row][col] = 2*(row)*(col); //you can put anything here for( int row = 0; row < myarray.length; row++ ) for ( int col = 0; col <myarray[0].length; col++) <Code/statement> System.out.printnl( ); //adds a new line for every row for (int[] row: MyArray) for (int col: row) System.out.print( row[col] );

5 5 AP CS - Rodriguez ArrayList **import java.util.arraylist; ArrayList<String> nums = new ArrayList<String>(); nums.add( zero ) nums.add( new String( "two" ) ); nums.get(0) //Gets element in index 0) nums.remove(0) //Removes elements at index 0) nums.set(1, one ) //Set index 2 to a new String) nums.size() //Gets size of ArrayList or the number of elements) nums.get(1).length() //Get the length of the item in index 1 one, // the length is 3 //Make an ArrayLust of objects ArrayList<MyDevice> inventory = new ArrayList<MyDevice>(); inventory.add( new MyPhone( 64, Blue ) ); Memory and color ArrayList of Objects Ex. ArrayList<MyDevice> inventory = new ArrayList<>(); inventory.add(new MyPhone( 64, Blue ) ); //Memory and color For loop ArrayList Find min or max in array of integers ArrayList<String> nums = new ArrayList<String>(); for(int i = 0; i < nums.size(); i++) System.out.print( array.get(i) ); //prints element in index i int max = 0; for(int i=0; i < myarray.length; i++) if( i == 0) max = myarray[0]; if( myarray[i] > max) max = myarray[i];

6 6 AP CS - Rodriguez The Big 3 1. instance variables 2. constructors (zero-arg and multi-arg) 3. tostring() method The Dynamic Duo 4. getter methods 5. setter methods The The Brain (public or private) 6. processor method(s) (algorithmic processing) Instance Variables Constructors Zeroargument Multiargument tostring() Getter Setter Methods are accessed by tostring() or item.getprice() or getprice() (if used within the class) public class Shoes // Instance variables private String brand; private int size; //Constructor (Zero-Argument) public Shoes() brand = new String("none"); size = 5; //Constructor (Multi-Argument) public Shoes( String brand, int size) this.brand = brand; this.size = size; //tostring() public String tostring() String output = new String(); output = "Brand: " + brand + "Size: " + size; return output; //Getter public int getsize() return size; //Getter public String getbrand() return brand; //Setter public void setsize( int size) this.size = size;

7 7 AP CS - Rodriguez Brain Example Brain Example Signature //Other Methods/ Brains public String wideaval() if(size > 5 && brand.equals("jordans") return "Does not come in wide sizes"; else return "Avaiable in wide"; //Another Brain example public double gettotal(int price) double total=price + (.08) *(price); //taxes if(size > 6) total += 9.99; //for shipping return total; Inheritance extends This extends a class to inherent instance variables but NOT methods Must us super(), super(args), super.tostring(), super.gettotal() to use super s methods Interface Abstract implements abstract This allows for multiple classes to have a similar method, connecttobluetooth() but each class can have a different code to implement it. Abstract Class: This makes a class abstract ( existing in thought or as an idea but not having a physical or concrete existence ). You cannot make an object in the driver of this class

8 8 AP CS - Rodriguez Unified Modeling Language (UML) Class Diagram

CS1083 Week 2: Arrays, ArrayList

CS1083 Week 2: Arrays, ArrayList CS1083 Week 2: Arrays, ArrayList mostly review David Bremner 2018-01-08 Arrays (1D) Declaring and using 2D Arrays 2D Array Example ArrayList and Generics Multiple references to an array d o u b l e prices

More information

CS111: PROGRAMMING LANGUAGE II

CS111: PROGRAMMING LANGUAGE II CS111: PROGRAMMING LANGUAGE II Computer Science Department Lecture 1(c): Java Basics (II) Lecture Contents Java basics (part II) Conditions Loops Methods Conditions & Branching Conditional Statements A

More information

AP CS Unit 7: Interfaces. Programs

AP CS Unit 7: Interfaces. Programs AP CS Unit 7: Interfaces. Programs You cannot use the less than () operators with objects; it won t compile because it doesn t always make sense to say that one object is less than

More information

Programming Assignment Unit 7

Programming Assignment Unit 7 Name: Programming Assignment Unit 7 Where to Save These Assignments: These programs should be saved on your flashdrive under Unit 7 à Assignments Each program should be saved in a separate BlueJ project.

More information

Chapter 4: Control structures. Repetition

Chapter 4: Control structures. Repetition Chapter 4: Control structures Repetition Loop Statements After reading and studying this Section, student should be able to Implement repetition control in a program using while statements. Implement repetition

More information

Language Features. 1. The primitive types int, double, and boolean are part of the AP

Language Features. 1. The primitive types int, double, and boolean are part of the AP Language Features 1. The primitive types int, double, and boolean are part of the AP short, long, byte, char, and float are not in the subset. In particular, students need not be aware that strings are

More information

Chapter 4: Control structures

Chapter 4: Control structures Chapter 4: Control structures Repetition Loop Statements After reading and studying this Section, student should be able to Implement repetition control in a program using while statements. Implement repetition

More information

Review. Primitive Data Types & Variables. String Mathematical operators: + - * / % Comparison: < > <= >= == int, long float, double boolean char

Review. Primitive Data Types & Variables. String Mathematical operators: + - * / % Comparison: < > <= >= == int, long float, double boolean char Review Primitive Data Types & Variables int, long float, double boolean char String Mathematical operators: + - * / % Comparison: < > = == 1 1.3 Conditionals and Loops Introduction to Programming in

More information

CSE 142 SPRING 2008 FINAL EXAM

CSE 142 SPRING 2008 FINAL EXAM CSE 142 SPRING 2008 FINAL EXAM 1. Expressions (10 points) For each expression in the left-hand column, indicate its value in the right-hand column. Be sure to list a constant of appropriate type (e.g.,

More information

Table of Contents Date(s) Title/Topic Page #s. Chapter 4: Writing Classes 4.1 Objects Revisited

Table of Contents Date(s) Title/Topic Page #s. Chapter 4: Writing Classes 4.1 Objects Revisited Table of Contents Date(s) Title/Topic Page #s 11/6 Chapter 3 Reflection/Corrections 56 Chapter 4: Writing Classes 4.1 Objects Revisited 57 58-59 look over your Ch 3 Tests and write down comments/ reflections/corrections

More information

boolean, char, class, const, double, else, final, float, for, if, import, int, long, new, public, return, static, throws, void, while

boolean, char, class, const, double, else, final, float, for, if, import, int, long, new, public, return, static, throws, void, while CSCI 150 Fall 2007 Java Syntax The following notes are meant to be a quick cheat sheet for Java. It is not meant to be a means on its own to learn Java or this course. For that you should look at your

More information

Object-Oriented Programming

Object-Oriented Programming Object-Oriented Programming Java Syntax Program Structure Variables and basic data types. Industry standard naming conventions. Java syntax and coding conventions If Then Else Case statements Looping (for,

More information

1) Consider the following code segment, applied to list, an ArrayList of Integer values.

1) Consider the following code segment, applied to list, an ArrayList of Integer values. Advanced Computer Science Unit 7 Review Part I: Multiple Choice (12 questions / 4 points each) 1) What is the difference between a regular instance field and a static instance field? 2) What is the difference

More information

Warm up question. 2)Which of the following operators are defined on a half integer? Which of the following would it be useful to write as behaviors?

Warm up question. 2)Which of the following operators are defined on a half integer? Which of the following would it be useful to write as behaviors? Warm up question Suppose we have defined a class called half-integer The point of the class is to be able to store regular integers and also half integers (i.e. 3.5) 1)What would be a good way to represent

More information

AP Computer Science Homework Set 1 Fundamentals

AP Computer Science Homework Set 1 Fundamentals AP Computer Science Homework Set 1 Fundamentals P1A. Using MyFirstApp.java as a model, write a similar program, MySecondApp.java, that prints your favorites. Your program should print your food, your favorite

More information

c) And last but not least, there are javadoc comments. See Weiss.

c) And last but not least, there are javadoc comments. See Weiss. CSCI 151 Spring 2010 Java Bootcamp The following notes are meant to be a quick refresher on Java. It is not meant to be a means on its own to learn Java. For that you would need a lot more detail (for

More information

AP Computer Science A

AP Computer Science A AP Computer Science A 1st Quarter Notes Table of Contents - section links Click on the date or topic below to jump to that section Date : 9/8/2017 Aim : Java Basics Objects and Classes Data types: Primitive

More information

BIT Java Programming. Sem 1 Session 2011/12. Chapter 2 JAVA. basic

BIT Java Programming. Sem 1 Session 2011/12. Chapter 2 JAVA. basic BIT 3383 Java Programming Sem 1 Session 2011/12 Chapter 2 JAVA basic Objective: After this lesson, you should be able to: declare, initialize and use variables according to Java programming language guidelines

More information

Simple Java Reference

Simple Java Reference Simple Java Reference This document provides a reference to all the Java syntax used in the Computational Methods course. 1 Compiling and running... 2 2 The main() method... 3 3 Primitive variable types...

More information

CS111: PROGRAMMING LANGUAGE II

CS111: PROGRAMMING LANGUAGE II 1 CS111: PROGRAMMING LANGUAGE II Computer Science Department Lecture 1: Introduction Lecture Contents 2 Course info Why programming?? Why Java?? Write once, run anywhere!! Java basics Input/output Variables

More information

CS 106 Introduction to Computer Science I

CS 106 Introduction to Computer Science I CS 106 Introduction to Computer Science I 05 / 31 / 2017 Instructor: Michael Eckmann Today s Topics Questions / Comments? recap and some more details about variables, and if / else statements do lab work

More information

AP CS Unit 7: Interfaces Exercises 1. Select the TRUE statement(s).

AP CS Unit 7: Interfaces Exercises 1. Select the TRUE statement(s). AP CS Unit 7: Interfaces Exercises 1. Select the TRUE statement(s). a) This code will not compile because a method cannot specify an interface as a parameter. public class Testing { public static void

More information

Program Fundamentals

Program Fundamentals Program Fundamentals /* HelloWorld.java * The classic Hello, world! program */ class HelloWorld { public static void main (String[ ] args) { System.out.println( Hello, world! ); } } /* HelloWorld.java

More information

Week 6: Review. Java is Case Sensitive

Week 6: Review. Java is Case Sensitive Week 6: Review Java Language Elements: special characters, reserved keywords, variables, operators & expressions, syntax, objects, scoping, Robot world 7 will be used on the midterm. Java is Case Sensitive

More information

CSCI 161 Introduction to Computer Science

CSCI 161 Introduction to Computer Science CSCI 161 Introduction to Computer Science Department of Mathematics and Computer Science Lecture 2b A First Look at Class Design Last Time... We saw: How fields (instance variables) are declared How methods

More information

CS 112 Introduction to Computing II. Wayne Snyder Computer Science Department Boston University

CS 112 Introduction to Computing II. Wayne Snyder Computer Science Department Boston University 9/5/6 CS Introduction to Computing II Wayne Snyder Department Boston University Today: Arrays (D and D) Methods Program structure Fields vs local variables Next time: Program structure continued: Classes

More information

AP Computer Science Unit 1. Programs

AP Computer Science Unit 1. Programs AP Computer Science Unit 1. Programs Open DrJava. Under the File menu click on New Java Class and the window to the right should appear. Fill in the information as shown and click OK. This code is generated

More information

AP COMPUTER SCIENCE A DIAGNOSTIC EXAM. Multiple Choice Section Time - 1 hour and 15 minutes Number of questions - 40 Percent of total grade - 50

AP COMPUTER SCIENCE A DIAGNOSTIC EXAM. Multiple Choice Section Time - 1 hour and 15 minutes Number of questions - 40 Percent of total grade - 50 AP COMPUTER SCIENCE A DIAGNOSTIC EXAM Multiple Choice Section Time - 1 hour and 15 minutes Number of questions - 40 Percent of total grade - 50 Directions: Determine the answer to each of the following

More information

Sequence structure. The computer executes java statements one after the other in the order in which they are written. Total = total +grade;

Sequence structure. The computer executes java statements one after the other in the order in which they are written. Total = total +grade; Control Statements Control Statements All programs could be written in terms of only one of three control structures: Sequence Structure Selection Structure Repetition Structure Sequence structure The

More information

Final Exam. COMP Summer I June 26, points

Final Exam. COMP Summer I June 26, points Final Exam COMP 14-090 Summer I 2000 June 26, 2000 200 points 1. Closed book and closed notes. No outside material allowed. 2. Write all answers on the test itself. Do not write any answers in a blue book

More information

Inheritance (Part 2) Notes Chapter 6

Inheritance (Part 2) Notes Chapter 6 Inheritance (Part 2) Notes Chapter 6 1 Object Dog extends Object Dog PureBreed extends Dog PureBreed Mix BloodHound Komondor... Komondor extends PureBreed 2 Implementing Inheritance suppose you want to

More information

Subclass Gist Example: Chess Super Keyword Shadowing Overriding Why? L10 - Polymorphism and Abstract Classes The Four Principles of Object Oriented

Subclass Gist Example: Chess Super Keyword Shadowing Overriding Why? L10 - Polymorphism and Abstract Classes The Four Principles of Object Oriented Table of Contents L01 - Introduction L02 - Strings Some Examples Reserved Characters Operations Immutability Equality Wrappers and Primitives Boxing/Unboxing Boxing Unboxing Formatting L03 - Input and

More information

APCS Semester #1 Final Exam Practice Problems

APCS Semester #1 Final Exam Practice Problems Name: Date: Per: AP Computer Science, Mr. Ferraro APCS Semester #1 Final Exam Practice Problems The problems here are to get you thinking about topics we ve visited thus far in preparation for the semester

More information

AP CS Unit 3: Control Structures Notes

AP CS Unit 3: Control Structures Notes AP CS Unit 3: Control Structures Notes The if and if-else Statements. These statements are called control statements because they control whether a particular block of code is executed or not. Some texts

More information

CmSc 150 Fundamentals of Computing I. Lesson 28: Introduction to Classes and Objects in Java. 1. Classes and Objects

CmSc 150 Fundamentals of Computing I. Lesson 28: Introduction to Classes and Objects in Java. 1. Classes and Objects CmSc 150 Fundamentals of Computing I Lesson 28: Introduction to Classes and Objects in Java 1. Classes and Objects True object-oriented programming is based on defining classes that represent objects with

More information

1 Epic Test Review 2 Epic Test Review 3 Epic Test Review 4. Epic Test Review 5 Epic Test Review 6 Epic Test Review 7 Epic Test Review 8

1 Epic Test Review 2 Epic Test Review 3 Epic Test Review 4. Epic Test Review 5 Epic Test Review 6 Epic Test Review 7 Epic Test Review 8 Epic Test Review 1 Epic Test Review 2 Epic Test Review 3 Epic Test Review 4 Write a line of code that outputs the phase Hello World to the console without creating a new line character. System.out.print(

More information

Practice Midterm 1. Problem Points Score TOTAL 50

Practice Midterm 1. Problem Points Score TOTAL 50 CS 120 Software Design I Spring 2019 Practice Midterm 1 University of Wisconsin - La Crosse February 25 NAME: Do not turn the page until instructed to do so. This booklet contains 10 pages including the

More information

Introduction to the Java Basics: Control Flow Statements

Introduction to the Java Basics: Control Flow Statements Lesson 3: Introduction to the Java Basics: Control Flow Statements Repetition Structures THEORY Variable Assignment You can only assign a value to a variable that is consistent with the variable s declared

More information

Visit us at

Visit us at Visit us at www.apluscompsci.com Full Curriculum Solutions M/C Review Question Banks Live Programming Problems Tons of great content! www.facebook.com/apluscomputerscience -Read all 4 questions before

More information

Condi(onals and Loops

Condi(onals and Loops Condi(onals and Loops 1 Review Primi(ve Data Types & Variables int, long float, double boolean char String Mathema(cal operators: + - * / % Comparison: < > = == 2 A Founda(on for Programming any program

More information

Variables and data types

Variables and data types Survivor: CSCI 135 Variables Variables and data types Stores information your program needs Each has a unique name Each has a specific type Java built-in type what it stores example values operations String

More information

AP Computer Science Homework Set 2 Class Design

AP Computer Science Homework Set 2 Class Design AP Computer Science Homework Set 2 Class Design P2A. Write a class Song that stores information about a song. Class Song should include: a) At least three instance variables that represent characteristics

More information

Constructor. Liang, Introduction to Java Programming, Tenth Edition, (c) 2013 Pearson Education, Inc. All rights reserved.

Constructor. Liang, Introduction to Java Programming, Tenth Edition, (c) 2013 Pearson Education, Inc. All rights reserved. Constructor Suppose you will define classes to model circles, rectangles, and triangles. These classes have many common features. What is the best way to design these classes so to avoid redundancy? The

More information

HUDSONVILLE HIGH SCHOOL COURSE FRAMEWORK

HUDSONVILLE HIGH SCHOOL COURSE FRAMEWORK HUDSONVILLE HIGH SCHOOL COURSE FRAMEWORK COURSE / SUBJECT Introduction to Programming KEY COURSE OBJECTIVES/ENDURING UNDERSTANDINGS OVERARCHING/ESSENTIAL SKILLS OR QUESTIONS Introduction to Java Java Essentials

More information

Introduction to Programming Using Java (98-388)

Introduction to Programming Using Java (98-388) Introduction to Programming Using Java (98-388) Understand Java fundamentals Describe the use of main in a Java application Signature of main, why it is static; how to consume an instance of your own class;

More information

The Java language has a wide variety of modifiers, including the following:

The Java language has a wide variety of modifiers, including the following: PART 5 5. Modifier Types The Java language has a wide variety of modifiers, including the following: Java Access Modifiers Non Access Modifiers 5.1 Access Control Modifiers Java provides a number of access

More information

AP Computer Science Homework Set 1 Fundamentals

AP Computer Science Homework Set 1 Fundamentals AP Computer Science Homework Set 1 Fundamentals P1A. Using MyFirstApp.java as a model, write a similar program, MySecondApp.java, that prints your favorites. Your program should do the following: a. create

More information

CS 307 Midterm 1[corrected] Spring 2008

CS 307 Midterm 1[corrected] Spring 2008 Points off 1 2 3 4 5 Total off Net Score CS 307 Midterm 1[corrected] Spring 2008 Your Name Your UTEID Circle yours TA s name: Ruchica Mario Vishvas Instructions: 1. Please turn off or silence your cell

More information

Lecture 5: Methods CS2301

Lecture 5: Methods CS2301 Lecture 5: Methods NADA ALZAHRANI CS2301 1 Opening Problem Find the sum of integers from 1 to 10, from 20 to 30, and from 35 to 45, respectively. 2 Solution public static int sum(int i1, int i2) { int

More information

APCS Assessment Sheet Consider the following program segment int count = 1;

APCS Assessment Sheet Consider the following program segment int count = 1; APCS Assessment Sheet 1 1. Consider the following program segment int count = 1; for(int p = 0; p < 5; p++) if(p % 2 = = 0) count++; else count += 2; System.out.println(count); What value is displayed?

More information

Homework Set 1- Fundamentals

Homework Set 1- Fundamentals 1 Homework Set 1- Fundamentals Topics if statements with ints if-else statements with Strings if statements with multiple boolean statements for loops and arrays while loops String ".equals()" method "=="

More information

Anatomy of a Class Encapsulation Anatomy of a Method

Anatomy of a Class Encapsulation Anatomy of a Method Writing Classes Writing Classes We've been using predefined classes. Now we will learn to write our own classes to define objects Chapter 4 focuses on: class definitions instance data encapsulation and

More information

Index COPYRIGHTED MATERIAL

Index COPYRIGHTED MATERIAL Index COPYRIGHTED MATERIAL Note to the Reader: Throughout this index boldfaced page numbers indicate primary discussions of a topic. Italicized page numbers indicate illustrations. A abstract classes

More information

CompuScholar, Inc. 9th - 12th grades

CompuScholar, Inc. 9th - 12th grades CompuScholar, Inc. Alignment to the College Board AP Computer Science A Standards 9th - 12th grades AP Course Details: Course Title: Grade Level: Standards Link: AP Computer Science A 9th - 12th grades

More information

Practice Midterm 1 Answer Key

Practice Midterm 1 Answer Key CS 120 Software Design I Fall 2018 Practice Midterm 1 Answer Key University of Wisconsin - La Crosse Due Date: October 5 NAME: Do not turn the page until instructed to do so. This booklet contains 10 pages

More information

CS Introduction to Programming Midterm Exam #1 - Prof. Reed Fall 2009

CS Introduction to Programming Midterm Exam #1 - Prof. Reed Fall 2009 CS 102 - Introduction to Programming Midterm Exam #1 - Prof. Reed Fall 2009 What is your name?: There are two sections: I. True/False..................... 60 points; ( 30 questions, 2 points each) II.

More information

cis20.1 design and implementation of software applications I fall 2007 lecture # I.2 topics: introduction to java, part 1

cis20.1 design and implementation of software applications I fall 2007 lecture # I.2 topics: introduction to java, part 1 topics: introduction to java, part 1 cis20.1 design and implementation of software applications I fall 2007 lecture # I.2 cis20.1-fall2007-sklar-leci.2 1 Java. Java is an object-oriented language: it is

More information

Chapter 1 Introduction to java

Chapter 1 Introduction to java Chapter 1 Introduction to java History of java Java was created by by Sun Microsystems team led by James Gosling (1991) It was mainly used for home appliance, it later became a general purpose programming

More information

AP Computer Science Chapter 10 Implementing and Using Classes Study Guide

AP Computer Science Chapter 10 Implementing and Using Classes Study Guide AP Computer Science Chapter 10 Implementing and Using Classes Study Guide 1. A class that uses a given class X is called a client of X. 2. Private features of a class can be directly accessed only within

More information

More on variables and methods

More on variables and methods More on variables and methods Robots Learning to Program with Java Byron Weber Becker chapter 7 Announcements (Oct 12) Reading for Monday Ch 7.4-7.5 Program#5 out Character Data String is a java class

More information

AP CS Unit 6: Inheritance Notes

AP CS Unit 6: Inheritance Notes AP CS Unit 6: Inheritance Notes Inheritance is an important feature of object-oriented languages. It allows the designer to create a new class based on another class. The new class inherits everything

More information

public static boolean isoutside(int min, int max, int value)

public static boolean isoutside(int min, int max, int value) See the 2 APIs attached at the end of this worksheet. 1. Methods: Javadoc Complete the Javadoc comments for the following two methods from the API: (a) / @param @param @param @return @pre. / public static

More information

Expressions and Data Types CSC 121 Spring 2015 Howard Rosenthal

Expressions and Data Types CSC 121 Spring 2015 Howard Rosenthal Expressions and Data Types CSC 121 Spring 2015 Howard Rosenthal Lesson Goals Understand the basic constructs of a Java Program Understand how to use basic identifiers Understand simple Java data types

More information

TeenCoder : Java Programming (ISBN )

TeenCoder : Java Programming (ISBN ) TeenCoder : Java Programming (ISBN 978-0-9887070-2-3) and the AP * Computer Science A Exam Requirements (Alignment to Tennessee AP CS A course code 3635) Updated March, 2015 Contains the new 2014-2015+

More information

Quarter 1 Practice Exam

Quarter 1 Practice Exam University of Chicago Laboratory Schools Advanced Placement Computer Science Quarter 1 Practice Exam Baker Franke 2005 APCS - 12/10/08 :: 1 of 8 1.) (10 percent) Write a segment of code that will produce

More information

Array Basics: Outline

Array Basics: Outline Arrays Chapter 7 Array Basics: Outline Creating and Accessing Arrays Array Details The Instance Variable length More About Array Indices Partially-filled Arrays Working with Arrays Creating and Accessing

More information

University Interscholastic League. Computer Science Competition

University Interscholastic League. Computer Science Competition University Interscholastic League Computer Science Competition Number 121 (District 1-2010) General Directions (Please read carefully!): 1) DO NOT OPEN EXAM UNTIL TOLD TO DO SO. 2) NO CALCULATOR OF ANY

More information

CS302: Self Check Quiz 2

CS302: Self Check Quiz 2 CS302: Self Check Quiz 2 name: Part I True or False For these questions, is the statement true or false? Assume the statements are about the Java programming language. 1.) The result of an expression with

More information

Introduction to Programming Written Examination

Introduction to Programming Written Examination Introduction to Programming Written Examination 23.9.2016 FIRST NAME STUDENT NUMBER LAST NAME SIGNATURE Instructions for students: Write First Name, Last Name, Student Number and Signature where indicated.

More information

Lab Activity Plan. John Dalbey CPE /30/2013

Lab Activity Plan. John Dalbey CPE /30/2013 John Dalbey CPE 13-5 9/3/213 Lab Activity Plan Purpose The purpose of this lab is to demonstrate the performance impacts of autoboxing in Java. The textbook describes how Java will automatically convert

More information

Inheritance. Inheritance allows the following two changes in derived class: 1. add new members; 2. override existing (in base class) methods.

Inheritance. Inheritance allows the following two changes in derived class: 1. add new members; 2. override existing (in base class) methods. Inheritance Inheritance is the act of deriving a new class from an existing one. Inheritance allows us to extend the functionality of the object. The new class automatically contains some or all methods

More information

CSC 1051 Data Structures and Algorithms I. Dr. Mary-Angela Papalaskari Department of Computing Sciences Villanova University

CSC 1051 Data Structures and Algorithms I. Dr. Mary-Angela Papalaskari Department of Computing Sciences Villanova University Last Class CSC 1051 Data Structures and Algorithms I Dr. Mary-Angela Papalaskari Department of Computing Sciences Villanova University Course website: www.csc.villanova.edu/~map/1051/ Some slides in this

More information

AP CS Unit 7: Arrays Exercises

AP CS Unit 7: Arrays Exercises AP CS Unit 7: Arrays Exercises 1. What is displayed? int [] a = new int[ 3 ]; System.out.println(a.length ); 2. What is displayed? int [] sting = { 34, 23, 67, 89, 12 ; System.out.println( sting[ 1 ] );

More information

Interpreted vs Compiled. Java Compile. Classes, Objects, and Methods. Hello World 10/6/2016. Python Interpreted. Java Compiled

Interpreted vs Compiled. Java Compile. Classes, Objects, and Methods. Hello World 10/6/2016. Python Interpreted. Java Compiled Interpreted vs Compiled Python 1 Java Interpreted Easy to run and test Quicker prototyping Program runs slower Compiled Execution time faster Virtual Machine compiled code portable Java Compile > javac

More information

1.1 Your First Program

1.1 Your First Program 1.1 Your First Program Introduction to Programming in Java: An Interdisciplinary Approach Robert Sedgewick and Kevin Wayne Copyright 2002 2010 5/20/2013 9:37:22 AM Why Programming? Why programming? Need

More information

Object Class. EX: LightSwitch Class. Basic Class Concepts: Parts. CS257 Computer Science II Kevin Sahr, PhD. Lecture 5: Writing Object Classes

Object Class. EX: LightSwitch Class. Basic Class Concepts: Parts. CS257 Computer Science II Kevin Sahr, PhD. Lecture 5: Writing Object Classes 1 CS257 Computer Science II Kevin Sahr, PhD Lecture 5: Writing Object Classes Object Class 2 objects are the basic building blocks of programs in Object Oriented Programming (OOP) languages objects consist

More information

RECURSION. Prof. Chris Jermaine

RECURSION. Prof. Chris Jermaine RECURSION Prof. Chris Jermaine cmj4@cs.rice.edu 1 What Is Recursion? Using a call to a method (directly or indirectly) to implement itself T findlargest (ArrayList inme) { if (inme.size ()

More information

CS 110 Practice Final Exam originally from Winter, Instructions: closed books, closed notes, open minds, 3 hour time limit.

CS 110 Practice Final Exam originally from Winter, Instructions: closed books, closed notes, open minds, 3 hour time limit. Name CS 110 Practice Final Exam originally from Winter, 2003 Instructions: closed books, closed notes, open minds, 3 hour time limit. There are 4 sections for a total of 49 points. Part I: Basic Concepts,

More information

Computer Science II (20073) Week 1: Review and Inheritance

Computer Science II (20073) Week 1: Review and Inheritance Computer Science II 4003-232-01 (20073) Week 1: Review and Inheritance Richard Zanibbi Rochester Institute of Technology Review of CS-I Hardware and Software Hardware Physical devices in a computer system

More information

CS 307 Midterm 1 Fall 2007

CS 307 Midterm 1 Fall 2007 Points off 1 2 3 4 Total off Net Score CS 307 Midterm 1 Fall 2007 Your Name Your UTEID Circle yours TA s name: David Joseph Ola Instructions: 1. Please turn off your cell phones 2. There are 4 questions

More information

Lecture 14. 'for' loops and Arrays

Lecture 14. 'for' loops and Arrays Lecture 14 'for' loops and Arrays For Loops for (initiating statement; conditional statement; next statement) // usually incremental body statement(s); The for statement provides a compact way to iterate

More information

COE 212 Engineering Programming. Welcome to the Final Exam Tuesday December 15, 2015

COE 212 Engineering Programming. Welcome to the Final Exam Tuesday December 15, 2015 1 COE 212 Engineering Programming Welcome to the Final Exam Tuesday December 15, 2015 Instructors: Dr. Salim Haddad Dr. Bachir Habib Dr. Joe Tekli Dr. Wissam F. Fawaz Name: Student ID: Instructions: 1.

More information

CS 112 Programming 2. Lecture 06. Inheritance & Polymorphism (1) Chapter 11 Inheritance and Polymorphism

CS 112 Programming 2. Lecture 06. Inheritance & Polymorphism (1) Chapter 11 Inheritance and Polymorphism CS 112 Programming 2 Lecture 06 Inheritance & Polymorphism (1) Chapter 11 Inheritance and Polymorphism rights reserved. 2 Motivation Suppose you want to define classes to model circles, rectangles, and

More information

AP COMPUTER SCIENCE A

AP COMPUTER SCIENCE A AP COMPUTER SCIENCE A CONTROL FLOW Aug 28 2017 Week 2 http://apcs.cold.rocks 1 More operators! not!= not equals to % remainder! Goes ahead of boolean!= is used just like == % is used just like / http://apcs.cold.rocks

More information

BASIC COMPUTATION. public static void main(string [] args) Fundamentals of Computer Science I

BASIC COMPUTATION. public static void main(string [] args) Fundamentals of Computer Science I BASIC COMPUTATION x public static void main(string [] args) Fundamentals of Computer Science I Outline Using Eclipse Data Types Variables Primitive and Class Data Types Expressions Declaration Assignment

More information

CT 229 Java Syntax Continued

CT 229 Java Syntax Continued CT 229 Java Syntax Continued 06/10/2006 CT229 Lab Assignments Due Date for current lab assignment : Oct 8 th Before submission make sure that the name of each.java file matches the name given in the assignment

More information

Recitation #2 Abstract Data Types, Collection Classes, and Linked List

Recitation #2 Abstract Data Types, Collection Classes, and Linked List Recitation #2 Abstract Data Types, Collection Classes, and Linked List (1) Create an ADT Fraction that describes properties of fractions. Include the constructor, setter, getter, and tostring() methods

More information

CS 307 Midterm 2 Spring 2008

CS 307 Midterm 2 Spring 2008 Points off 1 2 3 4 Total off Net Score Exam Number: CS 307 Midterm 2 Spring 2008 Name UTEID login name TA's Name: Mario Ruchica Vishvas (Circle One) Instructions: 1. Please turn off your cell phones and

More information

CS 302: Introduction to Programming in Java. Lecture 11 Yinggang Huang. CS302 Summer 2012

CS 302: Introduction to Programming in Java. Lecture 11 Yinggang Huang. CS302 Summer 2012 CS 302: Introduction to Programming in Java Lecture 11 Yinggang Huang 1 Review How do we call a method? What are method inputs called? How many values can be returned from a method? Write a method header

More information

AP CS Unit 7: Interfaces Exercises Assume all code compiles unless otherwise suggested.

AP CS Unit 7: Interfaces Exercises Assume all code compiles unless otherwise suggested. AP CS Unit 7: Interfaces Exercises Assume all code compiles unless otherwise suggested. 1. The Nose class... b) will not compile because the m1 method parameter should be named n, not x. 2. The Ears class...

More information

Tester vs. Controller. Elementary Programming. Learning Outcomes. Compile Time vs. Run Time

Tester vs. Controller. Elementary Programming. Learning Outcomes. Compile Time vs. Run Time Tester vs. Controller Elementary Programming EECS1022: Programming for Mobile Computing Winter 2018 CHEN-WEI WANG For effective illustrations, code examples will mostly be written in the form of a tester

More information

SPRING 13 CS 0007 FINAL EXAM V2 (Roberts) Your Name: A pt each. B pt each. C pt each. D or 2 pts each

SPRING 13 CS 0007 FINAL EXAM V2 (Roberts) Your Name: A pt each. B pt each. C pt each. D or 2 pts each Your Name: Your Pitt (mail NOT peoplesoft) ID: Part Question/s Points available Rubric Your Score A 1-6 6 1 pt each B 7-12 6 1 pt each C 13-16 4 1 pt each D 17-19 5 1 or 2 pts each E 20-23 5 1 or 2 pts

More information

Course Outline. Introduction to java

Course Outline. Introduction to java Course Outline 1. Introduction to OO programming 2. Language Basics Syntax and Semantics 3. Algorithms, stepwise refinements. 4. Quiz/Assignment ( 5. Repetitions (for loops) 6. Writing simple classes 7.

More information

This exam is open book. Each question is worth 3 points.

This exam is open book. Each question is worth 3 points. This exam is open book. Each question is worth 3 points. Page 1 / 15 Page 2 / 15 Page 3 / 12 Page 4 / 18 Page 5 / 15 Page 6 / 9 Page 7 / 12 Page 8 / 6 Total / 100 (maximum is 102) 1. Are you in CS101 or

More information

Elementary Programming

Elementary Programming Elementary Programming EECS1022: Programming for Mobile Computing Winter 2018 CHEN-WEI WANG Learning Outcomes Learn ingredients of elementary programming: data types [numbers, characters, strings] literal

More information

Programming overview

Programming overview Programming overview Basic Java A Java program consists of: One or more classes A class contains one or more methods A method contains program statements Each class in a separate file MyClass defined in

More information

Entry Point of Execution: the main Method. Elementary Programming. Learning Outcomes. Development Process

Entry Point of Execution: the main Method. Elementary Programming. Learning Outcomes. Development Process Entry Point of Execution: the main Method Elementary Programming EECS1021: Object Oriented Programming: from Sensors to Actuators Winter 2019 CHEN-WEI WANG For now, all your programming exercises will

More information

Outline. Parts 1 to 3 introduce and sketch out the ideas of OOP. Part 5 deals with these ideas in closer detail.

Outline. Parts 1 to 3 introduce and sketch out the ideas of OOP. Part 5 deals with these ideas in closer detail. OOP in Java 1 Outline 1. Getting started, primitive data types and control structures 2. Classes and objects 3. Extending classes 4. Using some standard packages 5. OOP revisited Parts 1 to 3 introduce

More information

Lecture Set 4: More About Methods and More About Operators

Lecture Set 4: More About Methods and More About Operators Lecture Set 4: More About Methods and More About Operators Methods Definitions Invocations More arithmetic operators Operator Side effects Operator Precedence Short-circuiting main method public static

More information

COP 3330: Object Oriented Programming FALL 2017 STUDY UNION REVIEW CREDIT TO DR. GLINOS AND PROFESSOR WHITING FOR COURSE CONTENT

COP 3330: Object Oriented Programming FALL 2017 STUDY UNION REVIEW CREDIT TO DR. GLINOS AND PROFESSOR WHITING FOR COURSE CONTENT COP 3330: Object Oriented Programming FALL 2017 STUDY UNION REVIEW CREDIT TO DR. GLINOS AND PROFESSOR WHITING FOR COURSE CONTENT Object-Oriented Structure Program Structure Main structural elements of

More information