SCU - Introduction to OO Program Design Software College of...

Info iconThis preview shows pages 1–15. Sign up to view the full content.

View Full Document Right Arrow Icon
Introduction to OO Program Design Software College of SCU Instructor: Shu Li Email: shuli@scu.edu.cn
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
2 Unit 1. Class Design Unit 1.1 Java Applications 1.1.1 Applications in Java
Background image of page 2
3 1. Java Basic JAVA source code is first written in plain text files ending with the .java extension. Those source files are then compiled into .class files by the Java compiler ( javac ). A .class file does not contain code that is native to your processor; it instead contains bytecode s ( o ) -- the machine language of the Java Virtual Machine. The Java launcher tool ( java ) then runs your application with an instance of the Java Virtual Machine.
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
4 JAVA Technology
Background image of page 4
5 Platform-Independent
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
6 The Java Platform The Java platform is a software-only platform that runs on top of other hardware-based platforms. The Java platform has two components: The Java Virtual Machine The Java Application Programming Interface (API)
Background image of page 6
7 Java Virtual Machine JVM is a crucial component of the Java Platform. A Java Virtual Machine (JVM) enables a set of computer software programs and data structures to use a virtual machine model for the execution of other computer programs and scripts. The JVM, which is the instance of the 'JRE' ( Java Runtime Environment ), comes into action when a Java program is executed. When execution is complete, this instance is garbage collected .
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
8 Difference between Java and C Java is derived from C Many of its syntactic characteristics are similar to C However, there are some huge differences
Background image of page 8
9 Expressions Arithmetic operators are the same:– +, –, *, /, %, ++, –– Numerical type conversion is mostly the same Java spells out divide by zero, NaN (not a number, etc.) C & C++ are machine dependent Check the textbooks for details
Background image of page 9

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
10 Relational Operators Relational operators work the same way but return different results: >, >=, <, <=, ==, != In Java, they return values FALSE and TRUE In C/C++, they return values 0 and 1 In C/C++, a value of zero means false any value that is not zero means true E.g., 1, 5, -1000000, 3.14159, 6.626068 × 10 -34 Very important!
Background image of page 10
11 Conditional and Bitwise Operators Conditional execution operators are same in Java and C/C++:– ||, &&, ! Bitwise operators are same in Java and C/C++:– |, &, ^ for bit-by-bit operations with a word Shift operators differ a little bit << (left shift) is the same >> (right shift) is machine dependent in C/C++ I.e., whether to fill from left with zeros or sign bits
Background image of page 11

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
12 Assignment and Unary Operators Assignment operators work the same:– =, +=, -=, *=, /=, &=, |=, ^= The following unary operators are available C/C++ but not in Java ~ invert the bits of a word * pointer dereference & pointer creation sizeof # of bytes in operand or data type -> pointer dereference with field selection There is no pointer in Java.
Background image of page 12
13 Statements Statements in C/C++:– Labeled statement ( o ) Expression statement( % _ ) Compound statement( o o ) Selection statement( o ) Iteration statement( o ) Jump statement( o )
Background image of page 13

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
14 Statements Statements in C/C++:– Labeled statement Expression statement
Background image of page 14
Image of page 15
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 48

SCU - Introduction to OO Program Design Software College of...

This preview shows document pages 1 - 15. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online