Advanced Programming Collage of Information Technology University of Palestine, Gaza Prepared by: Mahmoud Rafeek Alfarra Lecture 2: Major Concepts of Programming.

Slides:



Advertisements
Similar presentations
 Control structures  Algorithm & flowchart  If statements  While statements.
Advertisements

INSTRUCTOR: SHIH-SHINH HUANG Windows Programming Using Java Chapter4: Control Statements Part I.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Chapter 4 – C Program Control Outline 4.1Introduction.
 2006 Pearson Education, Inc. All rights reserved Control Statements: Part 2.
Repetition Statements repeat block of code until a condition is satisfied also called loops Java supports 3 kinds of loops: while statement – repeats a.
Introduction to Computers and Programming Lecture 5 Boolean type; if statement Professor: Evan Korth New York University.
Slides prepared by Rose Williams, Binghamton University Chapter 3 Flow of Control Loops in Java.
CS1061: C Programming Lecture 8: Repetition A. O’Riordan, 2004.
Loops Repetition Statements. Repetition statements allow us to execute a statement multiple times Often they are referred to as loops Like conditional.
Chapter 2 - Java Programming Fundamentals1 Chapter 2 Java Programming Fundamentals.
ECE122 L9: While loops March 1, 2007 ECE 122 Engineering Problem Solving with Java Lecture 9 While Loops.
C How to Program, 6/e Summary © by Pearson Education, Inc. All Rights Reserved.
CS0007: Introduction to Computer Programming Introduction to Arrays.
© The McGraw-Hill Companies, 2006 Chapter 1 The first step.
CC0002NI – Computer Programming Computer Programming Er. Saroj Sharan Regmi Week 7.
DAT602 Database Application Development Lecture 5 JAVA Review.
Chapter 5: Control Structures II (Repetition)
EGR 2261 Unit 5 Control Structures II: Repetition  Read Malik, Chapter 5.  Homework #5 and Lab #5 due next week.  Quiz next week.
Fundamentals of C and C++ Programming Control Structures and Functions.
Control Structures Session 03 Mata kuliah: M0874 – Programming II Tahun: 2010.
Programming language A programming language is an artificial language designed to communicate instructions to a machine,languageinstructionsmachine particularly.
INTRODUCTION TO JAVA CHAPTER 1 1. WHAT IS JAVA ? Java is a programming language and computing platform first released by Sun Microsystems in The.
Sadegh Aliakbary Sharif University of Technology Fall 2012.
ASP.NET Programming with C# and SQL Server First Edition Chapter 3 Using Functions, Methods, and Control Structures.
Lecture 4 C Program Control Acknowledgment The notes are adapted from those provided by Deitel & Associates, Inc. and Pearson Education Inc.
Chapter 8 High-Level Programming Languages. 8-2 Chapter Goals Describe the translation process and distinguish between assembly, compilation, interpretation,
Programming in Java Unit 4. Learning outcome:  LO2: Be able to design Java solutions  LO3: Be able to implement Java solutions Assessment criteria:
Chapter 5: Control Structures II (Repetition). Objectives In this chapter, you will: – Learn about repetition (looping) control structures – Learn how.
Group 4 Java Compiler Group Members: Atul Singh(Y6127) Manish Agrawal(Y6241) Mayank Sachan(Y6253) Sudeept Sinha(Y6483)
COMPUTER PROGRAMMING. Iteration structures (loops) There may be a situation when you need to execute a block of code several number of times. In general,
CMPSC 16 Problem Solving with Computers I Spring 2014 Instructor: Lucas Bang Lecture 5: Introduction to C: More Control Flow.
1 Chap 4. Data Should know Declare & Initialize variables Declare constants Assignment Operators Increment and Decrement Operators Precedence of Operators.
Chapter 3 Functions, Events, and Control Structures JavaScript, Third Edition.
Introduction to Java Java Translation Program Structure
Using Java MINISTRY OF EDUCATION & HIGHER EDUCATION COLLEGE OF SCIENCE AND TECHNOLOGY KHANYOUNIS- PALESTINE Lecture 9 & 10 Repetition Statements.
 In computer programming, a loop is a sequence of instruction s that is continually repeated until a certain condition is reached.  PHP Loops :  In.
