AP Computer Science Homework Set 2 Class Design

Size: px
Start display at page:

Download "AP Computer Science Homework Set 2 Class Design"

Transcription

1 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 of a song. b) A zero-argument and three-argument constructor to initialize all instance variables c) A tostring() method to display the object s instance variables in a userfriendly format. Write a separate SongDriver class to: a) create an instance of a Song called song1 using its zero-argument constructor, b) display the instance variables of the song1 using the object s tostring() method, c) create an instance of a Song called a song2 and initialize its instance variables using the object s multi-argument constructor, and d) display the instance variables of the song2 using the object s tostring() method. Page 1

2 P2B. Write a class Clock that stores information about a clock. It should have integer instance variables for the Clock s hours, minutes, seconds. Include a zeroargument and three-argument constructor to initialize all instance variables. It should also have a tostring() method to display the time in the format shown below: The time is 3:45:16 Note that zero-argument constructors should initialize instance variables to known values, most commonly zero for integers, for Strings, or false for boolean values. See the example below: public Clock() { int hour = 0; double cost = 0.0; String brand = new String( ); boolean ison = false; } // end constructor Clock Write a separate ClockDriver class to: a) create an instance of a Clock called kitchenclock using its zeroargument constructor, b) display the time of the kitchenclock using its tostring() method, c) create an instance of a Clock called a bedroomclock and set the hours, minutes, and seconds using the Clock s three-arguments constructor d) display the time of the bedroomclock using its tostring() method. Page 2

3 P2C. Let s write another class and test it with a driver. This time let s create a Student class that models a Fairfax student. The Student class should have instance variables for the student s first and last name, and at least TWO other instance variables chosen by you. Include a zero-argument and multi-argument constructor to initialize all instance variables. Choose the most appropriate variable types (i.e. int, double, String, boolean) for each instance variable. It should also have a tostring() method to display the object s instance variables in a user-friendly format. Write a separate StudentDriver class to: a) create an instance of a Student called senior001 using its zeroargument constructor, b) display the instance variables of the senior001 using the object s tostring() method, c) create an instance of a Student called a frosh001 and initialize its instance variables using the object s multi-argument constructor, and d) display the instance variables of the frosh001 using the object s tostring() method. If you are looking for an extra challenge, try to printout the results of the program using JOptionPane.showMessageDialog(). See the LewTube video for this HW Set on the details of how to use this very cool tool. P2D. Design a class that models an object of your choice (e.g. type of car, sports team, musical instrument, etc.) Include at least two different instance variables of two different types (e.g. String and an int, int and a double, boolean and a String, etc.) for your class. It should also have a tostring() method to display the object s instance variables in a user-friendly format. Write a separate YourObjectDriver class to: a) create an instance of a your object called obj1 (or a name more appropriate for your object) using its zero-argument constructor, b) display the instance variables of the obj1 using the object s tostring() method, c) create an instance of a your object called a obj2 and initialize its instance variables using the object s multi-argument constructor, and d) display the instance variables of the obj2 using the object s tostring() method. Page 3

4 P2E. Blackjack! Design a class called Card that models a playing card. Decide what instance variables you will need for your class in order to play Blackjack (or any other card game.) Include a zero-argument constructor and the appropriate multiargument constructor for your class. It should also have a tostring() method to display ALL of the object s instance variables in a user-friendly format this can be a bit tricky Write a CardDriver that will perform the following tasks: a) Create three Card objects: a blank card (i.e. a Card created using its zeroargument constructor), a number card, and a face card you pick the cards. b) Create an array called myhand that can hold 3 Card objects. Below are the lines of code that demonstrate how to create an array of Card objects and how to place a Card object into an array called myhand. Card[] myhand = new Card[10]; Card card1 = new Card( 10, Jack, Hearts ); myhand[0] = card1; c) Use a for loop to traverse the array of your Cards and print each Card using System.out.println(). The following programs DO NOT need a separate class and driver files. They are stand-alone programs that are meant to review previous topics (and introduce a couple new concepts) P2F. Write a program that creates an array that can hold 9 double values that represent baseball batting averages for a starting baseball lineup. Use a for loop to populate array with double values in the range of 0.00 to Recall that double values are what Java calls real numbers. Use a second for loop to print the values in the array with one number per line. Finally, use a third for loop to traverse the array and find and print the maximum batting average in the array. See the LewTube for this HW assignment to see how to control the precision of a double number when you print it. Page 4

