University of Central Florida COP 3330 Object Oriented Programming

Slides:



Advertisements
Similar presentations
Chapter 1: Computer Systems
Advertisements

Programming with Java. Problem Solving The purpose of writing a program is to solve a problem The general steps in problem solving are: –Understand the.
C++ Basics Variables, Identifiers, Assignments, Input/Output.
IntroductionIntroduction  Computer program: an ordered sequence of statements whose objective is to accomplish a task.  Programming: process of planning.
The Java Programming Language
Outline Java program structure Basic program elements
COMP 14: Intro. to Intro. to Programming May 23, 2000 Nick Vallidis.
Copyright 2013 by Pearson Education Building Java Programs Chapter 1 Lecture 1-1: Introduction; Basic Java Programs reading:
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Java Software Solutions Foundations of Program Design Sixth Edition by Lewis.
Programming Principles Data types and Variables. Data types Variables are nothing but reserved memory locations to store values. This means that when.
JAVA PROGRAMMING PART II.
Prepared by Uzma Hashmi Instructor Information Uzma Hashmi Office: B# 7/ R# address: Group Addresses Post message:
University of Limerick1 Work with API’s. University of Limerick2 Learning OO programming u Learning a programming language can be broadly split into two.
COMPUTER PROGRAMMING. Data Types “Hello world” program Does it do a useful work? Writing several lines of code. Compiling the program. Executing the program.
1 Identifiers  Identifiers are the words a programmer uses in a program  An identifier can be made up of letters, digits, the underscore character (
Java Language and SW Dev’t
System development with Java Lecture 2. Rina Errors A program can have three types of errors: Syntax and semantic errors – called.
Introduction to Programming David Goldschmidt, Ph.D. Computer Science The College of Saint Rose Java Fundamentals (Comments, Variables, etc.)
The Java Programming Language
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.
C Derived Languages C is the base upon which many build C++ conventions also influence others *SmallTalk is where most OOP comes Java and Javascript have.
Hello.java Program Output 1 public class Hello { 2 public static void main( String [] args ) 3 { 4 System.out.println( “Hello!" ); 5 } // end method main.
Chapter 2: Java Fundamentals
Methods in Java. Program Modules in Java  Java programs are written by combining new methods and classes with predefined methods in the Java Application.
Page: 1 การโปรแกรมเชิงวัตถุด้วยภาษา JAVA บุรินทร์ รุจจนพันธุ์.. ปรับปรุง 15 มิถุนายน 2552 Keyword & Data Type มหาวิทยาลัยเนชั่น.
Java The Java programming language was created by Sun Microsystems, Inc. It was introduced in 1995 and it's popularity has grown quickly since A programming.
SE-1010 Dr. Mark L. Hornick 1 Variables & Datatypes.
Copyright Curt Hill Variables What are they? Why do we need them?
Java Language Basics By Keywords Keywords of Java are given below – abstract continue for new switch assert *** default goto * package.
 In the java programming language, a keyword is one of 50 reserved words which have a predefined meaning in the language; because of this,
What Is a Package? A package is a namespace that organizes a set of related classes and interfaces. Conceptually you can think of packages as being similar.
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 Variables:-
JAVA Programming (Session 2) “When you are willing to make sacrifices for a great cause, you will never be alone.” Instructor: รัฐภูมิ เถื่อนถนอม
© 2011 Pearson Education, publishing as Addison-Wesley Chapter 1: Computer Systems Presentation slides for Java Software Solutions for AP* Computer Science.
Introduction to Java Programming by Laurie Murphy Revised 09/08/2016.
Copyright 2010 by Pearson Education APCS Building Java Programs Chapter 1 Lecture 1-1: Introduction; Basic Java Programs reading:
1 Problem Solving  The purpose of writing a program is to solve a problem  The general steps in problem solving are: Understand the problem Dissect the.
Variables, Identifiers, Assignments, Input/Output
JAVA MULTIPLE CHOICE QUESTION.
Working with Java.
Chapter 4 Assignment Statement
Lecture 2: Data Types, Variables, Operators, and Expressions
CSE 190D, Winter 2013 Building Java Programs Chapter 1
CS180 – Week 1 Lecture 3: Foundation Ismail abumuhfouz.
Variables and Arithmetic Operators in JavaScript
Selenium WebDriver Web Test Tool Training
Chapter 3 Assignment Statement
CMSC 104, Section 4 Richard Chang
Starting JavaProgramming
null, true, and false are also reserved.
Introduction to Java Programming
An overview of Java, Data types and variables
Instructor: Alexander Stoytchev
Chapter 1: Computer Systems
Variables, Identifiers, Assignments, Input/Output
Chapter 2: Java Fundamentals
Units with – James tedder
Units with – James tedder
JavaScript Reserved Words
Focus of the Course Object-Oriented Software Development
Module 2 - Part 1 Variables, Assignment, and Data Types
Programming Language C Language.
CSE 142, Spring 2012 Building Java Programs Chapter 1
Instructor: Alexander Stoytchev
Zorah Fung University of Washington, Spring 2015
Chap 2. Identifiers, Keywords, and Types
CSE 142, Winter 2014 Building Java Programs Chapter 1
Agenda Types and identifiers Practice Assignment Keywords in Java
Zorah Fung University of Washington, Winter 2016
Presentation transcript:

University of Central Florida COP 3330 Object Oriented Programming

Agenda Variables

Variables

Variables Instance Variables (Non-Static Fields) Objects store their individual states in non-static fields (i.e. fields declared without keyword static) Non-static fields are also known as instance variables because their values are unique to each instance of a class (to each object, in other words)

Variables Class Variables (Static Fields) A class variable is any field declared with the static modifier Keyword static tells the compiler that there is exactly one copy of this variable in existence, regardless of how many times the class has been instantiated. Example: the field defining the number of gears for a particular kind of bicycle could be marked as static since conceptually the same number of gears will apply to all instances. static int numGears = 6;  the keyword final could be added to indicate that the number of gears will never change.

Variables Local Variables Similar to how an object stores its state in fields, a method will often store its temporary state in local variables. The syntax for declaring a local variable is similar to declaring a field int count = 0; No special keyword designating a variable as local A local variable is based on the variable being declared between the opening and closing braces of a method. Local variables are only visible to the methods in which they are declared; Local variables are not accessible from the rest of the class

Variables Parameters The signature for the main method is public static void main(String[] args) the args variable is the parameter to this method Parameters are always classified as "variables" not "fields". This applies to other parameter-accepting constructs as well Constructors Exception handlers

Variables Naming Variable names are case-sensitive. Can be any legal identifier unlimited-length sequence of Unicode letters and digits beginning with a letter, the dollar sign "$", or the underscore character "_" The convention is to always begin your variable names with a letter, not "$" or "_". The dollar sign character, by convention, is never used at all The underscore character is technically legal, though is discouraged White space is not permitted

Variables Naming Subsequent characters may be letters Digits dollar signs underscore characters Use full words instead of cryptic abbreviations Makes code easier to read and understand May make code self-documenting must not be a keyword or reserved word.  

Keywords and Reserved Words abstract continue for new switch assert*** default goto* package synchronized boolean do if private this break double implements protected throw byte else import public throws case enum**** instanceof return transient catch extends int short try char final interface static void class finally long strictfp** volatile const* float native super while

Variables Naming Single word variables Multi-word variables spell that word in all lowercase letters Multi-word variables capitalize the first letter of each subsequent word (i.e. camel casing) Variables that store a constant value Capitalize every letter separate subsequent words with the underscore character. static final int NUM_GEARS = 6,