Download presentation
Presentation is loading. Please wait.
Published byNorah Carpenter Modified over 9 years ago
1
Advanced Programming Collage of Information Technology University of Palestine, Gaza Prepared by: Mahmoud Rafeek Alfarra Lecture 2: Major Concepts of Programming
2
2 Outlines Java: Overview Java: Overview Java Virtual Machine (JVM) The Java runtime environment Variables Types Statements Selection Iteration Garbage collection
3
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
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
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
6 The Java runtime environment
7
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
8 Primitive Types Numbers, characters, and Boolean values are fundamental elements in Java.
9
9 Primitive Types Variable declaration and initialization: 1 2 3
10
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
11 Statements Statements and expressions in Java appear within a code block. Statements Selection Iteration Sequential
12
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
13 Selection Grade >= 60 print “Passed”print “Failed” falsetrue Another types, study them
14
14 Selection
15
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
16 Iteration while Repetition Structure true false Product = 2 * product Product <= 1000
17
17 Iteration true false action(s) condition do/while Repetition Structure
18
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
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
20 Next Lecture isa Arrays and Concepts of OOP
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.