3.1 Documentation & Java Language Elements. 3.1.1 Purpose of documentation Assist the programmer with developing the program Assist other programers who.

Slides:



Advertisements
Similar presentations
Constants and Data Types Constants Data Types Reading for this class: L&L,
Advertisements

Road Map Introduction to object oriented programming. Classes
1 Chapter 4 Language Fundamentals. 2 Identifiers Program parts such as packages, classes, and class members have names, which are formally known as identifiers.
Declaring Variables You must first declare a variable before you can use it! Declaring involves: – Establishing the variable’s spot in memory – Specifying.
CMT Programming Software Applications
Variables, Data Types, & Arithmetic Expressions CSC 1401: Introduction to Programming with Java Lecture 3 Wanda M. Kunkle.
Fundamental Programming Structures in Java: Comments, Data Types, Variables, Assignments, Operators.
Applying OO Concepts Using Java. In this class, we will cover: Overriding a method Overloading a method Constructors Mutator and accessor methods The.
Introduction to Java Appendix A. Appendix A: Introduction to Java2 Chapter Objectives To understand the essentials of object-oriented programming in Java.
Introduction to Programming Prof. Rommel Anthony Palomino Department of Computer Science and Information Technology Spring 2011.
CSM-Java Programming-I Spring,2005 Introduction to Objects and Classes Lesson - 1.
1 Identifiers  Identifiers are the words a programmer uses in a program  An identifier can be made up of letters, digits, the underscore character (
CSCI 1100/1202 January 16, Why do we need variables? To store intermediate results in a long computation. To store a value that is used more than.
Programming in Java Unit 2. Class and variable declaration A class is best thought of as a template from which objects are created. You can create many.
By Nicholas Policelli An Introduction to Java. Basic Program Structure public class ClassName { public static void main(String[] args) { program statements.
11 Chapter 5 METHODS CONT’D. 22 MORE ON PASSING ARGUMENTS TO A METHOD Passing an Object Reference as an Argument to a Method Objects are passed by reference.
Introduction to Programming David Goldschmidt, Ph.D. Computer Science The College of Saint Rose Java Fundamentals (Comments, Variables, etc.)
The Java Programming Language
CSC204 – Programming I Lecture 4 August 28, 2002.
JAVA Tokens. Introduction A token is an individual element in a program. More than one token can appear in a single line separated by white spaces.
Classes CS 21a: Introduction to Computing I First Semester,
CPS120: Introduction to Computer Science
Lec 6 Data types. Variable: Its data object that is defined and named by the programmer explicitly in a program. Data Types: It’s a class of Dos together.
Java Syntax and Style JavaMethods An Introduction to Object-Oriented Programming Maria Litvin Gary Litvin Copyright © 2003 by Maria Litvin, Gary Litvin,
Using Data Within a Program Chapter 2.  Classes  Methods  Statements  Modifiers  Identifiers.
Vladimir Misic: Java1 Basic Java Syntax The java language will be described by working through its features: –Variable types and expressions.
Java™ How to Program, 10/e © Copyright by Pearson Education, Inc. All Rights Reserved.
Assignment An assignment statement changes the value of a variable The assignment operator is the = sign total = 55; Copyright © 2012 Pearson Education,
Copyright Curt Hill Variables What are they? Why do we need them?
Everything is an object (CH-2) Manipulating Objects with References. Manipulating Objects with References. String s; String s = “IS2550” String s = new.
COP INTERMEDIATE JAVA Designing Classes. Class Template or blueprint for creating objects. Their definition includes the list of properties (fields)
CSC 212 Object-Oriented Programming and Java Part 2.
Java Programming, Second Edition Chapter Two Using Data Within a Program.
 In the java programming language, a keyword is one of 50 reserved words which have a predefined meaning in the language; because of this,
Developed at Sun Microsystems in 1991 James Gosling, initially named “OAK” Formally announced java in 1995 Object oriented and cant write procedural.
Spring 2009 Programming Fundamentals I Java Programming XuanTung Hoang Lecture No. 8.
Quick Review of OOP Constructs Classes:  Data types for structured data and behavior  fields and methods Objects:  Variables whose data type is a class.
 Variables are nothing but reserved memory locations to store values. This means that when you create a variable you reserve some space in memory. 
In this class, we will cover: Overriding a method Overloading a method Constructors Mutator and accessor methods The import statement and using prewritten.
1 CSC 1111 Introduction to Computing using C++ C++ Basics (Part 1)
5.1 Basics of defining and using classes A review of class and object definitions A class is a template or blueprint for an object A class defines.
Java Basics. Tokens: 1.Keywords int test12 = 10, i; int TEst12 = 20; Int keyword is used to declare integer variables All Key words are lower case java.
JAVA Programming (Session 2) “When you are willing to make sacrifices for a great cause, you will never be alone.” Instructor: รัฐภูมิ เถื่อนถนอม
1 Lecture # 2. * Introducing Programming with an Example * Identifiers, Variables, and Constants * Primitive Data Types * Byte, short, int, long, float,
Java and C# - Some Commonalities Compile into machine-independent, language- independent code which runs in a managed execution environment Garbage Collection.
Chapter 2 Variables and Constants. Objectives Explain the different integer variable types used in C++. Declare, name, and initialize variables. Use character.
Information and Computer Sciences University of Hawaii, Manoa
More Sophisticated Behavior
JAVA MULTIPLE CHOICE QUESTION.
Working with Java.
Yanal Alahmad Java Workshop Yanal Alahmad
Java Primer 1: Types, Classes and Operators
Selenium WebDriver Web Test Tool Training
FUNDAMENTALS OF JAVA.
Chapter 3 Introduction to Classes, Objects Methods and Strings
Chapter 3 Introduction to Classes, Objects Methods and Strings
2.1 Parts of a C++ Program.
Introduction to Java Programming
An overview of Java, Data types and variables
Chapter 1: Computer Systems
Variables Numbers can be stored and retrieved while a program is running if they are given a home. The way that integers and decimal numbers are stored.
Chap 1 Chap 2 Chap 3 Chap 5 Surprise Me
Applying OO Concepts Using Java
Anatomy of a Java Program
Chapter 2: Introduction to C++.
Object Oriented Programming in java
Classes CS 21a: Introduction to Computing I
Chap 2. Identifiers, Keywords, and Types
Variables and Constants
Presentation transcript:

3.1 Documentation & Java Language Elements

3.1.1 Purpose of documentation Assist the programmer with developing the program Assist other programers who wish to use or modify the program

3.1.2 Guidelines for documenting classes Block comments – Start with /* and end with */. Can occupy multiple lines Single line comments – The line starts with //

3.1.3 The javadoc parameters The javadoc program can create HTML documents from the comments in the program’s source file To create javadoc comments, use /** and */ Special tags can be imbedded in etc

3.1.4 Java API documentation

3.1.5 Generating API docs for classes using the javadoc tool

3.2.2 Keywords Keywords form the Java vocabulary The compiler is case-sensitive

3.2.3 Identifiers Labels assigned to data or storage addresses Rules for identifiers: –Any alphabetic character –First character must be a letter –Cannot contain space, % or # –Cannot be keywords

3.2.4 Use of braces, semicolons, commas, and white space A block is a collection of statements bounded by braces { } A statement consists of one or more lines of code, followed by a semicolon ; Commas are used to delineate data Whitespace is used to separate keywords and identifiers

3.3.1 Data storage introduction Registers – Memory in the CPU The Stack – Memory for methods and local variables The Heap – Memory to store objects Static – Stores data that will not change during the life of the program Constant – Values that never change.

3.4.1 Java language types Data type is the classification of forms of information Data type is declared using keywords Java is strongly typed

3.4.2 Java primitives boolean – true or false char – Stores a single UNICODE character byte – Signed whole numbers from -127 to +128 short – Signed whole numbers from -32,768 to +32,767 int - Signed whole numbers from to long – Signed whole numbers from -9x10 18 to 9x float – Decimal values up to 6 – 7 decimal places double – Decimal values up to 14 – 15 decimal places

3.4.3 Java references Objects are created in heap memory Programs use a variable that references the object The program acts on the object by using the reference

3.4.4 Data Object Data – Instance of a class, stored on the heap Static Class Data – Available before the object is created Local Data – Exists in methods, stored on the stack Constants – Data that will not change Variables – Holds a primitive or a reference to an object

3.4.4 Data (example) public class Student { private final String studentName; public static final int courseNumber = 12345; public String grade; public Student(String name, String grd) { studentName = name; grade = grd; } public void changeGrade(String grd) { grade = grd; } public String getName() { return studentName; } Try to Identify!!!!! 1.Object Data/Variable 2.Static Data/Variable 3.Local Data/Variable 4.Constants

3.5.2 Elements Class – Template or blueprint for object creation Method – A block of statements that control an object’s behavior Constructor – A special method that is called when the object is created Modifiers – private, public, protected, default, static, final

constructormethod class Elements public class Student { private final String studentName; public static final int courseNumber = 12345; public String grade; public Student(String name, String grd) { studentName = name; grade = grd; } public void changeGrade(String grd) { grade = grd; } public String getName() { return studentName; }

3.6.1 Five steps of object creation Declaration of a reference variable Default initialization Explicit initialization Execution of the constructor Assignment of object’s address to reference variable

3.6.3 Mutability, Garbage Collection & Finalizers Most data is mutable, and can be changed. To make it immutable, use the final keyword Garbage collection frees up memory occupied by unused objects. This process cannot be controlled Every object inherits a finalizer method, that will be executed when the object is released

Individual activity & Lab Work Possible Lab Schedule every: –Monday, or –Friday, (PUSKOM-FTUI) TODO LIST (finished before next session): –Read through the online curriculum –Take the module exam 1 – 3 (Start: Thursday) –Do LABs: Insert Documentation for Classes in the JBANK Application Generate API Docs for JBANK Classes with the javadoc Tool Define Variables Apply Access Modifiers Use of Constructors Create the Classes for Phase I of the JBANK Application3.8.1 Note: Red bold color is obligatory to be submitted to ECourse System!