5 P2G. College application time! Write a program that creates an array of Strings. Fill the array with the name of the universities that you will be applying to. Then perform the following tasks: a. traverse the array using a for loop and printout the length of each university s name. You can find the length of a String as shown below: String name = new String( UCLA ); System.out.println( name.length() ); // prints 4 b. print the name of the university that has the shortest length. c. You ve decided not to apply to one of the schools on your list. Remove that school from the list by setting that element in the array to null. This can be done as shown below: school[3] = new String( NYU ); school[3] = null; // null removes NYU from array d. print your list of schools again using a second for loop. Page 5

6 By the end of the lesson students should be able to: a. Write the Java code define a class, its data members, and its constructors. b. Write a tostring() method for a class. c. Write the Java code that uses the new operator to instantiate an object. d. Write the Java code for a driver class that creates instance of an object and initializes the class instance variables and calls the class tostring() method. Page 6

Homework Set 2- Class Design

Homework Set 2- Class Design 1 Homework Set 2- Class Design By the end of the lesson students should be able to: a. Write the Java code define a class, its data members, and its constructors. b. Write a tostring() method for a class.

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. In later programs we will use this Song class in our MyPod and online store. Here are the specs

More information

AP Computer Science Homework Set 3 Class Methods

AP Computer Science Homework Set 3 Class Methods AP Computer Science Homework Set 3 Class Methods P3A. Let s upgrade the Song class. Let s make the following upgrades: a. Add a private instance variable yearreleased that stores the year the Song was

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

AP Computer Science Homework Set 3 Class Methods

AP Computer Science Homework Set 3 Class Methods AP Computer Science Homework Set 3 Class Methods P3A. (BlueJ) Let s upgrade your Song class from P2A. You can make a copy of project P2AProject and rename it P3AProject in your Chapter 3 folder for this

More information

AP Computer Science Homework Set 5 2D Arrays

AP Computer Science Homework Set 5 2D Arrays AP Computer Science Homework Set 5 2D Arrays Note: all programs described below should work if the size of the 2D array is changed. P5A. Create a 3x4 2D array of integers. Use a nested for loop to populate

More information

AP Computer Science Homework Set 5 2D Arrays

AP Computer Science Homework Set 5 2D Arrays AP Computer Science Homework Set 5 2D Arrays Note: all programs described below should work if the size of the 2D array is changed. P5A. Create a 3x4 2D array of integers and fill it with random numbers

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

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

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

Binghamton University. CS-140 Fall Problem Solving. Creating a class from scratch

Binghamton University. CS-140 Fall Problem Solving. Creating a class from scratch Problem Solving Creating a class from scratch 1 Recipe for Writing a Class 1. Write the class boilerplate stuff 2. Declare Fields 3. Write Creator(s) 4. Write accessor methods 5. Write mutator methods

More information

Queens College, CUNY Department of Computer Science. CS 212 Object-Oriented Programming in Java Practice Exam 2. CS 212 Exam 2 Study Guide

Queens College, CUNY Department of Computer Science. CS 212 Object-Oriented Programming in Java Practice Exam 2. CS 212 Exam 2 Study Guide Topics for Exam 2: Queens College, CUNY Department of Computer Science CS 212 Object-Oriented Programming in Java Practice Exam 2 CS 212 Exam 2 Study Guide Linked Lists define a list node define a singly-linked

More information

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

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

More information

CS201 - Assignment 1, Part 2 Due: Wednesday February 19, at the beginning of class

CS201 - Assignment 1, Part 2 Due: Wednesday February 19, at the beginning of class CS201 - Assignment 1, Part 2 Due: Wednesday February 19, at the beginning of class 1 Java Practice To give you some practice writing functions/methods in Java, for the first part of this assignment, you

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

Birkbeck (University of London) Software and Programming 1 In-class Test Mar 2018

Birkbeck (University of London) Software and Programming 1 In-class Test Mar 2018 Birkbeck (University of London) Software and Programming 1 In-class Test 2.1 22 Mar 2018 Student Name Student Number Answer ALL Questions 1. What output is produced when the following Java program fragment

More information

Exam 1 - (20 points)

Exam 1 - (20 points) Exam 1 - (20 points) Answer all of the following questions. READ EACH QUESTION CAREFULLY. Fill the correct bubble on your scantron sheet. Each correct answer is worth 1 point (unless otherwise stated).

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

