EECS1710. Checklist from last lecture (Sept 9, 2014) " get an EECS account (if you don t have it already) " read sections

Similar documents
What we are reinforcing with the exercises this class

EECS1710. Announcements. Labtests have been returned Term Test #01 marking is in progress. Next Labtest: Thu Oct 23/Fri Oct 24

Checklist (for Today) What we are reinforcing with the exercises this class. recognizing the various different arithmetic operators (in situ)

Object-oriented programming. and data-structures CS/ENGRD 2110 SUMMER 2018

Objectives for this class meeting. 1. Conduct review of core concepts concerning contracts and pre/post conditions

PROGRAMMING FUNDAMENTALS

data_type variable_name = value; Here value is optional because in java, you can declare the variable first and then later assign the value to it.

Programming by Delegation

Computational Expression

Review for Test 1 (Chapter 1-5)

VARIABLES AND TYPES CITS1001

CS 11 java track: lecture 1

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

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

Computing Science 114 Solutions to Midterm Examination Tuesday October 19, In Questions 1 20, Circle EXACTLY ONE choice as the best answer

An overview of Java, Data types and variables

About this exam review

Introduction to Programming (Java) 2/12

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

Building Java Programs

Object Oriented Programming and Design in Java. Session 2 Instructor: Bert Huang

Building Java Programs

Programming with Java

EECS1710. Announcements. epost updated, please check online Next Labtest: Thu Oct 23/Fri Oct 24. Next Term Test: Tue Oct 28.

Computer Science is...

Program Fundamentals

Chapters 1-4 Summary. Syntax - Java or C? Syntax - Java or C?

1 Lexical Considerations

Reminder the scope of a variable is the part of the program where that variable is visible Will this compile?

CS453 Compiler Construction

4. An interpreter is a program that

Recitation 3 Class and Objects

Java Identifiers, Data Types & Variables

Section 2.2 Your First Program in Java: Printing a Line of Text

Chapter 6 Classes and Objects

Pace University. Fundamental Concepts of CS121 1

(A) 99 ** (B) 100 (C) 101 (D) 100 initial integers plus any additional integers required during program execution

CS-140 Fall 2017 Test 1 Version Practice Practie for Sept. 27, Name:

Lecture Set 2: Starting Java

CS/ENGRD 2110 FALL Lecture 2: Objects and classes in Java

CMPS 134: Computer Science I Fall 2011 Test #1 October 5 Name Dr. McCloskey

Lecture Set 2: Starting Java

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

QUIZ Lesson 4. Exercise 4: Write an if statement that assigns the value of x to the variable y if x is in between 1 and 20, otherwise y is unchanged.

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

Lexical Considerations

