Docsity

Object-Oriented Programming Concepts in Java: A Comprehensive Guide, Study notes of Java Programming

Partial preview of the text

Download Object-Oriented Programming Concepts in Java: A Comprehensive Guide and more Study notes Java Programming in PDF only on Docsity!

CS 190 - Java

Introduction to Java

Andy Mroczkowski

[email protected]

Department of Computer Science

Drexel University

February 11, 2008 / Lecture 4

Outline

Course Status Course Information & Schedule Assignments Questions

Polymorphism Polymorphism Re-visisted Pitfalls Constructors & Polymorphism Other

Containers Overview ArrayList HashMap Generics

Exceptions Concepts Catching Exceptions Throwing Exceptions Runtime Exceptions Restrictions and Pitfalls

Midterm Review

Schedule

Jan 7 Course Overview, Introduction to Java

Jan 14 No Class

Jan 21 No Class (University Holiday)

Jan 28 Object Oriented Concepts, Control Statements

Feb 4 Access Control, Intialization & Cleanup, Reuse, Interfaces,

Feb 11 Containers, Exceptions, Polymorphism, Midterm Revie

Feb 18 Midterm, Inner Classes, Strings

Mar 3 File I/O, Threading

Feb 25 Graphical User Interfaces (AWT, Swing)

Mar 10 Networking, Special Topics (Encryption, Reflection)

Mar 17 Final

Also subject to change

Grades

• Assignment 3 is graded

• Grades reported in comments in BB Vista

• See me about grading issues

Assignment 4

• Questions?

• Push back due date to 22 Feb

Midterm

Monday Feb 18th

Questions

• Difference between:

• String[] args

• String args[]

• String[] args is preferred

• String args[] is discouraged

http://java.sun.com/docs/books/tutorial/java/nutsandbolts/arrays.html

Questions

• Difference between:

• String[] args

• String args[]

• String[] args is preferred

• String args[] is discouraged

http://java.sun.com/docs/books/tutorial/java/nutsandbolts/arrays.html

Questions

Do super calls have to occur first in the constructor?

• Yes.

Questions

• Why would you want several things to point to the same

object?

Singleton

• Only one instance for the entire VM

Questions

• Why would you want several things to point to the same

object?

Singleton

• Only one instance for the entire VM

Class Participation!

Let’s write a Singleton!

Hooray!

Singleton - Implementation

p u b l i c c l a s s S i n g l e t o n {

p r o t e c t e d S i n g l e t o n ( ) { }

s t a t i c p r i v a t e S i n g l e t o n _ i n s t a n c e = n u l l ;

s t a t i c p u b l i c S i n g l e t o n g e t I n s t a n c e ( ) {

i f (! _ i n s t a n c e ) {

_ i n s t a n c e = new S i n g l e t o n ( ) ;

r e t u r n _ i n s t a n c e ;

Polymorphism