Lesson 39: Conditionals #3 (W11D4)

Lesson 39: Conditionals #3 (W11D4) Lesson 39: Conditionals #3 (W11D4) Balboa High School Michael Ferraro October 29, 2015 1 / 29 Do Now In order to qualify for a $50k loan, the following conditions must be met: Your annual income must be

More information

CO Java SE 8: Fundamentals

CO Java SE 8: Fundamentals CO-83527 Java SE 8: Fundamentals Summary Duration 5 Days Audience Application Developer, Developer, Project Manager, Systems Administrator, Technical Administrator, Technical Consultant and Web Administrator

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

AP Computer Science in Java Course Syllabus

AP Computer Science in Java Course Syllabus CodeHS AP Computer Science in Java Course Syllabus College Board Curriculum Requirements The CodeHS AP Java course is fully College Board aligned and covers all seven curriculum requirements extensively

More information

Draft. Students Table. FName LName StudentID College Year. Justin Ennen Science Senior. Dan Bass Management Junior

Draft. Students Table. FName LName StudentID College Year. Justin Ennen Science Senior. Dan Bass Management Junior Chapter 6 Introduction to SQL 6.1 What is a SQL? When would I use it? SQL stands for Structured Query Language. It is a language used mainly for talking to database servers. It s main feature divisions

More information

Interfaces: JAVA CONTRACTS

Interfaces: JAVA CONTRACTS Interfaces: JAVA CONTRACTS Homework Stamp #3: Udacity Problem Set #6, #10-20 + Quiz Question #2 https://classroom.udacity.com/courses/cs046 Warm-Up SuperFriends Video Game! You ve been hired to work on

More information

THE UNIVERSITY OF WESTERN AUSTRALIA. School of Computer Science & Software Engineering CITS1001 OBJECT-ORIENTED PROGRAMMING AND SOFTWARE ENGINEERING

THE UNIVERSITY OF WESTERN AUSTRALIA. School of Computer Science & Software Engineering CITS1001 OBJECT-ORIENTED PROGRAMMING AND SOFTWARE ENGINEERING THE UNIVERSITY OF WESTERN AUSTRALIA School of Computer Science & Software Engineering CITS1001 OBJECT-ORIENTED PROGRAMMING AND SOFTWARE ENGINEERING SAMPLE TEST APRIL 2012 This Paper Contains: 12 Pages

More information

CS 61B, Spring 1999 MT3 Professor M. Clancy

CS 61B, Spring 1999 MT3 Professor M. Clancy CS 61B, Spring 1999 MT3 Professor M. Clancy Problem #1 One approach to producing debugging output is to use inheritance to create objects that print any changes to themselves. For instance, instead of

More information

Advanced Java Concepts Unit 2: Linked Lists.

Advanced Java Concepts Unit 2: Linked Lists. Advanced Java Concepts Unit 2: Linked Lists. The List interface defines the structure of a linear collection. Here are some of its methods. boolean add( E element ) Appends the element to the end of the

More information

CIS 110: Introduction to Computer Programming

CIS 110: Introduction to Computer Programming CIS 110: Introduction to Computer Programming Lecture 3 Express Yourself ( 2.1) 9/16/2011 CIS 110 (11fa) - University of Pennsylvania 1 Outline 1. Data representation and types 2. Expressions 9/16/2011

More information

DATA STRUCTURES CHAPTER 1

DATA STRUCTURES CHAPTER 1 DATA STRUCTURES CHAPTER 1 FOUNDATIONAL OF DATA STRUCTURES This unit introduces some basic concepts that the student needs to be familiar with before attempting to develop any software. It describes data

More information

CS211 Prelim Oct 2001 NAME NETID

CS211 Prelim Oct 2001 NAME NETID This prelim has 4 questions. Be sure to answer them all. Please write clearly, and show all your work. It is difficult to give partial credit if all we see is a wrong answer. Also, be sure to place suitable

More information

CLASS DESIGN. Objectives MODULE 4

CLASS DESIGN. Objectives MODULE 4 MODULE 4 CLASS DESIGN Objectives > After completing this lesson, you should be able to do the following: Use access levels: private, protected, default, and public. Override methods Overload constructors

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

Lesson 36: for() Loops (W11D1)

