Midterm Review 01. SP17 ICS 111 Ed Meyer

Similar documents
Module 2 - Part 2 DATA TYPES AND EXPRESSIONS 1/15/19 CSE 1321 MODULE 2 1

A variable is a name for a location in memory A variable must be declared

Exam 1 Prep. Dr. Demetrios Glinos University of Central Florida. COP3330 Object Oriented Programming

CS313D: ADVANCED PROGRAMMING LANGUAGE

Full file at

Java Basics. SP17 ICS 111 Ed Meyer

Chapter 2 Using Data. Instructor s Manual Table of Contents. At a Glance. Overview. Objectives. Teaching Tips. Quick Quizzes. Class Discussion Topics

Introduction to Programming Using Java (98-388)

HUDSONVILLE HIGH SCHOOL COURSE FRAMEWORK

Chapter 2: Using Data

Chapter 3 Syntax, Errors, and Debugging. Fundamentals of Java

Chapter 2: Data and Expressions

AP Computer Science A

Review: Exam 1. Your First C++ Program. Declaration Statements. Tells the compiler. Examples of declaration statements

Two Types of Types. Primitive Types in Java. Using Primitive Variables. Class #07: Java Primitives. Integer types.

Chapter 2: Using Data

COMP Primitive and Class Types. Yi Hong May 14, 2015

Chapter 2: Data and Expressions

B. Subject-specific skills B1. Problem solving skills: Supply the student with the ability to solve different problems related to the topics

Declaration and Memory

CSCI 2010 Principles of Computer Science. Data and Expressions 08/09/2013 CSCI

CS111: PROGRAMMING LANGUAGE II

Lecture 6. Assignments. Java Scanner. User Input 1/29/18. Reading: 2.12, 2.13, 3.1, 3.2, 3.3, 3.4

Full file at

9/10/10. Arithmetic Operators. Today. Assigning floats to ints. Arithmetic Operators & Expressions. What do you think is the output?

Review Chapters 1 to 4. Instructor: Scott Kristjanson CMPT 125/125 SFU Burnaby, Fall 2013

ECE 122 Engineering Problem Solving with Java

CSCI 131, Midterm Exam 1 Review Questions This sheet is intended to help you prepare for the first exam in this course. The following topics have

Reviewing for the Midterm Covers chapters 1 to 5, 7 to 9. Instructor: Scott Kristjanson CMPT 125/125 SFU Burnaby, Fall 2013

Chapter 2: Data and Expressions

Lecture 2. COMP1406/1006 (the Java course) Fall M. Jason Hinek Carleton University

Lecture 6. Assignments. Summary - Variables. Summary Program Parts 1/29/18. Reading: 3.1, 3.2, 3.3, 3.4

CMPT 125: Lecture 3 Data and Expressions

Data and Expressions. Outline. Data and Expressions 12/18/2010. Let's explore some other fundamental programming concepts. Chapter 2 focuses on:

COMP 202. Built in Libraries and objects. CONTENTS: Introduction to objects Introduction to some basic Java libraries string

Chapter 2 Elementary Programming

Chapter 2 Using Data. Instructor s Manual Table of Contents. At a Glance. A Guide to this Instructor s Manual:

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

Le L c e t c ur u e e 2 To T p o i p c i s c t o o b e b e co c v o e v r e ed e Variables Operators

Chapter 2 Working with Data Types and Operators

CIS 110: Introduction to Computer Programming

Strings. Strings and their methods. Dr. Siobhán Drohan. Produced by: Department of Computing and Mathematics

Data Conversion & Scanner Class

Fall 2017 CISC124 10/1/2017

C Language Part 1 Digital Computer Concept and Practice Copyright 2012 by Jaejin Lee

