Object-Oriented Programming (OOP). Implementing an OOD in Java Each class is stored in a separate file. All files must be stored in the same package.

Slides:



Advertisements
Similar presentations
Arrays.
Advertisements

Pass by Value. COMP104 Pass by Value / Slide 2 Passing Parameters by Value * A function returns a single result (assuming the function is not a void function)
Java Programing PSC 120 Jeff Schank. Let’s Create a Java Program 1.Open Eclipse 2.Create a project: File -> New -> Java Project 3.Create a package: File.
INHERITANCE BASICS Reusability is achieved by INHERITANCE
Chapter 7 User-Defined Methods. Chapter Objectives  Understand how methods are used in Java programming  Learn about standard (predefined) methods and.
Objectives Learn about objects and reference variables Explore how to use predefined methods in a program.
Classes and Objects Systems Programming.
1 Chapter 7 User-Defined Methods Java Programming from Thomson Course Tech, adopted by kcluk.
Getting Started with Java
C++ data types. Structs vs. Classes C++ Classes.
Class template Describing a generic class Instantiating classes that are type- specific version of this generic class Also are called parameterized types.
Introduction to Classes and Objects CS-2303, C-Term Introduction to Classes and Objects CS-2303 System Programming Concepts (Slides include materials.
Week 3 Recap CSE 115 – Spring Constructor Special capability of a class that sets up the initial state of the object. Constructor definitions are.
TCU CoSc Introduction to Programming (with Java) Getting to Know Java.
Introduction To Object-Oriented Programming. Object-Oriented Programming Class: Code that defines the behavior of a Java programming element called an.
CSM-Java Programming-I Spring,2005 Introduction to Objects and Classes Lesson - 1.
ITEC 320 Lecture 16 Packages (1). Review Questions? –HW –Exam Nested records –Benefits –Downsides.
Java Class Syntax CSIS 3701: Advanced Object Oriented Programming.
By Nicholas Policelli An Introduction to Java. Basic Program Structure public class ClassName { public static void main(String[] args) { program statements.
CIS 3301 C# Lesson 5 Methods. CIS 3302 Objectives Understand the structure of a method. Know the difference between static and instance methods. Learn.
Chapter 7 Objects and Classes 1 Fall 2012 CS2302: Programming Principles.
Array in C++ / review. An array contains multiple objects of identical types stored sequentially in memory. The individual objects in an array, referred.
1 Chapter 8 – Classes and Object: A Deeper Look Outline 1 Introduction 2 Implementing a Time Abstract Data Type with a Class 3 Class Scope 4 Controlling.
ADTs and C++ Classes Classes and Members Constructors The header file and the implementation file Classes and Parameters Operator Overloading.
Java™ How to Program, 10/e © Copyright by Pearson Education, Inc. All Rights Reserved.
An Object-Oriented Approach to Programming Logic and Design Chapter 3 Using Methods and Parameters.
DEPARTMENT OF COMPUTER SCIENCE & TECHNOLOGY FACULTY OF SCIENCE & TECHNOLOGY UNIVERSITY OF UWA WELLASSA ‏ Visibility Control.
Object Oriented Programming (OOP) Lecture No. 11.
CSC241 Object-Oriented Programming (OOP) Lecture No. 6.
Procedural Programming Criteria: P2 Task: 1.2 Thomas Jazwinski.
Identifiers Identifiers in Java are composed of a series of letters and digits where the first character must be a letter. –Identifiers should help to.
Programming with Java © 2002 The McGraw-Hill Companies, Inc. All rights reserved. 1 McGraw-Hill/Irwin Chapter 5 Creating Classes.
Copyright © 2002 W. A. Tucker1 Chapter 10 Lecture Notes Bill Tucker Austin Community College COSC 1315.
1 Chapter 5: Defining Classes. 2 Basics of Classes An object is a member of a class type What is a class? Fields & Methods Types of variables: –Instance:
MCQ Which is the correct syntax for placing the string "boat" into an ArrayList name recVehicles in position 3 (index 2) for the first time? a)recVehicles.set(3,
نظام المحاضرات الالكترونينظام المحاضرات الالكتروني Introduction to Object Oriented Programming (OOP) Object Oriented programming is method of programming.
AP Java Ch. 4 Review Question 1  Java methods can return only primitive types (int, double, boolean, etc).
Class Everything in Java is in a class. The class has a constructor that creates the object. If you do not supply a constructor Java will create a default.
An Introduction to Programming with C++ Fifth Edition Chapter 14 Classes and Objects.
Programming Fundamentals1 Chapter 7 INTRODUCTION TO CLASSES.
1 Sections 6.4 – 6.5 Methods and Variables Fundamentals of Java: AP Computer Science Essentials, 4th Edition Lambert / Osborne.
Introduction to Classes and Objects CS-2303, C-Term C++ Program Structure Typical C++ Programs consist of:– main –A function main –One or more classes.
Inheritance a subclass extends the functionality of a superclass a subclass inherits all the functionality of a superclass don't reinvent the wheel – "stand.
TK1924 Program Design & Problem Solving Session 2011/2012
Test 2 Review Outline.
Chapter 7 User-Defined Methods.
Haidong Xue Summer 2011, at GSU
Class Definitions and Writing Methods
CompSci 230 Software Construction
Introduction to Object-oriented Program Design
Using local variable without initialization is an error.
Chapter 4 Procedural Methods.
Inner Classes 11/14/ Dec-04 inner_classes.ppt.
2011/11/10: Lecture 21 CMSC 104, Section 4 Richard Chang
Interface.
An Introduction to Java – Part II
Object-oriented Design in Processing
Unit-1 Introduction to Java
Interfaces.
More On Enumeration Types
Implementing Classes Chapter 3.
Object-oriented Design in Processing
Chapter 7 Procedural Methods.
Object-oriented Design in Processing
Topics discussed in this section:
Unit-1 Introduction to Java
Abstract Data Types Abstraction is to distill a system to its most fundamental parts. Applying the abstraction paradigm to the design of data structures.
Object-oriented Design in Processing
CSG2H3 Object Oriented Programming
Introduction to Classes and Objects
Presentation transcript:

Object-Oriented Programming (OOP)

Implementing an OOD in Java Each class is stored in a separate file. All files must be stored in the same package. This is achieved by creating a project. Each project will have a driver class which uses the different classes. The main method is in the driver class.

Creating a Class File The name of the Java source file will correspond to the name of the class. Data elements of the class are declared using the same format as that used to declare variables. Syntax: accessibility type name; The operations are defined as methods.

Methods Syntax: modifiers type name (parameters) {variable declarations; statements; } If the type is void a method does not return a value. In the case of any other type the method must return a value of that type.

Example