Selection statements Repetition statements. Lesson plan Main concepts Practice session –If- then –Switch –Nested if.
UMass Lowell Computer Science Java and Distributed Computing Prof. Karen Daniels Fall, 2000 Lecture 8 Java Fundamentals Control Structures Fri.
Chapter 1 Java Programming Review. Introduction Java is platform-independent, meaning that you can write a program once and run it anywhere. Java programs.
Repetition Statements (Loops). 2 Introduction to Loops We all know that much of the work a computer does is repeated many times. When a program repeats.
Lecture1 Instructor: Amal Hussain ALshardy. Introduce students to the basics of writing software programs including variables, types, arrays, control.
COMP Loop Statements Yi Hong May 21, 2015.
LECTURE # 8 : REPETITION STATEMENTS By Mr. Ali Edan.
Chapter 7: Repetition Structure (Loop) Department of Computer Science Foundation Year Program Umm Alqura University, Makkah Computer Programming Skills.
Programming Language C++ Lecture 3. Control Structures  C++ provides control structures that serve to specify what has to be done to perform our program.
JAVA Programming (Session 2) “When you are willing to make sacrifices for a great cause, you will never be alone.” Instructor: รัฐภูมิ เถื่อนถนอม
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.
C Program Control September 15, OBJECTIVES The essentials of counter-controlled repetition. To use the for and do...while repetition statements.
Introduction to 1. What is Java ? Sun Microsystems Java is a programming language and computing platform first released by Sun Microsystems in The.
JAVA TRAINING IN NOIDA. JAVA Java is a general-purpose computer programming language that is concurrent, class-based, object-oriented and specifically.
 It is a pure oops language and a high level language.  It was developed at sun microsystems by James Gosling.
Chapter 4 – C Program Control
Before You Begin Nahla Abuel-ola /WIT.
GC101 Introduction to computer and program
Lecture 1: Introduction to JAVA
Lecture 6 Repetition Richard Gesick.
CiS 260: App Dev I Chapter 4: Control Structures II.
Java Programming: Guided Learning with Early Objects
Chapter 4 – Control Structures Part 1
Arrays, For loop While loop Do while loop
Programming Fundamentals Lecture #6 Program Control
MSIS 655 Advanced Business Applications Programming
Outline Altering flow of control Boolean expressions
MSIS 655 Advanced Business Applications Programming
Introduction To Programming Information Technology , 1’st Semester
3 Control Statements:.
(Computer fundamental Lab)
PROGRAM FLOWCHART Iteration Statements.
Review of Java Fundamentals
Presentation transcript:

Advanced Programming Collage of Information Technology University of Palestine, Gaza Prepared by: Mahmoud Rafeek Alfarra Lecture 2: Major Concepts of Programming

2 Outlines Java: Overview  Java: Overview  Java Virtual Machine (JVM)  The Java runtime environment  Variables Types  Statements  Selection  Iteration  Garbage collection

3 Overview  Java is a programming language originally developed by Sun Microsystems and released in 1995 as a core component of Sun Microsystems' Java platform.  The language derives much of its syntax from C and C++ but has a simpler object model and fewer low-level facilities.  Java applications are typically compiled to bytecode that can run on any Java virtual machine (JVM) regardless of computer architecture.

4 Java Virtual Machine (JVM)  A Java Virtual Machine (JVM) is a set of computer software programs and data structures which use a virtual machine model for the execution of other computer programs and scripts.  JVMs operate on Java bytecode, which is normally (but not necessarily) generated from Java source code; a JVM can also be used to implement programming languages other than Java.

5 Java Virtual Machine (JVM)  One characteristic of Java is platform independence, which means that programs written in the Java language must run similarly on any supported hardware/operating-system platform. One should be able to write a program once, compile it once, and run it anywhere.

6 The Java runtime environment

7 Variables Types  Java data types fall into two categories. Primitive types 1. Primitive types represent simple values that have built-in functionality in the language; they are fixed elements, such as literal constants and numbers. Reference types 2. Reference types (or class types) include objects and arrays; they are called reference types because they "refer to" a large data type which is passed "by reference," as we'll explain shortly.

8 Primitive Types  Numbers, characters, and Boolean values are fundamental elements in Java.

9 Primitive Types  Variable declaration and initialization: 1 2 3

10 Reference Types  Complex data types (user defined) from simple primitives by creating a class. Each class then serves as a new type in the language.  For example,  if we create a new class called Foo in Java,  A new type called Foo is created.  The type of an item governs how it's used and where it can be assigned.

11 Statements  Statements and expressions in Java appear within a code block. Statements Selection Iteration Sequential

12 Selection  The if structure  Causes the program to make a selection  Chooses based on conditional  Any expression that evaluates to a bool type  True: perform an action  False: skip the action  Single entry/exit point  Require no semicolon in syntax print “Passed” Grade >= 60 true false

13 Selection Grade >= 60 print “Passed”print “Failed” falsetrue Another types, study them

14 Selection

15 Iteration  Repetition Structure  An action is to be repeated  Continues while statement is true  Ends when statement is false  Contain either a line or a body of code  Must alter conditional  Endless loop

16 Iteration  while Repetition Structure true false Product = 2 * product Product <= 1000

17 Iteration true false action(s) condition do/while Repetition Structure

18 Iteration counter++ Establish initial value of control variable. Determine if final value of control variable has been reached. counter <= 10 Console.WriteLine ( counter * 10 ); true false int counter = 1 Body of loop (this may be multiple statements) Increment the control variable. For Repetition Structure

19 Garbage collection  Java uses an automatic garbage collector to manage memory in the object lifecycle.  The programmer determines when objects are created, and the Java runtime is responsible for recovering the memory once objects are no longer in use.  Once no references to an object remain, the unreachable object becomes eligible to be freed automatically by the garbage collector.

20 Next Lecture isa Arrays and Concepts of OOP