1 class Lecture2 { 2 3 "Elementray Programming" / References 8 [1] Ch. 2 in YDL 9 [2] Ch. 2 and 3 in Sharan 10 [3] Ch.

Full file at

Announcements. 1. Forms to return today after class:

Computer Programming, I. Laboratory Manual. Final Exam Solution

Java How to Program, 10/e. Copyright by Pearson Education, Inc. All Rights Reserved.

CS/ENGRD 2110 SPRING Lecture 2: Objects and classes in Java

Chapter 5 Methods. public class FirstMethod { public static void main(string[] args) { double x= -2.0, y; for (int i = 1; i <= 5; i++ ) { y = f( x );

CS-140 Fall 2017 Test 1 Version Practice Practie for Sept. 27, Name:

Following is the general form of a typical decision making structure found in most of the programming languages:

Lexical Considerations

H212 Introduction to Software Systems Honors

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

Praktische Softwaretechnologie

COMP-202: Foundations of Programming. Lecture 26: Review; Wrap-Up Jackie Cheung, Winter 2016

Operational Semantics. One-Slide Summary. Lecture Outline

(A) 99 (B) 100 (C) 101 (D) 100 initial integers plus any additional integers required during program execution

Selected Questions from by Nageshwara Rao

CS 231 Data Structures and Algorithms, Fall 2016

Lecture 9. Assignment. Logical Operations. Logical Operations - Motivation 2/8/18

CS/ENGRD 2110 SPRING Lecture 2: Objects and classes in Java

Building Java Programs

CS Programming I: Primitives and Expressions

false, import, new 1 class Lecture2 { 2 3 "Data types, Variables, and Operators" 4

Values and Variables 1 / 30

Constants. Why Use Constants? main Method Arguments. CS256 Computer Science I Kevin Sahr, PhD. Lecture 25: Miscellaneous

Introduction to Java. Java Programs Classes, Methods, and Statements Comments Strings Escape Sequences Identifiers Keywords

Administration. Classes. Objects Part II. Agenda. Review: Object References. Object Aliases. CS 99 Summer 2000 Michael Clarkson Lecture 7

Result: original lp in main is. Goal was.

Lecture 8 Classes and Objects Part 2. MIT AITI June 15th, 2005

Project Compiler. CS031 TA Help Session November 28, 2011

CSC324 Principles of Programming Languages

CISC-124. Dog.java looks like this. I have added some explanatory comments in the code, and more explanation after the code listing.

Assertions, pre/postconditions

COMP 202 Java in one week

CS 360 Programming Languages Interpreters

CSE1720 Delegation Concepts (Ch 2)

Building Java Programs Chapter 2

Introduction to Java

Materials covered in this lecture are: A. Completing Ch. 2 Objectives: Example of 6 steps (RCMACT) for solving a problem.

printf( Please enter another number: ); scanf( %d, &num2);

Midterms Save the Dates!

Math Modeling in Java: An S-I Compartment Model

CSE 374 Programming Concepts & Tools

Assumptions. History

Operational Semantics of Cool

CS 177 Recitation. Week 1 Intro to Java

Java Loop Control. Programming languages provide various control structures that allow for more complicated execution paths.

Methods Summer 2010 Margaret Reid-Miller

Introduction to Java

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

CSE Lecture 24 Review and Recap. High-Level Overview of the Course!! L1-7: I. Programming Basics!

COMP-202: Foundations of Programming. Lecture 4: Flow Control Loops Sandeep Manjanna, Summer 2015

Example: Monte Carlo Simulation 1

CSE 142, Summer 2015

Transcription:

EECS1710 Click to edit Master Week text 01, styles Lecture 02 Second level Third level Fourth level Fifth level Fall 2014! Thursday, Sept 11, 2014 1 Checklist from last lecture (Sept 9, 2014) " get an EECS account (if you don t have it already) warning!! it can take up to 24 hours to get the account. Plan ahead. " read sections 1.1-1.2. " review Ch 1 Key Concepts (KC) 1-13 " do Review Questions (RQ) 1-17 " do Exercises (Ex) 1.1-1.16 " get the Lecture 02 class materials (by Wed noon) 2 1

Checklist for this lecture (Sept 11, 2014) By the end of this lecture, you should " be able to identify the components of a program ( 1.1.1) " being able to recognize the significance of coding style " be able to identify the language elements within a program ( 1.1.2) " be able to describe the edit-compile-run process ( 1.1.3) " distinguish between a java file and a class file, distinguish between byte code and machine code, understand how all of this relates to the architecture of the computer platform 3 Checklist for this lecture (Sept 11, 2014) By the end of this lecture, you should " be able to construct a declaration statement ( 1.2.1) " be able to list Java s primitive types and describe the key issues in data representation ( 1.2.2, 1.2.4) " understand some of the significant differences between primitive and non-primitive values ( 1.2.3, 1.2.5) 4 2

Identifying Program Components Identify the preamble, class header, class body within this simple program. import java.util.date; public class Lect02Ex01 { public static void main(string[] args) { int thevalue = 89; // this app doesn't do very much // it declares a variable, assigns a value, and then stops! 5 Identifying Program Components Identify the preamble, class header, class body within this simple program. import java.io.printstream; public class Area {public static void main(string[] args) {PrintStream output;output = System. out;int width;width = 8;int height = 3;int area = width * height;output.println(area); 6 3

Identifying Program Components Identify the preamble, class header, class body within this simple program. Identify the method header, method body within the class body. package samplepkg; import java.io.printstream; public class Lect02Ex02 { public static void main(string[] args) { int thevalue = 89; // this app doesn't do very much // it declares a variable, assigns a value, and then stops! 7 Anatomy of a Java class Identify the method header, method body within the class body. package samplepkg; import java.io.printstream; public class Lect02Ex03 { public static void main(string[] args) { int thevalue = 89; // this app doesn't do very much // it declares a variable, assigns a value, and then stops! public void mymethod() { int someothervalue = 9; 8 4

The concept of scope SUPER VERY IMPORTANT 1.2, p.16 Notice that the identified thevalue occurs twice. How many variables are being declared and what is the scope of use? package samplepkg; public class Lect02Ex04 { public static void main(string[] args) { int thevalue = 89; public void mymethod() { int thevalue = 90; 9 Anatomy of Java RQ1. What is a package? How is a package different from a subpackage? 10 5

Illustration Here is how a package appears on the file system. 11 Anatomy of Java: Statements, Classify all statements in terms of (1) declaration, (2) assignment, combo declaration/assignment, (3) usage of other classes, (4) flow control, (5) other import java.lang.system; public class Area { public static void main(string[] args) { int width; width = 8; int height = 3; int area = width * height; System.out.println(area); JD 1.3 (p. 10) 12 6

Anatomy of Java: Variable Declaration RQ 6. What does strongly typed mean? Java is strongly typed. Other languages, such as Perl, are weakly typed. Strongly typed means: Weakly typed means: the identifier must be declared as a variable, but the type of the variable need not be declared in advance. Java enforces strong typing discipline so that the compiler can do a lot of checking before producing bytecode. 13 This results in code that has certain safety features (see sec 2.3.1) Anatomy of Java: Variable Declaration Why strong typing? the compiler can check and enforce type compatibility (for instance, if type compatibility is violated, the compiler will issue an error instead of producing bytecode) This results in code that has certain safety features (more on this in sec 2.3.1) 14 7

Lexical Elements Ex 1.7 (riff) In the statements below, identify each of the lexical elements: keywords, identifiers, literals, operators, separators. double balance = 34e3; boolean isvalid = false; long count = System.out.readLong(); booleanisvalid = `F`; String address = new String( Toronto ); number = Integer.parseInt(input); public static void main(string[] commmand) System.out.printf( %,.2f, amount) 15 Lexical Elements RQ.10. How do you know whether a word is a Java reserved word? RQ 13. Can you determine the type of each literal below? 34e3 false `F` Toronto 34.6 1L 2f 3e6f 16 16 8

Lexical Elements Analyse these tokens. Which tokens are literals and which are not? False `FX` 34.6 1.9L 1.233333333333333333333333333333333333399999999999 99999999999999999999999999999999999999999999999999 99999999999999999999999999999999999999999999999999 9999999999999999f 17 Edit-Compile-Run RQ 14. What is the difference between a source and a class file? 18 9

Syntax (and Semantic) Rules RQ.11. What are the syntactical rules for naming identifiers? ***What are the semantic rules for naming identifiers? 19 Coding Style RQ.12. What are the style guidelines for naming identifiers? What sorts of identifiers are there? 20 10

Primitive Types RQ.17. Name Java s primitive types. Why are they called primitive? Are there literal values for every primitive type in Java? 21 11