Objects as a programming concept

Slides:



Advertisements
Similar presentations
STRING AN EXAMPLE OF REFERENCE DATA TYPE. 2 Primitive Data Types  The eight Java primitive data types are:  byte  short  int  long  float  double.
Advertisements

Core Java Lecture 4-5. What We Will Cover Today What Are Methods Scope and Life Time of Variables Command Line Arguments Use of static keyword in Java.
Written by: Dr. JJ Shepherd
Java Basics M Taimoor Khan
OBJECT-ORIENTED PROGRAMMING CONCEPTS (Review). What is an Object? What is an Object? Objects have states and behaviors. Example: A dog has states - color,
George Blank University Lecturer. CS 602 Java and the Web Object Oriented Software Development Using Java Chapter 4.
Road Map Introduction to object oriented programming. Classes
Evan Korth New York University Computer Science I Classes and Objects Professor: Evan Korth New York University.
Terms and Rules Professor Evan Korth New York University (All rights reserved)
1 Fall 2007ACS-1903 Chapter 6: Classes Classes and Objects Instance Fields and Methods Constructors Overloading of Methods and Constructors Scope of Instance.
1 Chapter 8 Objects and Classes. 2 Motivations After learning the preceding chapters, you are capable of solving many programming problems using selections,
CSM-Java Programming-I Spring,2005 Introduction to Objects and Classes Lesson - 1.
Introduction to Object Oriented Programming. Object Oriented Programming Technique used to develop programs revolving around the real world entities In.
CSC 212 Object-Oriented Programming and Java Part 1.
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.
An Introduction to Java Chapter 11 Object-Oriented Application Development: Part I.
The Java Programming Language
Spring 2008 Mark Fontenot CSE 1341 Principles of Computer Science I Note Set 2.
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.
Review of ICS 102. Lecture Objectives To review the major topics covered in ICS 102 course Refresh the memory and get ready for the new adventure of ICS.
Objects, Classes and Syntax Dr. Andrew Wallace PhD BEng(hons) EurIng
An Object-Oriented Approach to Programming Logic and Design Chapter 3 Using Methods and Parameters.
Applications Development
Programs and Classes A program is made up from classes Classes may be grouped into packages A class has two parts static parts exist independently Non-static.
Chapter 10 Defining Classes. The Internal Structure of Classes and Objects Object – collection of data and operations, in which the data can be accessed.
BEGINNING PROGRAMMING.  Literally – giving instructions to a computer so that it does what you want  Practically – using a programming language (such.
Copyright Curt Hill Variables What are they? Why do we need them?
 In the java programming language, a keyword is one of 50 reserved words which have a predefined meaning in the language; because of this,
Java Classes Chapter 1. 2 Chapter Contents Objects and Classes Using Methods in a Java Class References and Aliases Arguments and Parameters Defining.
CSI 3125, Preliminaries, page 1 Data Type, Variables.
Quick Review of OOP Constructs Classes:  Data types for structured data and behavior  fields and methods Objects:  Variables whose data type is a class.
Written by: Dr. JJ Shepherd
 Variables are nothing but reserved memory locations to store values. This means that when you create a variable you reserve some space in memory. 
Java Programming, Second Edition Chapter Three Using Methods, Classes, and Objects.
JAVA Programming (Session 2) “When you are willing to make sacrifices for a great cause, you will never be alone.” Instructor: รัฐภูมิ เถื่อนถนอม
Object and Classes อ. ยืนยง กันทะเนตร คณะเทคโนโลยีสารสนเทศและการสื่อสาร มหาวิทยาลัยพะเยา Chapter 3.
UMass Lowell Computer Science Java and Distributed Computing Prof. Karen Daniels Fall, 2000 Lecture 10 Java Fundamentals Objects/ClassesMethods.
Geoff Holmes and Bernhard Pfahringer COMP206-08S General Programming 2.
Methods, classes, and Objects Dr. Jim Burns. Question  Which of the following access modifiers is the default modifier?  public  private  protected.
Copyright © Texas Education Agency, Computer Programming Variables and Data Types.
Topics introduced today (these topics would be covered in more detail in later classes) – Primitive Data types Variables Methods “for” loop “if-else” statement.
Topic: Classes and Objects
OOP: Encapsulation &Abstraction
JAVA MULTIPLE CHOICE QUESTION.
Objects as a programming concept
Understand the Fundamentals of Classes
Objects as a programming concept
Objects as a programming concept
Lecture 5: Some more Java!
Yanal Alahmad Java Workshop Yanal Alahmad
Internet and Java Foundations, Programming and Practice
Chapter 3: Using Methods, Classes, and Objects
Selenium WebDriver Web Test Tool Training
University of Central Florida COP 3330 Object Oriented Programming
Java Review Hello..This ppt is to give you an introduction about java and why it is soo special The segments all discussed here are the crucial parts of.
Road Map Introduction to object oriented programming. Classes
Programming Language Concepts (CIS 635)
Methods The real power of an object-oriented programming language takes place when you start to manipulate objects. A method defines an action that allows.
An overview of Java, Data types and variables
The Building Blocks Classes: Java class library, over 1,800 classes:
Encapsulation and Constructors
Sridhar Narayan Java Basics Sridhar Narayan
Programs and Classes A program is made up from classes
Object-Oriented Programming
Instance Method – CSC142 Computer Science II
Java Programming Language
Java Basics Data Types in Java.
Chap 2. Identifiers, Keywords, and Types
CS 1054: Lecture 2, Chapter 1 Objects and Classes.
Presentation transcript:

Objects as a programming concept IB Computer Science

HL Topics 1-7, D1-4 1: System design 2: Computer Organisation 3: Networks 4: Computational thinking 5: Abstract data structures 6: Resource management 7: Control D: OOP

HL & SL D.3 Overview 1: System design 2: Computer Organisation 3: Networks D.3 Program development D.3.1 Define the terms: class, identifier, primitive, instance variable, parameter variable, local variable D.3.2 Define the terms: method, accessor, mutator, constructor, signature, return value D.3.3 Define the terms: private, protected, public, extends, static D.3.4 Describe the uses of the primitive data types and the reference class string D.3.5 Construct code to implement assessment statements D.3.6 Construct code examples related to selection statements D.3.7 Construct code examples related to repetition statements D.3.8 Construct code examples related to static arrays D.3.9 Discuss the features of modern programming languages that enable internationalization D.3.10 Discuss the ethical and moral obligations of programmers 4: Computational thinking 5: Abstract data structures 6: Resource management 7: Control D: OOP

Topic D.3.1 Define the terms: class, identifier, primitive, instance variable, parameter variable, local variable

Object Orientated Programming (OOP) All objects have a state and behaviour. If we consider a dog, the its state is - name, breed, colour, and the behavio is - barking, wagging, running Software objects also have a state and behaviour. A software object's state is stored in fields and behaviour is shown via methods. n ur

object & class class Student private String name; private int age; { //constructor } public setStudent(String n) name = n; Object - Objects have states and behaviours. Example: A dog has states - colour, name, breed as well as behaviours -wagging, barking, eating. An object is an instance of a class. Class - A class can be defined as a template/blue print that describes the behaviours/states that object of its type support. }

identifier public readStudentName() { An identifier is a pointer that explicitly identifies an object, class, interface, method, or variable. It allows a programmer to refer to the item from other places in the program. To make the most out of the identifiers you choose make them meaningful and follow the standard Java naming conventions. public readStudentName() { System.out.println(“Enter student name”); String answer = kb.nextLine(); }

identifier (rules)

primitive (data type) char byte short int long float double boolean Primitive Type Size Minimum Value Maximum Value char 16-bit Unicode 0 Unicode 216-1 byte 8-bit -128 +127 short -215 (-32,768) +215-1 (32,767) int 32-bit -231 (-2,147,483,648) +231-1 (2,147,483,647) long 64-bit -263 (-9,223,372,036,854,775,808) +263-1 (9,223,372,036,854,775,807) float 32-bit IEEE 754 floating-point numbers double 64-bit IEEE 754 floating-point numbers boolean 1-bit true or false

variable (in general) A variable provides us with named storage that our programs can manipulate. They must be declared before they can be used. int a, b, c; // Declares three ints, a, b, and c. int a = 10, b = 10; // Example of initialization byte B = 22; // initializes a byte type variable B. double pi = 3.14159; // declares and assigns a value of PI. char a = 'a'; // the char variable a is given value 'a'

3 Variable types instance variable: A variable in a class from which every instantiated object gets its own copy. If a class called people would have an instance variable called age, every object of this class would have its own variable called age. parameter variable: A variable that is passed along to a function that is called to perform operations with. In Java it is the argument passed in the brackets with the function caller. local variable: A variable declared inside a function. This variable is only known and accessible by the function it is declared inside.

instance variable (global) class Student private String name; private int age; Student() { //constructor } public setStudent(String n) Instance variables are declared inside a class, but outside a method, constructor or any block name = n; }

local variable Local variables are declared inside methods, constructors, or blocks public readStudentName() { System.out.println(“Enter student name”); String answer = kb.nextLine(); }

parameter variable Variable that is declared inside the brackets of a method. It only exists in that method. public setDogType(String n) { //something }