Presentation is loading. Please wait.

Presentation is loading. Please wait.

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.

Similar presentations


Presentation on theme: "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."— Presentation transcript:

1 Final Review James Atlas August 12, 2008

2 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…

3 August 12,2008James Atlas - CISC3703 First, a list of topics http://www.cis.udel.edu/~atlas/cisc370/finalprep.html http://www.cis.udel.edu/~atlas/cisc370/finalprep.html 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

4 August 12,2008James Atlas - CISC3704

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

25 August 12,2008James Atlas - CISC37025 The End!

26 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

27 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

28 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.

29 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();

30 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

31 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.

32 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

33 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

34 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

35 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

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

37 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

38 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

39 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

40 August 12,2008James Atlas - CISC37040 Synchronization Diagram

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


Download ppt "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."

Similar presentations


Ads by Google