Lesson 36: for() Loops (W11D1) Lesson 36: for() Loops (W11D1) Balboa High School Michael Ferraro October 26, 2015 1 / 27 Do Now Create a new project: Lesson36 Write class FirstForLoop: Include a main() method: public static void main(string[]

More information

Advanced Java Concepts Unit 9: Graph Exercises

Advanced Java Concepts Unit 9: Graph Exercises dvanced Java oncepts Unit : Graph Exercises. Which one of the following data structures would be best suited for representing a street map for pedestrians? graph with... a) undirected, unweighted edges.

More information

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

Computer Science II (20082) Week 1: Review and Inheritance Computer Science II 4003-232-08 (20082) Week 1: Review and Inheritance Richard Zanibbi Rochester Institute of Technology Review of CS-I Syntax and Semantics of Formal (e.g. Programming) Languages Syntax

More information

CSE115 / CSE503 Introduction to Computer Science I. Dr. Carl Alphonce 343 Davis Hall Office hours:

CSE115 / CSE503 Introduction to Computer Science I. Dr. Carl Alphonce 343 Davis Hall Office hours: CSE115 / CSE503 Introduction to Computer Science I Dr. Carl Alphonce 343 Davis Hall alphonce@buffalo.edu Office hours: Thursday 12:00 PM 2:00 PM Friday 8:30 AM 10:30 AM OR request appointment via e-mail

More information

Computer Sciences 302 Exam 2 Information & Sample Exam

Computer Sciences 302 Exam 2 Information & Sample Exam Computer Sciences 302 Exam 2 Information & Sample Exam Below you ll find information about the second midterm exam and sample exam questions. This sample is intended to be similar in length and difficulty

More information

CSIS 10B Lab 2 Bags and Stacks