Computer Components. Software{ User Programs. Operating System. Hardware

Midterm Exam 2 Thursday, November 15th, points (15% of final grade) Instructors: Jim Williams and Marc Renault

Java Foundations: Introduction to Program Design & Data Structures, 4e John Lewis, Peter DePasquale, Joseph Chase Test Bank: Chapter 2

Slide 1 CS 170 Java Programming 1 Expressions Duration: 00:00:41 Advance mode: Auto

Computer Components. Software{ User Programs. Operating System. Hardware

We now start exploring some key elements of the Java programming language and ways of performing I/O

Primitive Data Types: Intro

BASIC ELEMENTS OF A COMPUTER PROGRAM

Datatypes, Variables, and Operations

JAVA REVIEW cs2420 Introduction to Algorithms and Data Structures Spring 2015

Introduction to: Computers & Programming: Review prior to 1 st Midterm

Operators and Expressions

C: How to Program. Week /Mar/05

Fundamental of Programming (C)

COMP-202: Foundations of Programming. Lecture 5: More About Methods and Data Types Jackie Cheung, Winter 2016

Chapter 2 Primitive Data Types and Operations. Objectives

Lecture 1. Types, Expressions, & Variables

Data and Variables. Data Types Expressions. String Concatenation Variables Declaration Assignment Shorthand operators. Operators Precedence

Chapter 02: Using Data

Assoc. Prof. Dr. Marenglen Biba. (C) 2010 Pearson Education, Inc. All rights reserved.

Hello World. n Variables store information. n You can think of them like boxes. n They hold values. n The value of a variable is its current contents

Program Fundamentals

Values, Variables, Types & Arithmetic Expressions. Agenda

CSC 1214: Object-Oriented Programming

Chapter 2: Using Data

} Evaluate the following expressions: 1. int x = 5 / 2 + 2; 2. int x = / 2; 3. int x = 5 / ; 4. double x = 5 / 2.

MODULE 02: BASIC COMPUTATION IN JAVA

Visual C# Instructor s Manual Table of Contents

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

12/22/11. Java How to Program, 9/e. Help you get started with Eclipse and NetBeans integrated development environments.

Administration. Exceptions. Leftovers. Agenda. When Things Go Wrong. Handling Errors. CS 99 Summer 2000 Michael Clarkson Lecture 11

Chapter 2 Part 2 Edited by JJ Shepherd, James O Reilly

CSCI 136 Data Structures & Advanced Programming. Fall 2018 Instructors Bill Lenhart & Bill Jannen

Week 6: Review. Java is Case Sensitive

1 Lexical Considerations

TOPIC 2 INTRODUCTION TO JAVA AND DR JAVA

Numerical Data. CS 180 Sunil Prabhakar Department of Computer Science Purdue University

CS61BL. Lecture 1: Welcome to CS61BL! Intro to Java and OOP Testing Error-handling

Primitive Data, Variables, and Expressions; Simple Conditional Execution

McGill University School of Computer Science COMP-202A Introduction to Computing 1

Java Fall 2018 Margaret Reid-Miller

Using Java Classes Fall 2018 Margaret Reid-Miller

4. Inputting data or messages to a function is called passing data to the function.

CEN 414 Java Programming

5/23/2015. Core Java Syllabus. VikRam ShaRma

Lecture Set 2: Starting Java

Lecture 5. Assignments. Arithmetic Operations. Arithmetic Operations -Summary 1/24/18. Lab 3: Variables and operations. Read Sections

Java Identifiers. Java Language Essentials. Java Keywords. Java Applications have Class. Slide Set 2: Java Essentials. Copyright 2012 R.M.

Computer Programming, I. Laboratory Manual. Experiment #3. Selections

Lecture Set 2: Starting Java

Lesson 3: Arithmetic & Casting. Pic 10A Ricardo Salazar

Expressions and Data Types CSC 121 Spring 2015 Howard Rosenthal

Chapter 1 Introduction to java

Variables of class Type. Week 8. Variables of class Type, Cont. A simple class:

Computational Expression

Transcription:

Midterm Review 01 SP17 ICS 111 Ed Meyer

Exam Details On Laulima > Quizzes, Tests and Surveys Due Thursday 2/23 by 11:55pm Password: toast 1 attempt; 1 hr 15 minutes Reserve uninterrupted time for yourself I do NOT recommend starting at 10:40pm Covers all material so far Weeks 01-06 2

Exam Format 3 Sections 1. Multiple Choice & True/False 2. Short Answer 3. Programming 3

Exam Format 1. Multiple Choice & True/False 10 Questions Given some code and ask what will print/happen Conceptual questions 4

Exam Format 2. Short Answer 2 Questions Respond in complete sentences directly in the exam Given larger coding snippets and trace through them Ask to explain the difference between code 5

Exam Format 3. Programming 2 Questions Given a scenario or specifications and code from scratch Code only what you would put in the main method Any imports will be assumed Majority will come from approach, but syntax is still part of your grade 6

Topics Covered By Week Week 01: Program Skeleton, Reserved Words, Printing Week 02: Data Types, Arithmetic, Variables Week 03: Input/Output (Scanner) Week 04: Conversions and Objects Week 05: Error Handling / IF-statements Week 06: Comparisons / RNG 7

Week 01 Naming Conventions Classes: Camel case notation Variables: lower camel case Constants: all uppercase Reserved Words Program Skeleton Printing: print vs println 8

Week 02 Complex Messages Printing characters that you normally cannot print Escape characters with \ Concatenation using + Concept of a variable Primitive Data Types Constants Naming convention final keyword: final double PI = 3.14; 9

Week 02 (Cont.) Using String variables Arithmetic Expressions Order of operations (PEMDAS) What does % do? Comparisons Comparison operators: <, >, <=, >=, ==,!= Evaluate to true or false Declaring vs. Initializing Concept of an assignment statement 10

Arithmetic Expressions int num1 = 7; int num2 = 3; double result = num1 / num2; // 2.0 System.out.print(result); Integer Division When dividing by integers, only the quotient is used. The decimal is discarded. 7 / 3 = 2 remainder 1 11

Arithmetic Expressions int num1 = 200091; int num2 = 2; double result = num1 % num2; // 1.0 System.out.print(result); 12

Week 03 Input/Output Import the Scanner class Why? What don't we need to import? Where can you go to check if you're not sure? Create a Scanner object Use System.in as an argument Use various methods to read input from the user What are some methods? 13

Week 04 Levels of Precedence Highest: Unary + and Lowest: Assignment statement = Data Conversion Changing the data type from more/less to less/more memory space Widening vs Narrowing Conversion Casting truncates values 14

Data Conversion double num1 = 11.0; double num2 = 2.0; // 5.5 System.out.println(num1 / num2); int result = (int) (num1 / num2); // 5 System.out.println(result); 15

Week 04 (cont.) String methods String anatomy (positions/indexes) touppercase() and tolowercase() length() substring(beginindex) substring(beginindex, endindex) trim() charat(int index) replace(oldchar, newchar) 16

Working with Strings String name = "Huzzah!"; // 7 System.out.println(name.length()); // Huz System.out.println(name.substring(0,3)); // zah! System.out.println(name.substring(3)); // zah! System.out.println(name.substring(name.length() / 2)); System.out.println(name.substring(name.length())); 17

Working with Strings String name = "Huzzah!"; // 7 System.out.println(name.length()); // Huz System.out.println(name.substring(0,3)); // zah! System.out.println(name.substring(3)); // zah! System.out.println(name.substring(name.length() / 2)); System.out.println(name.substring(name.length())); 18

Week 05 Error Handling try/catch try { // Risky code } catch (exception) { // Error message } 19

Week 05 (cont.) Exceptions Are caught in the catch block InputMismatchException StringIndexOutOfBoundsException ArithmeticException 20

Week 05 if statement Execute code based on a condition The condition evaluates to true/false if (condition) { // Execute when true } else { // Execute when false } 21

Week 05 (cont.) if statement What if you wanted to do additional tests? if (condition1) { // When condition1 is true } else { if (condition2) { // When condition1 is false and // condition2 is true } else { // When condition1 is false and // condition2 is false } } 22

Trace Through int x = 0; int a = 6; int b = 5; if (a > 0) { if (b < 0) { x = x + 2; } else { if (a > 5) { x = x + 8; } else { x = x + 1; } } } else { x = x + 3; } What is the value of x? 8 23

Week 05 (cont.) Switch case When you have discrete possibilities Code will "fall through" if there is no break switch (value) { case 0: break; default: break; } 24

Week 05 (cont.) Short circuit evaluations && and && has a higher precedence than 25

Week 06 More on comparisons with equality Equality for PDT use == Equality for objects use.equals Two objects that are.equals may not be == If two objects are ==, they are.equals. Why? Objects point to a place in memory that has the value PDT is a box that stores the value Object is a box that points to another box that stores the value 27

Week 06 (cont.) Random Number Generation (RNG) Need to import java.util.random; Methods.nextDouble().nextInt().nextInt(int n) 28

Good Luck! 29