Advanced Programming Behnam Hatami Fall 2017.

Slides:



Advertisements
Similar presentations
Programming Languages and Paradigms
Advertisements

Assembly Language for Intel-Based Computers, 4 th Edition Chapter 1: Basic Concepts (c) Pearson Education, All rights reserved. You may modify and.
Expression Evaluation, Scope, Parameter Passing, Data Organization, Program Control, Binding By Ramon Quiusky CS 490 Fall 2003.
CHAPTER 1: AN OVERVIEW OF COMPUTERS AND LOGIC. Objectives 2  Understand computer components and operations  Describe the steps involved in the programming.
 2005 Pearson Education, Inc. All rights reserved Introduction.
CS241 PASCAL I - Control Structures1 PASCAL I - Control Structures Philip Fees CS241.
1 Chapter 4 Simple Selections and Repetitions INTRODUCTION The majority of challenging and interesting algorithms necessitate the ability to make.
Hello, world! Dissect HelloWorld.java Compile it Run it.
Principles of Procedural Programming
Sadegh Aliakbary Sharif University of Technology Fall 2011.
Sadegh Aliakbary. Copyright ©2014 JAVACUP.IRJAVACUP.IR All rights reserved. Redistribution of JAVACUP contents is not prohibited if JAVACUP.
Sadegh Aliakbary Sharif University of Technology Fall 2012.
“Introduction to Programming With Java”
Sadegh Aliakbary Sharif University of Technology Spring 2011.
Introduction to Java Appendix A. Appendix A: Introduction to Java2 Chapter Objectives To understand the essentials of object-oriented programming in Java.
Chapter 2 How to Compile and Execute a Simple Program.
Advanced Java New York University School of Continuing and Professional Studies.
Sadegh Aliakbary Sharif University of Technology Spring 2011.
 Value, Variable and Data Type  Type Conversion  Arithmetic Expression Evaluation  Scope of variable.