CSIS 10B Lab 2 Bags and Stacks CSIS 10B Lab 2 Bags and Stacks Part A Bags and Inheritance In this part of the lab we will be exploring the use of the Bag ADT to manage quantities of data of a certain generic type (listed as T in the

More information

Excel Functions & Tables

Excel Functions & Tables Excel Functions & Tables Fall 2012 Fall 2012 CS130 - Excel Functions & Tables 1 Review of Functions Quick Mathematics Review As it turns out, some of the most important mathematics for this course revolves

More information

STUDENT LESSON A15 ArrayList

STUDENT LESSON A15 ArrayList STUDENT LESSON A15 ArrayList Java Curriculum for AP Computer Science, Student Lesson A15 1 STUDENT LESSON A15 - ArrayList INTRODUCTION: It is very common for a program to manipulate data that is kept in

More information

Object Oriented Design: Identifying Objects

Object Oriented Design: Identifying Objects Object Oriented Design: Identifying Objects Review What did we do in the last lab? What did you learn? What classes did we use? What objects did we use? What is the difference between a class and an object?

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

Birkbeck (University of London) Software and Programming 1 In-class Test Mar Answer ALL Questions

Birkbeck (University of London) Software and Programming 1 In-class Test Mar Answer ALL Questions Birkbeck (University of London) Software and Programming 1 In-class Test 2.1 16 Mar 2017 Student Name Student Number Answer ALL Questions 1. What output is produced when the following Java program fragment

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

Topic 7: Algebraic Data Types

Topic 7: Algebraic Data Types Topic 7: Algebraic Data Types 1 Recommended Exercises and Readings From Haskell: The craft of functional programming (3 rd Ed.) Exercises: 5.5, 5.7, 5.8, 5.10, 5.11, 5.12, 5.14 14.4, 14.5, 14.6 14.9, 14.11,

More information

CS 106 Introduction to Computer Science I

CS 106 Introduction to Computer Science I CS 106 Introduction to Computer Science I 03 / 28 / 2012 Instructor: Michael Eckmann Today s Topics Questions? Comments? Object oriented programming More of creating our own classes Valid ways to call

More information

Introduction to Computer Science II (CSI 1101)

Introduction to Computer Science II (CSI 1101) Introduction to Computer Science II (CSI 1101) Professor: M. Turcotte February 2002, duration: 75 minutes Identification Student name: last name: Section: Student number: initials: Signature: Instructions

More information

CS61B Lecture #2. Public Service Announcements:

CS61B Lecture #2. Public Service Announcements: CS61B Lecture #2 Please make sure you have obtained an account, run register, and finished the survey today. In the future (next week), the password required for surveys and such will be your account password

More information

Object-Oriented Design Lecture 14 CSU 370 Fall 2007 (Pucella) Friday, Nov 2, 2007

Object-Oriented Design Lecture 14 CSU 370 Fall 2007 (Pucella) Friday, Nov 2, 2007 Object-Oriented Design Lecture 14 CSU 370 Fall 2007 (Pucella) Friday, Nov 2, 2007 (These notes are very rough, and differ somewhat from what I presented in class; I am posting them here to supplemental

More information

Java Fundamentals (II)

Java Fundamentals (II) Chair of Software Engineering Languages in Depth Series: Java Programming Prof. Dr. Bertrand Meyer Java Fundamentals (II) Marco Piccioni static imports Introduced in 5.0 Imported static members of a class

More information

Object-Oriented Programming in Java

Object-Oriented Programming in Java CSCI/CMPE 3326 Object-Oriented Programming in Java inheritance Dongchul Kim Department of Computer Science University of Texas Rio Grande Valley Lab8 Please at the top of the program, as a comment include

More information

Islamic University of Gaza Faculty of Engineering Computer Engineering Department

Islamic University of Gaza Faculty of Engineering Computer Engineering Department Student Mark Islamic University of Gaza Faculty of Engineering Computer Engineering Department Question # 1 / 18 Question # / 1 Total ( 0 ) Student Information ID Name Answer keys Sector A B C D E A B

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

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

QUEEN MARY, UNIVERSITY OF LONDON DCS128 ALGORITHMS AND DATA STRUCTURES Class Test Monday 27 th March

QUEEN MARY, UNIVERSITY OF LONDON DCS128 ALGORITHMS AND DATA STRUCTURES Class Test Monday 27 th March QUEEN MARY, UNIVERSITY OF LONDON DCS128 ALGORITHMS AND DATA STRUCTURES Class Test Monday 27 th March 2006 11.05-12.35 Please fill in your Examination Number here: Student Number here: MODEL ANSWERS All

More information

Classes Classes 2 / 35

Classes Classes 2 / 35 Classes 1 / 35 Classes Classes 2 / 35 Anatomy of a Class By the end of next lecture, you ll understand everything in this class definition. package edu. gatech. cs1331. card ; import java. util. Arrays

More information

Prelim 1. CS 2110, March 15, 2016, 5:30 PM Total Question Name True False. Short Answer

Prelim 1. CS 2110, March 15, 2016, 5:30 PM Total Question Name True False. Short Answer Prelim 1 CS 2110, March 15, 2016, 5:30 PM 0 1 2 3 4 5 Total Question Name True False Short Answer Object- Oriented Recursion Loop Invariants Max 1 20 14 25 19 21 100 Score Grader The exam is closed book

More information

Loops. In Example 1, we have a Person class, that counts the number of Person objects constructed.

Loops. In Example 1, we have a Person class, that counts the number of Person objects constructed. Loops Introduction In this article from my free Java 8 course, I will discuss the use of loops in Java. Loops allow the program to execute repetitive tasks or iterate over vast amounts of data quickly.

More information

Rules and syntax for inheritance. The boring stuff

Rules and syntax for inheritance. The boring stuff Rules and syntax for inheritance The boring stuff The compiler adds a call to super() Unless you explicitly call the constructor of the superclass, using super(), the compiler will add such a call for

More information

Computer Science II. OO Programming Classes Scott C Johnson Rochester Institute of Technology

Computer Science II. OO Programming Classes Scott C Johnson Rochester Institute of Technology Computer Science II OO Programming Classes Scott C Johnson Rochester Institute of Technology Outline Object-Oriented (OO) Programming Review Initial Implementation Constructors Other Standard Behaviors

More information

Day 4. COMP1006/1406 Summer M. Jason Hinek Carleton University

Day 4. COMP1006/1406 Summer M. Jason Hinek Carleton University Day 4 COMP1006/1406 Summer 2016 M. Jason Hinek Carleton University today s agenda assignments questions about assignment 2 a quick look back constructors signatures and overloading encapsulation / information

More information

CS1004: Intro to CS in Java, Spring 2005

CS1004: Intro to CS in Java, Spring 2005 CS1004: Intro to CS in Java, Spring 2005 Lecture #23: OO Design, cont d. Janak J Parekh janak@cs.columbia.edu Administrivia HW#5 due Tuesday And if you re cheating on (or letting others see your) HW#5

More information

1.00/1.001 Introduction to Computers and Engineering Problem Solving. Final Exam

1.00/1.001 Introduction to Computers and Engineering Problem Solving. Final Exam 1.00/1.001 Introduction to Computers and Engineering Problem Solving Final Exam Name: Email Address: TA: Section: You have three hours to complete this exam. For coding questions, you do not need to include

More information

CMP 326 Midterm Fall 2015

CMP 326 Midterm Fall 2015 CMP 326 Midterm Fall 2015 Name: 1) (30 points; 5 points each) Write the output of each piece of code. If the code gives an error, write any output that would happen before the error, and then write ERROR.

More information

Student Performance Q&A:

Student Performance Q&A: Student Performance Q&A: 2016 AP Computer Science A Free-Response Questions The following comments on the 2016 free-response questions for AP Computer Science A were written by the Chief Reader, Elizabeth

More information

Faculty of Science FINAL EXAMINATION COMP-250 A Introduction to Computer Science School of Computer Science, McGill University

Faculty of Science FINAL EXAMINATION COMP-250 A Introduction to Computer Science School of Computer Science, McGill University NAME: STUDENT NUMBER:. Faculty of Science FINAL EXAMINATION COMP-250 A Introduction to Computer Science School of Computer Science, McGill University Examimer: Prof. Mathieu Blanchette December 8 th 2005,

More information

Excel Functions & Tables

Excel Functions & Tables Excel Functions & Tables Winter 2012 Winter 2012 CS130 - Excel Functions & Tables 1 Review of Functions Quick Mathematics Review As it turns out, some of the most important mathematics for this course

More information

CS2141 Software Development using C/C++ C++ Basics

CS2141 Software Development using C/C++ C++ Basics CS2141 Software Development using C/C++ C++ Basics Integers Basic Types Can be short, long, or just plain int C++ does not define the size of them other than short

More information

Contents. I. Classes, Superclasses, and Subclasses. Topic 04 - Inheritance

Contents. I. Classes, Superclasses, and Subclasses. Topic 04 - Inheritance Contents Topic 04 - Inheritance I. Classes, Superclasses, and Subclasses - Inheritance Hierarchies Controlling Access to Members (public, no modifier, private, protected) Calling constructors of superclass

More information

Java Arrays (review) Linked Lists (preview)

Java Arrays (review) Linked Lists (preview) Java Arrays (review) Linked Lists (preview) 1 Array Agenda What is an array Declaration of an array Instantiation of an array Accessing array element Array length Multi-dimensional array 2 What is an Array?

More information

Bellwork Strings 11/25/13

Bellwork Strings 11/25/13 Bellwork Strings 11/25/13 1. How have we been using Strings in Java for? 2. Why does String begin with a capital letter? 3. From your homework, what are the problems that we run into when we try to compare

More information

University of Palestine. Mid Exam Total Grade: 100

University of Palestine. Mid Exam Total Grade: 100 First Question No. of Branches (5) A) Choose the correct answer: 1. If we type: system.out.println( a ); in the main() method, what will be the result? int a=12; //in the global space... void f() { int

