Elipses int... passed into method as int[]

Slides:



Advertisements
Similar presentations
Object Oriented Programming with Java
Advertisements

OO Programming in Java Objectives for today: Overriding the toString() method Polymorphism & Dynamic Binding Interfaces Packages and Class Path.
Department of Computer Engineering Faculty of Engineering, Prince of Songkla University 1 5 – Abstract Data Types.
1 Chapter 6: Extending classes and Inheritance. 2 Basics of Inheritance One of the basic objectives of Inheritance is code reuse If you want to extend.
Encapsulation, Inheritance & Interfaces CSE 115 Spring 2006 February 27, March 1 & 3, 2006.
Inner Classes. Inner classes All the classes so far have been “top level” It is possible (and useful) to define a class inside another class Inner classes.
Chapter 6 Class Inheritance F Superclasses and Subclasses F Keywords: super F Overriding methods F The Object Class F Modifiers: protected, final and abstract.
Lecture 3 Casting Abstract Classes and Methods Interfaces.
MIT AITI 2002 Abstract Classes, Interfaces. Abstract Classes What is an abstract class? An abstract class is a class in which one or more methods is declared,
Creating a class. Fields (instance variables) Fields are the data defined in the class and belonging to each instantiation (object). Fields can change.
Inner and Anonymous Classes Though you are captive in the OO paradigm, you can use inner classes and anonymous classes to get around this constraint and.
1 Object-Oriented Software Engineering CS Interfaces Interfaces are contracts Contracts between software groups Defines how software interacts with.
CSC 211 Introduction to Design Patterns. Intro to the course Syllabus About the textbook – Read the introduction and Chapter 1 Good attendance is the.
"If I can't picture it, I can't understand it.". Reference anonymous - gravity Concrete classes: rules of.
Exceptions: Checked versus Unchecked Exceptions.
APCS Java AB 2004 Review of CS1 and CS2 Review for AP test #1 Sources: 2003 Workshop notes from Chris Nevison (Colgate University) AP Study Guide to go.
Inheritance Dwight Deugo Nesa Matic
More on Hierarchies 1. When an object of a subclass is instantiated, is memory allocated for only the data members of the subclass or also for the members.
Creating a class. Fields (instance variables) Fields are the data defined in the class and belonging to each instantiation (object). Fields can change.
Copyright © Curt Hill Generic Classes Template Classes or Container Classes.
Objects & Dynamic Dispatch CSE 413 Autumn Plan We’ve learned a great deal about functional and object-oriented programming Now,  Look at semantics.
Programming in Java CSCI-2220 Object Oriented Programming.
Object Oriented Programming Examples: C++, Java Advantages: 1. reusibility of code 2. ability to adapt (extend) previously written code.
Inheritance A Review of Objects, Classes, and Subclasses.
Inheritance and Access Control CS 162 (Summer 2009)
Programming with Java © 2002 The McGraw-Hill Companies, Inc. All rights reserved. 1 McGraw-Hill/Irwin Chapter 5 Creating Classes.
MIT AITI 2004 – Lecture 13 Abstract Classes and Interfaces.
Chapter 7: Class Inheritance F Superclasses and Subclasses F Keywords: super and this F Overriding methods F The Object Class F Modifiers: protected, final.
Inheritance and Class Hierarchies Chapter 3. Chapter 3: Inheritance and Class Hierarchies2 Chapter Objectives To understand inheritance and how it facilitates.
Inheritance and Class Hierarchies Chapter 3. Chapter Objectives  To understand inheritance and how it facilitates code reuse  To understand how Java.
Inheritance Inheritance is the process of extending the functionality of a class by defining a new class that inherit,all the features of extending class.
1 C# - Inheritance and Polymorphism. 2 1.Inheritance 2.Implementing Inheritance in C# 3.Constructor calls in Inheritance 4.Protected Access Modifier 5.The.
Lec 06 Agenda 1/ the 8 rules of Java 2/ Casting primitives 3/ Swing and Threading 4/ Java Event Model. Event api and support for Swing 5/ Swing labs, live.
OOP Basics Classes & Methods (c) IDMS/SQL News
COP INTERMEDIATE JAVA Inheritance, Polymorphism, Interfaces.
UMass Lowell Computer Science Java and Distributed Computing Prof. Karen Daniels Fall, 2000 Lecture 10 Java Fundamentals Objects/ClassesMethods.
Java Programming: Guided Learning with Early Objects Chapter 9 Inheritance and Polymorphism.
Object Oriented Programming Some Interesting Genes.
Inner Classes.
Topic: Inner Classes Course : JAVA PROGRAMMING Paper Code: ETCS-307 Faculty : Dr. Prabhjot Kaur Reader, Dept. of IT 1.
Inner Classes 27-Dec-17.
Classes and OOP.
Lec 06 Agenda 1/ the 6 rules of Java
Inheritance and Polymorphism
Chapter 11 Object-Oriented Design
Java Programming Language
Generics, Lambdas, Reflections
Road Map Inheritance Class hierarchy Overriding methods Constructors
Nested class.
Functional Programming with Java
Object oriented vs procedural programming
CS18000: Problem Solving and Object-Oriented Programming
Java – Inheritance.
OO Design with Inheritance
Java Programming, Second Edition
Functional interface.
Quizz Results hw1 quizz mean std-dev
Chapter 14 Abstract Classes and Interfaces
Inheritance and Polymorphism
Inner Classes 17-Apr-19.
Inner Classes 21-Apr-19.
Review of Previous Lesson
Object-Oriented PHP (1)
Inner Classes 11-May-19.
Inner Classes 18-May-19.
Inner Classes.
CIS 110: Introduction to computer programming
CSG2H3 Object Oriented Programming
Inner Classes 25-Oct-19.
Presentation transcript:

Elipses int... passed into method as int[] Object... passed into method as Object[] Date... passed into method as Date[] etc.

Casting Casting down may be done ONLY down the class hierarchy. Casting up is not required because a subclass object may always be stored in a superclass reference (or an interface that it implements).

Reflection If your program is written well and adheres to the principals of polymorphism, then you don't really need reflection. It's nice to know you have it when testing/debugging though.

Recursion Often times recursion is simpler than iteration. Certain applications require recursion, such as binary trees. Let's see some examples. break to code. 4

Intro to Data Structures in Java Single Lined List Stack Binary Tree others...

Inner and Anonymous Classes Though you are captive in the OO paradigm, you can use inner classes and anonymous classes to get around this constraint and write procedural-like code. Often times, no one but the enclosing class cares about an object. In this case, you may consider using inner or anonymous classes.

WindowsBuilderPro by Google http://download.eclipse.org/windowbuilder/ WB/release/R201109201200/3.7/ b,y,c,n,s,l,d,f,str; get rid of these in Window || Preferences || Java || Code Style || Fields. Otherwise, they will hose you in WB.

Constructors Constructors are optional. If your class is just a static driver; i.e. it just has a static main method, then no need to instantiate it; and no need for constructor. If your class is a "java bean" -- a class that models a real world object (noun) in your system, then it should have a constructor. House, Car, Person, etc. If you don't provide a constructor, a no-args constructor is provided automatically. You can, and often want, more than one constructor with different signatures. You call a constrcutor with the 'new' keyword.

Model a system Object-oriented programming is about modelling a system. Write the problem out as requirements -- this will essentially be a math world problem (your favorite kind to solve!) Your computer objects map directly to real- world objects (nouns). Your methods map directly to real-world actions (verbs).

Build a GUI using WindowBuilder and Swing. Write a very simple application for a contact manager. The the sake of simplicity, each contact will have a name and a phone number only. The user should be able to create new contacts and diplay all contacts. Build a GUI using WindowBuilder and Swing. Solve a simple word problem. Red are verbs and blue are nouns. Model the system! Nouns are either objects or fields (properties of objects). Verbs are methods. 12

Interfaces A class implements an interface rather than extends it. Any class that implements the interface must override all the interface methods with it's own methods. Interface names often end with "able" to imply that they add to the capabilty of the class. An interface is a contract; it defines the methods

Class Objects

The ColorSelector GUI App

The Leet Translator GUI App