Chapter 6: Transition to Java

Similar documents
Handout 1. Introduction to Java programming language. Java primitive types and operations. Reading keyboard Input using class Scanner.

java.util.scanner Here are some of the many features of Scanner objects. Some Features of java.util.scanner

CS 106 Introduction to Computer Science I

How To Write A Program In Java (Programming) On A Microsoft Macbook Or Ipad (For Pc) Or Ipa (For Mac) (For Microsoft) (Programmer) (Or Mac) Or Macbook (For

J a v a Quiz (Unit 3, Test 0 Practice)

Introduction to Java

Object-Oriented Design Lecture 4 CSU 370 Fall 2007 (Pucella) Tuesday, Sep 18, 2007

Java Crash Course Part I

Crash Course in Java

CS 111 Classes I 1. Software Organization View to this point:

Variables, Constants, and Data Types

Free Java textbook available online. Introduction to the Java programming language. Compilation. A simple java program

CS 141: Introduction to (Java) Programming: Exam 1 Jenny Orr Willamette University Fall 2013

Free Java textbook available online. Introduction to the Java programming language. Compilation. A simple java program

TECHNOLOGY Computer Programming II Grade: 9-12 Standard 2: Technology and Society Interaction

Chapter 6: Programming Languages

Java Interview Questions and Answers

JAVA - QUICK GUIDE. Java SE is freely available from the link Download Java. So you download a version based on your operating system.

Sources: On the Web: Slides will be available on:

Basic Java Constructs and Data Types Nuts and Bolts. Looking into Specific Differences and Enhancements in Java compared to C

Introduction to Java Lecture Notes. Ryan Dougherty

AP Computer Science Java Subset

Chapter 1 Java Program Design and Development

Java Programming Fundamentals

Java Application Developer Certificate Program Competencies

Contents. 9-1 Copyright (c) N. Afshartous

Java CPD (I) Frans Coenen Department of Computer Science

Java Cheatsheet. Tim Coppieters Laure Philips Elisa Gonzalez Boix

java Features Version April 19, 2013 by Thorsten Kracht

Fundamentals of Java Programming

Introduction to Java. CS 3: Computer Programming in Java

Problem 1. CS 61b Summer 2005 Homework #2 Due July 5th at the beginning of class

core. Volume I - Fundamentals Seventh Edition Sun Microsystems Press A Prentice Hall Title ULB Darmstadt

Embedded Systems. Review of ANSI C Topics. A Review of ANSI C and Considerations for Embedded C Programming. Basic features of C

Part I. Multiple Choice Questions (2 points each):

Moving from CS 61A Scheme to CS 61B Java

Computer Programming I

The C Programming Language course syllabus associate level

Topics. Introduction. Java History CS 146. Introduction to Programming and Algorithms Module 1. Module Objectives

CS1020 Data Structures and Algorithms I Lecture Note #1. Introduction to Java

Chapter 2 Introduction to Java programming

The programming language C. sws1 1

Java Basics: Data Types, Variables, and Loops

First Java Programs. V. Paúl Pauca. CSC 111D Fall, Department of Computer Science Wake Forest University. Introduction to Computer Science

1.00 Lecture 1. Course information Course staff (TA, instructor names on syllabus/faq): 2 instructors, 4 TAs, 2 Lab TAs, graders

RARITAN VALLEY COMMUNITY COLLEGE ACADEMIC COURSE OUTLINE. CISY 105 Foundations of Computer Science

Wilson Area School District Planned Course Guide

CS506 Web Design and Development Solved Online Quiz No. 01

Chapter 1 Fundamentals of Java Programming

Thomas Jefferson High School for Science and Technology Program of Studies Foundations of Computer Science. Unit of Study / Textbook Correlation

Cohort: BCA/07B/PT - BCA/06/PT - BCNS/06/FT - BCNS/05/FT - BIS/06/FT - BIS/05/FT - BSE/05/FT - BSE/04/PT-BSE/06/FT

CMPT 183 Foundations of Computer Science I

Summit Public Schools Summit, New Jersey Grade Level / Content Area: Mathematics Length of Course: 1 Academic Year Curriculum: AP Computer Science A

Pemrograman Dasar. Basic Elements Of Java

Basic Programming and PC Skills: Basic Programming and PC Skills:

Topics. Parts of a Java Program. Topics (2) CS 146. Introduction To Computers And Java Chapter Objectives To understand:

Java from a C perspective. Plan

Debugging. Common Semantic Errors ESE112. Java Library. It is highly unlikely that you will write code that will work on the first go

Class 16: Function Parameters and Polymorphism

Java Programming Language

#820 Computer Programming 1A

Explain the relationship between a class and an object. Which is general and which is specific?

VB.NET Programming Fundamentals

Translating to Java. Translation. Input. Many Level Translations. read, get, input, ask, request. Requirements Design Algorithm Java Machine Language

ARIZONA CTE CAREER PREPARATION STANDARDS & MEASUREMENT CRITERIA SOFTWARE DEVELOPMENT,

McGraw-Hill The McGraw-Hill Companies, Inc.,

Java (12 Weeks) Introduction to Java Programming Language

Programming Languages CIS 443

Tutorial on Writing Modular Programs in Scala

C++FA 5.1 PRACTICE MID-TERM EXAM

Java Types and Enums. Nathaniel Osgood MIT April 25, 2012

ECE 122. Engineering Problem Solving with Java

Java Interfaces. Recall: A List Interface. Another Java Interface Example. Interface Notes. Why an interface construct? Interfaces & Java Types

Implementation Aspects of OO-Languages

CSE 1223: Introduction to Computer Programming in Java Chapter 2 Java Fundamentals

An Incomplete C++ Primer. University of Wyoming MA 5310

Practical Session 4 Java Collections

The Java Series. Java Essentials I What is Java? Basic Language Constructs. Java Essentials I. What is Java?. Basic Language Constructs Slide 1

High-Level Programming Languages. Nell Dale & John Lewis (adaptation by Michael Goldwasser)

Programming and Software Development CTAG Alignments

AP Computer Science AB Syllabus 1

Tutorial on C Language Programming

UIL Computer Science for Dummies by Jake Warren and works from Mr. Fleming

Computer Programming I

Introduction to Java Applications Pearson Education, Inc. All rights reserved.

Java the UML Way: Integrating Object-Oriented Design and Programming

Scanner. It takes input and splits it into a sequence of tokens. A token is a group of characters which form some unit.

JDK 1.5 Updates for Introduction to Java Programming with SUN ONE Studio 4

Short Introduction to the Concepts of Programming in Java Overview over the most important constructs

Name: Class: Date: 9. The compiler ignores all comments they are there strictly for the convenience of anyone reading the program.

Object Oriented Software Design

Software Engineering Techniques

Facebook Twitter YouTube Google Plus Website

WRITING DATA TO A BINARY FILE

The Sun Certified Associate for the Java Platform, Standard Edition, Exam Version 1.0

Java Programming. Binnur Kurt Istanbul Technical University Computer Engineering Department. Java Programming. Version 0.0.

Instruction Set Architecture (ISA)

Lecture 5: Java Fundamentals III

CSC 551: Web Programming. Fall 2001

CS346: Database Programming.

Transcription:

Chapter 6: Transition to Java Programming with Alice and Java First Edition by John Lewis and Peter DePasquale Edited/Modified by Nicole Tobias

Objectives Compare the concepts you saw in Alice to their counterparts in Java Learn about program development environments for Java Access the Java API support library and its online documentation Explore several Java program examples Practice using various Java statements 1-2 6-2

Focus Prior to now Creating worlds in Alice Animations were made of objects objects were created from classes Objects have methods Calling them makes the object behave in specific ways Objects also have properties We can set and change these as needed These concepts also apply in Java! 1-3 1-3

Java Features Java is a general-purpose programming language. Java has control statements for making decisions and repetition that are similar to the ones in Alice. Java classes are organized into packages, rather than galleries, and imported as needed. Inheritance is used to derive new classes from existing classes. 1-4 6-4

Java Features Objects are created dynamically during program execution. Methods and properties are defined in classes. Programs must be compiled before they can be executed. A Java compiler reports syntax errors. 1-5 1-5

Java Program Development There are many development environments that can be used to test Java programs. jgrasp Eclipse Java development environments use text-based editing. Source code is translated into Java bytecode by a compiler. A program may contain syntax errors, which compilers catch, and logic errors, which it will not. 1-6 6-6

Program Error Types There are three main types of errors you will encounter 1. Compile-time errors Found at compile-time Issued if a program breaks the language s syntax rules 2. Run-time errors Found when your program is running Occur when your program attempts an operation that is impossible to carry out 3. Logic errors Prevent your program from doing what you intended it to Code may compile and run without error, but result is not what you expected 1-7 6-7

Classes and Objects An object in Java is created using a programming statement: A class constructor uses a new operator to create an object. The constructor has the same name as the class. Often it also takes parameters to define initial values of certain properties of the object. 1-8 6-8

Classes and Objects in Java Creating objects dynamically Swarm of bees In Alice, create all bee objects separately In Java, use a loop over the statement that creates the object Create objects at any time in the program All methods and properties are defined to be part of a class Any object created from that class can use them Extensive library of predefined classes 1-9 6-9

Classes and Objects Java classes are organized into packages. You import the class you wish to use Java API (application programming interface) is a library of predefined classes. (Let s have a look at it) Child class can be derived from parent class, and it automatically inherits the methods and properties of the parent. (go to page104) Car ex 1-10 1-10

Data Types in Java Both Alice and Java are strongly typed languages. Each variable in Java must be declared before being used. Variable declaration establishes the particular data type. Eight primitive data types built into the language are: integers: byte short int long floating point numbers: float double character data type: char Boolean data type: boolean Objects are created from a class, which is another data type. 1-11 6-11

Operators in Java and Alice 1-12 6-12

Java Statements The assignment statement: **Show what you cannot do. The print statement uses two methods, print and println: System.out.println( The result is + total); (see p105) The if-else statement: total = total + 25; if (height > 69) height = height / 2; else System.out.println( Current height: + height); A main method is the default starting point in every Java program. 1-13 6-13

Summary You can use one of several development environments to create Java programs. Java code is compiled and translated into byte code before it is executed. A program may contain syntax errors, which will be caught by compiler. Logic errors cannot be caught by a compiler. A constructor is used to set up a newly created object. The Java API is a library of classes that we can use in any Java program. Encapsulation: the concept that each object should manage its own data and prevent explicit external modifications. The tostring method is called automatically when an object is printed. 1-14 6-14