More information

Introduction to Computer Science II (CSI 1101) Midterm Examination

Introduction to Computer Science II (CSI 1101) Midterm Examination Introduction to Computer Science II (CSI 1101) Midterm Examination Instructor: Marcel Turcotte February 2005, duration: 2 hours Identification Student name: Student number: Signature: Instructions 1. 2.

More information

CSC Java Programming, Fall Java Data Types and Control Constructs

CSC Java Programming, Fall Java Data Types and Control Constructs CSC 243 - Java Programming, Fall 2016 Java Data Types and Control Constructs Java Types In general, a type is collection of possible values Main categories of Java types: Primitive/built-in Object/Reference

More information

Creating an Immutable Class. Based on slides by Prof. Burton Ma

Creating an Immutable Class. Based on slides by Prof. Burton Ma Creating an Immutable Class Based on slides by Prof. Burton Ma 1 Value Type Classes A value type is a class that represents a value Examples of values: name, date, colour, mathematical vector Java examples:

More information

Arrays & Classes. Problem Statement and Specifications

Arrays & Classes. Problem Statement and Specifications Arrays & Classes Quick Start Compile step once always make -k baseball8 mkdir labs cd labs Execute step mkdir 8 java Baseball8 cd 8 cp /samples/csc/156/labs/8/*. Submit step emacs Player.java & submit

More information

Creating an object Instance variables

Creating an object Instance variables Introduction to Objects: Semantics and Syntax Defining i an object Creating an object Instance variables Instance methods What is OOP? Object-oriented programming (constructing software using objects)

More information

Lesson 10: Quiz #1 and Getting User Input (W03D2)

Lesson 10: Quiz #1 and Getting User Input (W03D2) Lesson 10: Quiz #1 and Getting User Input (W03D2) Balboa High School Michael Ferraro September 1, 2015 1 / 13 Do Now: Prep GitHub Repo for PS #1 You ll need to submit the 5.2 solution on the paper form

More information

Unit Testing. SWEN-610 Foundations of Software Engineering. Department of Software Engineering Rochester Institute of Technology

Unit Testing. SWEN-610 Foundations of Software Engineering. Department of Software Engineering Rochester Institute of Technology Unit Testing SWEN-610 Foundations of Software Engineering Department of Software Engineering Rochester Institute of Technology There are many levels of software testing. The developer of the software has

More information

(4-3) Selection Structures II in C H&K Chapter 4. Instructor - Andrew S. O Fallon CptS 121 (February 2, 2018) Washington State University

(4-3) Selection Structures II in C H&K Chapter 4. Instructor - Andrew S. O Fallon CptS 121 (February 2, 2018) Washington State University (4-3) Selection Structures II in C H&K Chapter 4 Instructor - Andrew S. O Fallon CptS 121 (February 2, 2018) Washington State University Nested if statements (1) Consider the following scenario: A high

More information

Binghamton University. CS-140 Fall Data Types in Java

Binghamton University. CS-140 Fall Data Types in Java Data Types in Java 1 CS-211 2015 Example Class: Car How Cars are Described Make Model Year Color Owner Location Mileage Actions that can be applied to cars Create a new car Transfer ownership Move to a

More information

C12a: The Object Superclass and Selected Methods

C12a: The Object Superclass and Selected Methods CISC 3115 TY3 C12a: The Object Superclass and Selected Methods Hui Chen Department of Computer & Information Science CUNY Brooklyn College 10/4/2018 CUNY Brooklyn College 1 Outline The Object class and

More information

1.00 Introduction to Computers and Engineering Problem Solving. Quiz 1 March 7, 2003

1.00 Introduction to Computers and Engineering Problem Solving. Quiz 1 March 7, 2003 1.00 Introduction to Computers and Engineering Problem Solving Quiz 1 March 7, 2003 Name: Email Address: TA: Section: You have 90 minutes to complete this exam. For coding questions, you do not need to

More information

Intro. Scheme Basics. scm> 5 5. scm>

Intro. Scheme Basics. scm> 5 5. scm> Intro Let s take some time to talk about LISP. It stands for LISt Processing a way of coding using only lists! It sounds pretty radical, and it is. There are lots of cool things to know about LISP; if

More information

Topic 7: Inheritance. Reading: JBD Sections CMPS 12A Winter 2009 UCSC

Topic 7: Inheritance. Reading: JBD Sections CMPS 12A Winter 2009 UCSC Topic 7: Inheritance Reading: JBD Sections 7.1-7.6 1 A Quick Review of Objects and Classes! An object is an abstraction that models some thing or process! Examples of objects:! Students, Teachers, Classes,

More information

COMP 105 Homework: Type Systems

COMP 105 Homework: Type Systems Due Tuesday, March 29, at 11:59 PM (updated) The purpose of this assignment is to help you learn about type systems. Setup Make a clone of the book code: git clone linux.cs.tufts.edu:/comp/105/build-prove-compare

More information

CSC-140 Assignment 6

CSC-140 Assignment 6 CSC-140 Assignment 6 1 Introduction In this assignment we will start out defining our own classes. For now, we will design a class that represents a date, e.g., Tuesday, March 15, 2011, or in short hand

More information

CSE 143: Computer Programming II Autumn Sample Solutions

CSE 143: Computer Programming II Autumn Sample Solutions CSE 43: Computer Programming II Autumn 206 Final Exam Name: Sample Solutions E-mail: bovik @washington.edu TA: The Best Section: A9 INSTRUCTIONS: You have 0 minutes to complete the exam. You will receive

More information

CS-140 Fall 2017 Test 2 Version A Nov. 29, 2017

CS-140 Fall 2017 Test 2 Version A Nov. 29, 2017 CS-140 Fall 2017 Test 2 Version A Nov. 29, 2017 Name: 1. (10 points) For the following, Check T if the statement is true, the F if the statement is false. (a) T F : An interface defines the list of fields

More information

1 If you want to store a letter grade (like a course grade) which variable type would you use? a. int b. String c. char d. boolean

1 If you want to store a letter grade (like a course grade) which variable type would you use? a. int b. String c. char d. boolean Practice Final Quiz 1 If you want to store a letter grade (like a course grade) which variable type would you use? a. int b. String c. char d. boolean 2 If you wanted to divide two numbers precisely, which

More information

Comp Intermediate Programming EXAM #1 February 16, 2004 Rice University - Instructors: Cox & Nguyen

Comp Intermediate Programming EXAM #1 February 16, 2004 Rice University - Instructors: Cox & Nguyen Instructions 1. This exam is conducted under the Rice Honor Code. It is a closed-notes, closed-book exam. 2. Fill in your name on every page of the exam. 3. If you forget the name of a Java class or method,

More information

STUDENT LESSON A20 Inheritance, Polymorphism, and Abstract Classes

STUDENT LESSON A20 Inheritance, Polymorphism, and Abstract Classes STUDENT LESSON A20 Inheritance, Polymorphism, and Abstract Classes Java Curriculum for AP Computer Science, Student Lesson A20 1 STUDENT LESSON A20 Inheritance, Polymorphism, and Abstract Classes INTRODUCTION:

More information

Ryerson University Vers HAL6891A-05 School of Computer Science CPS109 Midterm Test Fall 05 page 1 of 6

Ryerson University Vers HAL6891A-05 School of Computer Science CPS109 Midterm Test Fall 05 page 1 of 6 CPS109 Midterm Test Fall 05 page 1 of 6 Last Name First Name Student Number Circle Your Instructor Your last name here Your first name here Your student number here Ferworn Harley Instructions: (a) There

More information

Fundamentals of Programming Data Types & Methods

Fundamentals of Programming Data Types & Methods Fundamentals of Programming Data Types & Methods By Budditha Hettige Overview Summary (Previous Lesson) Java Data types Default values Variables Input data from keyboard Display results Methods Operators

More information

More about inheritance

More about inheritance Main concepts to be covered More about inheritance Exploring polymorphism method polymorphism static and dynamic type overriding dynamic method lookup protected access 4.1 The inheritance hierarchy Conflicting

More information

News and information! Review: Java Programs! Feedback after Lecture 2! Dead-lines for the first two lab assignment have been posted.!

News and information! Review: Java Programs! Feedback after Lecture 2! Dead-lines for the first two lab assignment have been posted.! True object-oriented programming: Dynamic Objects Reference Variables D0010E Object-Oriented Programming and Design Lecture 3 Static Object-Oriented Programming UML" knows-about Eckel: 30-31, 41-46, 107-111,

More information

IMACS: AP Computer Science A

IMACS: AP Computer Science A IMACS: AP Computer Science A OVERVIEW This course is a 34-week, 4 classroom hours per week course for students taking the College Board s Advanced Placement Computer Science A exam. It is an online course

More information

1 (5pts) 2 (20 pts) 3 (20 pts) 4 (10 pts) 5 (15 pts) 6 (30 pts) Total NAME: CU ID: Recitation instructor/time

1 (5pts) 2 (20 pts) 3 (20 pts) 4 (10 pts) 5 (15 pts) 6 (30 pts) Total NAME: CU ID: Recitation instructor/time CS 211 Computers and Programming Fall 2003 Prelim II 11/18/2003 NAME: CU ID: Recitation instructor/time You have one and a half hours to do this exam All programs in this exam must be written in Java Excessively

More information

Module Contact: Dr Geoff McKeown, CMP Copyright of the University of East Anglia Version 2

Module Contact: Dr Geoff McKeown, CMP Copyright of the University of East Anglia Version 2 UNIVERSITY OF EAST ANGLIA School of Computing Sciences Main Series UG Examination 2012-13 PROGRAMMING 1 CMPC1M0Y Time allowed: 2 hours Section A (Attempt all questions: 80 marks) Section B (Attempt one

More information

Computer Science 210: Data Structures

Computer Science 210: Data Structures Computer Science 210: Data Structures Welcome to Data Structures! Data structures are fundamental building blocks of algorithms and programs Csci 210 is a study of data structures design efficiency implementation

More information