Final Review James Atlas August 12, 2008. James Atlas - CISC3702 “Family Feud” style Each team gets a chance to pick an answer Each team gets a chance.

Slides:



Advertisements
Similar presentations
Lab Information Security Using Java (Review) Lab#0 Omaima Al-Matrafi.
Advertisements

Lab#1 (14/3/1431h) Introduction To java programming cs425
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
Inheritance and Class Hierarchies Chapter 3. Chapter 3: Inheritance and Class Hierarchies2 Chapter Objectives To understand inheritance and how it facilitates.
OOP in Java Nelson Padua-Perez Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
Principles of Object-Oriented Software Development The language Java.
1 Chapter 7 Inheritance, Polymorphism, and Scope.
Outline Java program structure Basic program elements
Scott Grissom, copyright 2004Ch 3: Java Features Slide 1 Why Java? It is object-oriented provides many ready to use classes platform independent modern.
COMS S1007 Object-Oriented Programming and Design in Java August 7, 2007.
Terms and Rules Professor Evan Korth New York University (All rights reserved)
VB in Context Michael B. Spring Department of Information Science and Telecommunications University of Pittsburgh Pittsburgh, Pa 15260
Data Abstraction and Object- Oriented Programming CS351 – Programming Paradigms.
ASP.NET Programming with C# and SQL Server First Edition
Chapter 10 Classes Continued
OOP in Java Fawzi Emad Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
Networking with Java CSc 335 Object-Oriented Programming and Design Spring 2009.
Lecture 1: Overview of Java. What is java? Developed by Sun Microsystems (James Gosling) A general-purpose object-oriented language Based on C/C++ Designed.
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.
Java Course Outline Kumar Harshit, USW. Course Description Teaches students to program using the Java programming language with the help of the Netbeans.
Java Software Solutions Lewis and Loftus Chapter 2 1 Copyright 1997 by John Lewis and William Loftus. All rights reserved. Software Concepts -- Introduction.
Principles of Computer Programming (using Java) Review Haidong Xue Summer 2011, at GSU.
Advanced Inheritance Concepts. In this chapter, we will cover: Creating and using abstract classes Using dynamic method binding Creating arrays of subclass.
Introduction to Java Appendix A. Appendix A: Introduction to Java2 Chapter Objectives To understand the essentials of object-oriented programming in Java.
Programming Languages and Paradigms Object-Oriented Programming.
1 Identifiers  Identifiers are the words a programmer uses in a program  An identifier can be made up of letters, digits, the underscore character (
CSM-Java Programming-I Spring,2005 Objects and Classes Overview Lesson - 1.
Introduction to Object Oriented Programming. Object Oriented Programming Technique used to develop programs revolving around the real world entities In.
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.
Algorithm Programming Bar-Ilan University תשס"ח by Moshe Fresko.
The Java Programming Language
Lecture 2 Object Oriented Programming Basics of Java Language MBY.
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.
JAVA BASICS Prepared by The Smartpath Information Systems
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.
Page: 1 การโปรแกรมเชิงวัตถุด้วยภาษา JAVA บุรินทร์ รุจจนพันธุ์.. ปรับปรุง 15 มิถุนายน 2552 Keyword & Data Type มหาวิทยาลัยเนชั่น.
Programming in Java CSCI-2220 Object Oriented Programming.
Chapter 6 Introduction to Defining Classes. Objectives: Design and implement a simple class from user requirements. Organize a program in terms of a view.
Programming with Java © 2002 The McGraw-Hill Companies, Inc. All rights reserved. 1 McGraw-Hill/Irwin Chapter 5 Creating Classes.
Lecture 10 Concepts of Programming Languages Arne Kutzner Hanyang University / Seoul Korea.
Introduction to Java Chapter 7 - Classes & Object-oriented Programming1 Chapter 7 Classes and Object-Oriented Programming.
Inheritance. Inheritance - Introduction Idea behind is to create new classes that are built on existing classes – you reuse the methods and fields and.
Chapter 10: Introduction to Inheritance. Objectives Learn about the concept of inheritance Extend classes Override superclass methods Call constructors.
ISBN Object-Oriented Programming Chapter Chapter
Chapter 8 Class Inheritance and Interfaces F Superclasses and Subclasses  Keywords: super F Overriding methods  The Object Class  Modifiers: protected,
 In the java programming language, a keyword is one of 50 reserved words which have a predefined meaning in the language; because of this,
Inheritance and Class Hierarchies Chapter 3. Chapter 3: Inheritance and Class Hierarchies2 Chapter Objectives To understand inheritance and how it facilitates.
Java Programming, Second Edition Chapter Twelve Advanced Inheritance Concepts.
Inheritance and Class Hierarchies Chapter 3. Chapter Objectives  To understand inheritance and how it facilitates code reuse  To understand how Java.
Classes, Interfaces and Packages
Quick Review of OOP Constructs Classes:  Data types for structured data and behavior  fields and methods Objects:  Variables whose data type is a class.
Reference Types CSE301 University of Sunderland Harry R Erwin, PhD.
ISBN Chapter 12 Support for Object-Oriented Programming.
RealTimeSystems Lab Jong-Koo, Lim
JAVA TRAINING IN NOIDA. JAVA Java is a general-purpose computer programming language that is concurrent, class-based, object-oriented and specifically.
Copyright 2010 by Pearson Education APCS Building Java Programs Chapter 1 Lecture 1-1: Introduction; Basic Java Programs reading:
 It is a pure oops language and a high level language.  It was developed at sun microsystems by James Gosling.
JAVA MULTIPLE CHOICE QUESTION.
University of Central Florida COP 3330 Object Oriented Programming
Object-Orientated Programming
null, true, and false are also reserved.
Programming in Java Text Books :
Java Programming Language
Chapter 1: Computer Systems
Advanced Inheritance Concepts
Chap 2. Identifiers, Keywords, and Types
Lecture 10 Concepts of Programming Languages
Presentation transcript:

Final Review James Atlas August 12, 2008

James Atlas - CISC3702 “Family Feud” style Each team gets a chance to pick an answer Each team gets a chance to pick an answer The team with the highest ranked answer gets to try to guess the rest The team with the highest ranked answer gets to try to guess the rest 2 wrong answers and the other team can then “steal” the category 2 wrong answers and the other team can then “steal” the category Each category winner gets candy! Each category winner gets candy! Must be able to explain a little about the answer! And there are bonus questions… Must be able to explain a little about the answer! And there are bonus questions…

August 12,2008James Atlas - CISC3703 First, a list of topics On the exam: On the exam:  Java basics  Syntax, primitive types, control flow, naming conventions  Basic OOP syntax, object-oriented design  OOP in Java: Inheritance, Interfaces, Polymorphism  Advanced classes: inner classes and anonymous classes  Packages  Exceptions  Java Input/Output  Serialization/Cloning  Java Collections framework  The Swing toolkit  Network programming  Multithreaded programming  Software design patterns  XML

August 12,2008James Atlas - CISC3704

August 12,2008James Atlas - CISC3705 What is Java? Programming Language (Sun) 5 Large Library of Tools Cross-platform Object-oriented boolean long float int

August 12,2008James Atlas - CISC3706 Name some components of the Java Virtual Machine Versions (native code for each platform) Dynamic Compiler Garbage Collector Bytecode Interpreter boolean long float int

August 12,2008James Atlas - CISC3707 Name a Java primitive type char 6 short 7 byte double boolean long float int char short byte double boolean long float int

August 12,2008James Atlas - CISC3708 Name a method/field access modifier package-private 5 protected private public boolean long float int

August 12,2008James Atlas - CISC3709 Name a different keyworded method/field modifier transient 5 volatile synchronized final static double boolean long float int

August 12,2008James Atlas - CISC37010 How do you control a loop in Java? continue 5 break do-while while for double boolean long float int

August 12,2008James Atlas - CISC37011 What Java constructs provide the basis for Object-oriented principles? java.lang.Object/Instances 5 Abstract Classes Interfaces Classes boolean long float int

August 12,2008James Atlas - CISC37012 BONUS: Every variable is passed-by- value in Java, how does this work?

August 12,2008James Atlas - CISC37013 What components/properties make up a class definition? Object hierarchy Imports Package Methods Constructors Fields/variables byte double boolean long float int

August 12,2008James Atlas - CISC37014 BONUS: What is overloading and how is it handled in Java?

August 12,2008James Atlas - CISC37015 Name some common Interfaces related to the Java Collections Framework Queue 5 Comparable 5 Collection Set Map List byte double boolean long float int

August 12,2008James Atlas - CISC37016 What keywords are used in Java Exception handling? finally throws try catch boolean long float int

August 12,2008James Atlas - CISC37017 Name a Java I/O class or interface ObjectInputStream/Out 4 DataInputStream/Out 6 SocketInputStream/Out FileInputStream/Out OutputStream InputStream byte double boolean long float int

August 12,2008James Atlas - CISC37018 BONUS: What design pattern does Java I/O follow?

August 12,2008James Atlas - CISC37019 Name a way/reason to use an inner- class Access the surrounding implementation Implement interfaces on-the-fly Convenient Hidden from other classes boolean long float int

August 12,2008James Atlas - CISC37020 Name a general software pattern (only ones we talked about in class) Observer/Event 4 Command 6 MVC Decorator Factory double boolean long float int

August 12,2008James Atlas - CISC37021 Name a component of the Java Swing framework Event 4 Menu 6 Panel Button Layout Container Frame short byte double boolean long float int

August 12,2008James Atlas - CISC37022 Name a component of the Java Network Programming model DatagramPacket 5 InetAddress 5 Stream ServerSocket Socket double boolean long float int

August 12,2008James Atlas - CISC37023 Name an activity that a Java program can perform on XML validate transform generate/write parse/read boolean long float int

August 12,2008James Atlas - CISC37024 BONUS: Explain the difference between the SAX and DOM programming models

August 12,2008James Atlas - CISC37025 The End!

August 12,2008James Atlas - CISC37026 Object Destructors In C++ (and many other OOP languages), classes have explicit destructor methods that run when an object is no longer used. In C++ (and many other OOP languages), classes have explicit destructor methods that run when an object is no longer used. Java does not support destructors, as it provides automatic garbage collection Java does not support destructors, as it provides automatic garbage collection  Watches/waits until there are no references to an object  Reclaims the memory allocated for the object that is no longer used

August 12,2008James Atlas - CISC37027 finalize() Java supports a method named finalize(). Java supports a method named finalize(). method is called before the garbage collector sweeps away the object and reclaims the memory method is called before the garbage collector sweeps away the object and reclaims the memory This method should not be used for reclaiming any resources This method should not be used for reclaiming any resources  the timing when this method is called is not deterministic or consistent  only know it will run sometime before garbage collection

August 12,2008James Atlas - CISC37028 Summary of Inheritance Place common operations & fields in the superclass. Place common operations & fields in the superclass.  Remove repetitive code by modeling the “is-a” hierarchy  Move “common denominator” code up the inheritance chain Protected fields are generally not a good idea. Protected fields are generally not a good idea. Don’t use inheritance unless all inherited methods make sense Don’t use inheritance unless all inherited methods make sense Use polymorphism. Use polymorphism.

August 12,2008James Atlas - CISC37029 Abstract Classes Some methods defined, others not defined Some methods defined, others not defined Classes in which not all methods are implemented are abstract classes. Classes in which not all methods are implemented are abstract classes.  public abstract class Animal Blank methods are labeled with the abstract keyword also Blank methods are labeled with the abstract keyword also  public abstract void feed();

August 12,2008James Atlas - CISC37030 Abstract Classes An abstract class cannot be instantiated An abstract class cannot be instantiated Subclass of an abstract class can only be instantiated if it overrides each of the abstract methods of its superclass and provides implementation Subclass of an abstract class can only be instantiated if it overrides each of the abstract methods of its superclass and provides implementation  If subclass does not override all abstract methods, it is also abstract Use abstract classes when you have a partial implementation Use abstract classes when you have a partial implementation

August 12,2008James Atlas - CISC37031 Methods: An Alternate Ending If a method throws an exception If a method throws an exception  it does not return anything  execution does not resume immediately following the method call (as it would if the method returns a normal value) JVM’s searches for an JVM’s exception-handling mechanism searches for an exception handler  Exception handler: error recovery code runs to deal with a particular error condition. runs to deal with a particular error condition.

August 12,2008James Atlas - CISC37032 Streams Java handles input/output using streams Java handles input/output using streams input stream: an object from which we can read a sequence of bytes Abstract class: InputStream

August 12,2008James Atlas - CISC37033 Streams Java handles input/output using streams Java handles input/output using streams output stream: an object to which we can write a sequence of bytes Abstract class: OutputStream

August 12,2008James Atlas - CISC37034 Object Serialization Serialization: process of converting an object to ordered data, to operate with streams Serialization: process of converting an object to ordered data, to operate with streams To allow a class of objects to be written and read with Object[Output/Input]Stream To allow a class of objects to be written and read with Object[Output/Input]Stream  the class must implement the Serializable interface Serializable interface contains no methods Serializable interface contains no methods  “Marker interface”  used to tag a class as able to be serialized  refers to the class’s ability to be converted into a single byte stream, which is then saved All classes are inherently serializable All classes are inherently serializable  But you have to mark them as Serializable

August 12,2008James Atlas - CISC37035 Object Serialization When an object is written to a stream, it is written as a sequence of bytes. When an object is written to a stream, it is written as a sequence of bytes. Stores, in order Stores, in order  fingerprinting information that describes the class  instance fields and their values  a more complete class description. The ability to convert an object from its “object” state to a byte stream state is what makes the direct writing and reading of objects possible The ability to convert an object from its “object” state to a byte stream state is what makes the direct writing and reading of objects possible

August 12,2008James Atlas - CISC37036 Java-memory model (JMM)

August 12,2008James Atlas - CISC37037 Java-memory model Rules Atomicity Atomicity  access/update to anything except long/double Visibility Visibility  changes not always guaranteed visible synchronization does synchronization does volatile variables volatile variables Thread.join() Thread.join() Ordering Ordering  instructions in-thread are as-if-serial  out-of-thread no guarantee

August 12,2008James Atlas - CISC37038 Thread Synchronization In many multithreaded applications, more than one thread will need to access the same data In many multithreaded applications, more than one thread will need to access the same data  Can turn into a problem when two threads have access to the same object and then both modify the state of the object  Depending on the order of data access, the object can become corrupted  Known as a race condition

August 12,2008James Atlas - CISC37039 Synchronized Methods A method or block of code can be marked as atomic A method or block of code can be marked as atomic  Using keyword synchronized in method’s return type  After the section of code starts, the code is guaranteed to complete before another thread can enter another synchronized section belonging to that same object

August 12,2008James Atlas - CISC37040 Synchronization Diagram

August 12,2008James Atlas - CISC37041 Wait/Notify Mechanism Diagram