Sadegh Aliakbary. Copyright ©2014 JAVACUP.IRJAVACUP.IR All rights reserved. Redistribution of JAVACUP contents is not prohibited if JAVACUP.
Sadegh Aliakbary Sharif University of Technology Fall 2010.
DEPARTMENT OF COMPUTER SCIENCE & TECHNOLOGY FACULTY OF SCIENCE & TECHNOLOGY UNIVERSITY OF UWA WELLASSA 1 CST 221 OBJECT ORIENTED PROGRAMMING(OOP) ( 2 CREDITS.
Welcome to the Lecture Series on “Introduction to Programming With Java”
Sadegh Aliakbary Sharif University of Technology Fall 2012.
Advanced Programming Collage of Information Technology University of Palestine, Gaza Prepared by: Mahmoud Rafeek Alfarra Lecture 2: Major Concepts of Programming.
Introduction to Computer Systems and the Java Programming Language.
Salman Marvasti Sharif University of Technology Fall 2014.
JAVA 0. HAFTA Algorithms FOURTH EDITION Robert Sedgewick and Kevin Wayne Princeton University.
David Streader Computer Science Victoria University of Wellington Copyright: David Streader, Victoria University of Wellington Java Programing Basics COMP.
 JAVA Compilation and Interpretation  JAVA Platform Independence  Building First JAVA Program  Escapes Sequences  Display text with printf  Data.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Chapter 2 Chapter 2 - Introduction to C Programming.
C++ Programming: Basic Elements of C++.
Sadegh Aliakbary. Copyright ©2014 JAVACUP.IRJAVACUP.IR All rights reserved. Redistribution of JAVACUP contents is not prohibited if JAVACUP.
Peyman Dodangeh Sharif University of Technology Spring 2014.
CompSci 100E 2.1 Java Basics - Expressions  Literals  A literal is a constant value also called a self-defining term  Possibilities: o Object: null,
Sadegh Aliakbary Sharif University of Technology Spring 2011.
Component 4: Introduction to Information and Computer Science Unit 5: Overview of Programming Languages, Including Basic Programming Concepts Lecture 3.
CS241 PASCAL I - Control Structures1 PASCAL Control Structures Modified Slides of Philip Fees.
Introduction Mehdi Einali Advanced Programming in Java 1.
“Hello World” In Java Mehdi Einali Advanced Programming in Java 1.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Chapter 2 - Introduction to C Programming Outline.
C Part 1 Computer Organization I 1 August 2009 © McQuain, Feng & Ribbens A History Lesson Development of language by Dennis Ritchie at Bell.
Mid-Year Review. Coding Problems In general, solve the coding problems by doing it piece by piece. Makes it easier to think about Break parts of code.
“Hello World” In Java Mehdi Einali Advanced Programming in Java 1.
Review A program is… a set of instructions that tell a computer what to do. Programs can also be called… software. Hardware refers to… the physical components.
Objects and Memory Mehdi Einali Advanced Programming in Java 1.
1 Sections 3.1 – 3.2a Basic Syntax and Semantics Fundamentals of Java: AP Computer Science Essentials, 4th Edition Lambert / Osborne.
Bill Tucker Austin Community College COSC 1315
Test 2 Review Outline.
Programming what is C++
Programming Fundamental
C Short Overview Lembit Jürimägi.
Java Review: Reference Types
Advanced Programming Behnam Hatami Fall 2017.
Advanced Programming in Java
Advanced Programming Behnam Hatami Fall 2017.
Lecturer: Mukhtar Mohamed Ali “Hakaale”
Starting Out with Java: From Control Structures through Objects
Advanced Programming Fall 2017.
Chapter 2 Edited by JJ Shepherd
Advanced Programming Behnam Hatami Fall 2017.
Programming in JavaScript
Advanced Programming Behnam Hatami Fall 2017.
Chap 1 Chap 2 Chap 3 Chap 5 Surprise Me
Advanced Programming in Java
Chapter 2 Programming Basics.
Welcome to AP Computer Science A!
Peer Instruction 4 Control Loops.
Problem 1 Given n, calculate 2n
Presentation transcript:

Advanced Programming Behnam Hatami Fall 2017

Quiz How a problem written in java run in computer? Is a compiled java program runnable in other Operating systems?

Agenda Review First program in java Variables Methods Conditions Loops

Review Java is Java is platform independent. Write Once, Run Anywhere! Simple object oriented Robust And popular Java is platform independent. Write Once, Run Anywhere!

First Example Create a file named First.java Java class files have .java extension Note to naming convention Copy this lines to the file Note: File name and class name should be the same.

First Example (2) Run javac First.java Run java First We don’t use any IDE now. To highlight compile and run stages. Lets watch it in real world!

Overview of the Example JAVACUP.ir Contents redistribution is allowed if JAVACUP is noted as the source 7

Java Programs A simple java program is a file The file contains one class The class name equal to the file name The names are case sensitive The class contains a main method When we run the program, the main method is executed

Variables What is a variable? A piece of memory Holds data For example a number, string or Boolean Java variables have a fixed size Platform independence

Java Primitive Types

Arithmetic Operators

Operator Precedence 1 + 2 * 3 = ? is treated as 1 + (2 * 3)

Equality and Relational Operators

Operators

Operators

Associativity When two operators with the same precendence the expression is evaluated according to its associativity. x = y = z = 17 is treated as x = (y = (z = 17)) since the = operator has right-to-left associativty 72 / 2 / 3 is treated as (72 / 2) / 3 since the / operator has left-to-right associativity

A simple program

Methods A method is like a machine Zero or more inputs Zero or one output Other names Function Procedure method Inputs output

Example Return type Method name Parameters

Parameter Passing Local variables Java passes the parameters by value

Call by Value

Conditions

Conditions (2)

Loops while do-while for

While Loop

do-while Loop do-while loop is executed at least one time

for

For Loop vs. While Loop X; for (X; Y; Z) { while(Y){ body(); body(); }

For Loop vs. While Loop (2)

goto goto is a reserved word in java But forbidden!

References Java How to Program (9th Edition) Deitel & Deitel Thinking in Java (Fourth Edition) Bruce Eckel Java cup

Any Question