1 Sections 3.1 – 3.2a Basic Syntax and Semantics Fundamentals of Java: AP Computer Science Essentials, 4th Edition Lambert / Osborne.

Slides:



Advertisements
Similar presentations
© 2007 Lawrenceville Press Slide 1 Assignment Statement An assignment statement gives a value to a variable. Assignment can take several forms: x = 5;
Advertisements

Chapter 8 Improving the User Interface
Java Programming, 3e Concepts and Techniques Chapter 3 Section 63 – Manipulating Data Using Methods – Day 2.
Chapter 3 Syntax, Errors, and Debugging
Types and Arithmetic Operators
Slide 1 Chapter 4 Assignment Statement An assignment statement gives a value to a variable. Assignment can take several forms: x = 5; a literal (5) is.
Chapter 10 Introduction to Arrays
An Introduction to Programming with C++ Fifth Edition Chapter 4 Chapter 4: Variables, Constants, and Arithmetic Operators.
Python Programming Chapter 2: Variables, expressions, and statements Saad Bani Mohammad Department of Computer Science Al al-Bayt University 1 st 2011/2012.
An Introduction to Programming with C++ Fifth Edition Chapter 4 Chapter 4: Variables, Constants, and Arithmetic Operators.
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Adrian Ilie COMP 14 Introduction to Programming Adrian Ilie June 27, 2005.
JavaScript, Fourth Edition
JavaScript, Third Edition
Computer Science: A Structured Programming Approach Using C1 Objectives ❏ To understand the structure of a C-language program. ❏ To write your first C.
1 MATERI PENDUKUNG OPERATOR Matakuliah: M0074/PROGRAMMING II Tahun: 2005 Versi: 1/0.
Hello, world! Dissect HelloWorld.java Compile it Run it.
Basic Elements of C++ Chapter 2.
Identifiers and Assignment Statements. Data structures In any programming language you need to refer to data The simplest way is with the actual data.
Introduction to Java Appendix A. Appendix A: Introduction to Java2 Chapter Objectives To understand the essentials of object-oriented programming in Java.
Programming Logic and Design Sixth Edition Chapter 2 Working with Data, Creating Modules, and Designing High-Quality Programs.
Chapter 2: Basic Elements of Java J ava P rogramming: From Problem Analysis to Program Design, From Problem Analysis to Program Design, Second Edition.
Chapter 2 Overview of C Part I J. H. Wang ( 王正豪 ), Ph. D. Assistant Professor Dept. Computer Science and Information Engineering National Taipei University.
DEPARTMENT OF COMPUTER SCIENCE & TECHNOLOGY FACULTY OF SCIENCE & TECHNOLOGY UNIVERSITY OF UWA WELLASSA 1 CST 221 OBJECT ORIENTED PROGRAMMING(OOP) ( 2 CREDITS.
Chapter 3: Data Types and Operators JavaScript - Introductory.
Chapter 2 Basic Elements of Java. Chapter Objectives Become familiar with the basic components of a Java program, including methods, special symbols,
Chapter 4 Variables and Constants. Goals and Objectives 1. Understand simple data types (int, boolean, double). 2. Declare and initialize variables using.
Chapter 3 Syntax, Errors, and Debugging Fundamentals of Java.
Computer Programming TCP1224 Chapter 4 Variables, Constants, and Arithmetic Operators.
CHAPTER 4: CONTROL STRUCTURES - SEQUENCING 10/14/2014 PROBLEM SOLVING & ALGORITHM (DCT 1123)
Java Programming: From Problem Analysis to Program Design, 4e Chapter 2 Basic Elements of Java.
Copyright 2008 by Pearson Education 1 Building Java Programs Chapter 2 Lecture 2-1: Expressions and Variables reading:
1 Chapter 3 Syntax, Errors, and Debugging Fundamentals of Java: AP Computer Science Essentials, 4th Edition Lambert / Osborne.
Chapter 3 Syntax, Errors, and Debugging Fundamentals of Java.
Java Programming, Second Edition Chapter Two Using Data Within a Program.
Component 4: Introduction to Information and Computer Science Unit 5: Overview of Programming Languages, Including Basic Programming Concepts Lecture 3.
Copyright 2010 by Pearson Education 1 Building Java Programs Chapter 2 Lecture 2-1: Expressions and Variables reading:
© 2005 Lawrenceville Press Slide 1 Chapter 4 Assignment Statement An assignment statement gives a value to a variable. Assignment can take several forms:
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley STARTING OUT WITH Python Python First Edition by Tony Gaddis Chapter 2 Input,
CHAPTER 2 PROBLEM SOLVING USING C++ 1 C++ Programming PEG200/Saidatul Rahah.
End of the beginning Let’s wrap up some details and be sure we are all on the same page Good way to make friends and be popular.
Java Programming: From Problem Analysis to Program Design, Second Edition 1 Lecture 1 Objectives  Become familiar with the basic components of a Java.
Variables and Constants Chapter 4 Review. Declaring Variables A variable is a name for a value stored in memory. Variables and constants are used in programs.
Chapter 4: Variables, Constants, and Arithmetic Operators Introduction to Programming with C++ Fourth Edition.
Chapter 4 Chapter 4: Variables, Constants, and Arithmetic Operators.
3.1 Language Elements Language elements: Vocabulary: The words and symbols in the language. Syntax: The rules for combining words into statements. Semantics:
1 Sections 6.4 – 6.5 Methods and Variables Fundamentals of Java: AP Computer Science Essentials, 4th Edition Lambert / Osborne.
1 Section 11.4 Java Interfaces – The Implementation Perspective Fundamentals of Java: AP Computer Science Essentials, 4th Edition Lambert / Osborne.
1 Sections 7.2 – 7.7 Nested Control Statements Fundamentals of Java: AP Computer Science Essentials, 4th Edition Lambert / Osborne.
1 Section 3.2b Arithmetic Operators Fundamentals of Java: AP Computer Science Essentials, 4th Edition Lambert / Osborne.
1 Sections 3.3 – 3.4 Terminal I/O and Comments Fundamentals of Java: AP Computer Science Essentials, 4th Edition Lambert / Osborne.
Information and Computer Sciences University of Hawaii, Manoa
Sections 10.1 – 10.4 Introduction to Arrays
Sections Inheritance and Abstract Classes
Chapter 4 Assignment Statement
Chapter 3 Syntax, Errors, and Debugging
Section 7.1 Logical Operators
Fundamentals of Java: AP Computer Science Essentials, 4th Edition
Basic Elements of C++.
Section 11.1 Class Variables and Methods
JavaScript.
Section 3.2c Strings and Method Signatures
Java Programming: From Problem Analysis to Program Design, 4e
Basic Elements of C++ Chapter 2.
Building Java Programs Chapter 2
Introduction to C++ Programming
Chapter 2: Basic Elements of Java
Programming Funamental slides
Chapter 2 Programming Basics.
Understand the interaction between computer hardware and software
An Introduction to Programming with C++ Fifth Edition
Presentation transcript:

1 Sections 3.1 – 3.2a Basic Syntax and Semantics Fundamentals of Java: AP Computer Science Essentials, 4th Edition Lambert / Osborne

Chapter Language Elements Programming and natural languages share three elements. – Vocabulary: Words and symbols – Syntax: Rules for combining statements. Use of operators, parentheses, etc. – Semantics: Rules for interpreting statements. Order of precedence

Chapter Language Elements (continued) Programming Vs. Natural Languages: Programming and natural languages have three differences. – Size: small vocabulary, simple syntax. – Rigidity: Syntax must be absolutely correct. – Literalness: Computers follow exact instructions. It is difficult to express complex ideas using limited syntax and semantics of programming languages.

Chapter Basic Java Syntax and Semantics Data Types: Primitive: numbers, characters, booleans Objects: scanners, strings, and more Syntax: Syntax differs for objects and primitive data. – Primitive: data types are combined in expressions with operators (addition, multiplication) – Objects: sent messages, must be instantiated before use

Chapter Basic Java Syntax and Semantics (continued) Numbers: Numeric data types: – Most programs input numeric data, perform calculations, output numeric results. – Java includes six numeric data types but we use two:

Chapter Basic Java Syntax and Semantics (continued) Literals: Literals are items in a program whose values do not change. – Restricted to primitive data types and strings. Examples of numeric literals

Chapter Basic Java Syntax and Semantics (continued) Variables and Their Declarations: Variables are items whose values can change during execution. Changing the value of a variable

Chapter Basic Java Syntax and Semantics (continued) Variables and Their Declarations (cont): Before using a variable, the program must declare its type. – Variable declaration statement – Type on left; variable name on right – Several variables and values can be in the same statement.

Chapter Basic Java Syntax and Semantics (continued) Variables and Their Declarations (cont): Instantiation creates objects. Constants are variables that, once initialized, cannot change.

Chapter 3 10